Skip to content

Commit 0753459

Browse files
committed
Auto merge of #69333 - ecstatic-morse:revert-simd-shuffle, r=petrochenkov
Revert #69280 Resolves #69313 by reverting #69280. After #69280, `#[rustc_args_required_const(2)]` is required on the declaration of `simd_shuffle` intrinsics. This is allowed breakage, since you can't define platform intrinsics on stable. However, the latest release of the widely used `packed_simd` crate defines these intrinsics without the requisite attribute. Since there's no urgency to merge #69280, let's revert it. We can reconsider when rust-lang/packed_simd#278 is included in a point release of `packed_simd`. r? @petrochenkov
2 parents 03d2f5c + 16790ae commit 0753459

9 files changed

+41
-39
lines changed

src/librustc_mir/const_eval/eval_queries.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ fn eval_body_using_ecx<'mir, 'tcx>(
7272
Ok(ret)
7373
}
7474

75-
/// The `InterpCx` is only meant to be used to do field and index projections into promoteds
76-
/// and const patterns in match arms.
75+
/// The `InterpCx` is only meant to be used to do field and index projections into constants for
76+
/// `simd_shuffle` and const patterns in match arms.
7777
///
7878
/// The function containing the `match` that is currently being analyzed may have generic bounds
7979
/// that inform us about the generic bounds of the constant. E.g., using an associated constant

src/librustc_mir/transform/promote_consts.rs

+19-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use rustc_span::{Span, DUMMY_SP};
2424
use syntax::ast::LitKind;
2525

2626
use rustc_index::vec::{Idx, IndexVec};
27+
use rustc_target::spec::abi::Abi;
2728

2829
use std::cell::Cell;
2930
use std::{cmp, iter, mem, usize};
@@ -105,10 +106,11 @@ pub enum Candidate {
105106
/// Promotion of the `x` in `[x; 32]`.
106107
Repeat(Location),
107108

108-
/// Function calls where the callee has the unstable
109-
/// `#[rustc_args_required_const]` attribute. The attribute requires that
110-
/// the arguments be constant, usually because they are encoded as an
111-
/// immediate operand in a platform intrinsic.
109+
/// Currently applied to function calls where the callee has the unstable
110+
/// `#[rustc_args_required_const]` attribute as well as the SIMD shuffle
111+
/// intrinsic. The intrinsic requires the arguments are indeed constant and
112+
/// the attribute currently provides the semantic requirement that arguments
113+
/// must be constant.
112114
Argument { bb: BasicBlock, index: usize },
113115
}
114116

@@ -216,6 +218,17 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
216218

217219
if let TerminatorKind::Call { ref func, .. } = *kind {
218220
if let ty::FnDef(def_id, _) = func.ty(self.body, self.tcx).kind {
221+
let fn_sig = self.tcx.fn_sig(def_id);
222+
if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = fn_sig.abi() {
223+
let name = self.tcx.item_name(def_id);
224+
// FIXME(eddyb) use `#[rustc_args_required_const(2)]` for shuffles.
225+
if name.as_str().starts_with("simd_shuffle") {
226+
self.candidates.push(Candidate::Argument { bb: location.block, index: 2 });
227+
228+
return; // Don't double count `simd_shuffle` candidates
229+
}
230+
}
231+
219232
if let Some(constant_args) = args_required_const(self.tcx, def_id) {
220233
for index in constant_args {
221234
self.candidates.push(Candidate::Argument { bb: location.block, index });
@@ -717,7 +730,8 @@ pub fn validate_candidates(
717730
.filter(|&candidate| {
718731
validator.explicit = candidate.forces_explicit_promotion();
719732

720-
// FIXME(eddyb) also emit the errors for `#[rustc_args_required_const]` arguments here.
733+
// FIXME(eddyb) also emit the errors for shuffle indices
734+
// and `#[rustc_args_required_const]` arguments here.
721735

722736
let is_promotable = validator.validate_candidate(candidate).is_ok();
723737
match candidate {

src/test/incremental/issue-61530.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
#![feature(repr_simd, platform_intrinsics, rustc_attrs)]
1+
#![feature(repr_simd, platform_intrinsics)]
22

33
// revisions:rpass1 rpass2
44

55
#[repr(simd)]
66
struct I32x2(i32, i32);
77

88
extern "platform-intrinsic" {
9-
#[rustc_args_required_const(2)]
109
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
1110
}
1211

src/test/ui/issues/issue-38074.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// run-pass
22
// ignore-emscripten FIXME(#45351)
33

4-
#![feature(platform_intrinsics, repr_simd, rustc_attrs)]
4+
#![feature(platform_intrinsics, repr_simd)]
55

66
extern "platform-intrinsic" {
7-
#[rustc_args_required_const(2)]
87
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
98
}
109

src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.rs

-4
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,9 @@ extern "platform-intrinsic" {
4242
fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;
4343
fn simd_extract<T, E>(x: T, idx: u32) -> E;
4444

45-
#[rustc_args_required_const(2)]
4645
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
47-
#[rustc_args_required_const(2)]
4846
fn simd_shuffle3<T, U>(x: T, y: T, idx: [u32; 3]) -> U;
49-
#[rustc_args_required_const(2)]
5047
fn simd_shuffle4<T, U>(x: T, y: T, idx: [u32; 4]) -> U;
51-
#[rustc_args_required_const(2)]
5248
fn simd_shuffle8<T, U>(x: T, y: T, idx: [u32; 8]) -> U;
5349
}
5450

src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.stderr

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,89 @@
11
error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected SIMD input type, found non-SIMD `i32`
2-
--> $DIR/simd-intrinsic-generic-elements.rs:59:9
2+
--> $DIR/simd-intrinsic-generic-elements.rs:55:9
33
|
44
LL | simd_insert(0, 0, 0);
55
| ^^^^^^^^^^^^^^^^^^^^
66

77
error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected inserted type `i32` (element of input `i32x4`), found `f64`
8-
--> $DIR/simd-intrinsic-generic-elements.rs:61:9
8+
--> $DIR/simd-intrinsic-generic-elements.rs:57:9
99
|
1010
LL | simd_insert(x, 0, 1.0);
1111
| ^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error[E0511]: invalid monomorphization of `simd_extract` intrinsic: expected return type `i32` (element of input `i32x4`), found `f32`
14-
--> $DIR/simd-intrinsic-generic-elements.rs:63:9
14+
--> $DIR/simd-intrinsic-generic-elements.rs:59:9
1515
|
1616
LL | simd_extract::<_, f32>(x, 0);
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818

1919
error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected SIMD input type, found non-SIMD `i32`
20-
--> $DIR/simd-intrinsic-generic-elements.rs:66:9
20+
--> $DIR/simd-intrinsic-generic-elements.rs:62:9
2121
|
2222
LL | simd_shuffle2::<i32, i32>(0, 0, [0; 2]);
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424

2525
error[E0511]: invalid monomorphization of `simd_shuffle3` intrinsic: expected SIMD input type, found non-SIMD `i32`
26-
--> $DIR/simd-intrinsic-generic-elements.rs:68:9
26+
--> $DIR/simd-intrinsic-generic-elements.rs:64:9
2727
|
2828
LL | simd_shuffle3::<i32, i32>(0, 0, [0; 3]);
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3030

3131
error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected SIMD input type, found non-SIMD `i32`
32-
--> $DIR/simd-intrinsic-generic-elements.rs:70:9
32+
--> $DIR/simd-intrinsic-generic-elements.rs:66:9
3333
|
3434
LL | simd_shuffle4::<i32, i32>(0, 0, [0; 4]);
3535
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3636

3737
error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected SIMD input type, found non-SIMD `i32`
38-
--> $DIR/simd-intrinsic-generic-elements.rs:72:9
38+
--> $DIR/simd-intrinsic-generic-elements.rs:68:9
3939
|
4040
LL | simd_shuffle8::<i32, i32>(0, 0, [0; 8]);
4141
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4242

4343
error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32`
44-
--> $DIR/simd-intrinsic-generic-elements.rs:75:9
44+
--> $DIR/simd-intrinsic-generic-elements.rs:71:9
4545
|
4646
LL | simd_shuffle2::<_, f32x2>(x, x, [0; 2]);
4747
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4848

4949
error[E0511]: invalid monomorphization of `simd_shuffle3` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x3` with element type `f32`
50-
--> $DIR/simd-intrinsic-generic-elements.rs:77:9
50+
--> $DIR/simd-intrinsic-generic-elements.rs:73:9
5151
|
5252
LL | simd_shuffle3::<_, f32x3>(x, x, [0; 3]);
5353
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5454

5555
error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32`
56-
--> $DIR/simd-intrinsic-generic-elements.rs:79:9
56+
--> $DIR/simd-intrinsic-generic-elements.rs:75:9
5757
|
5858
LL | simd_shuffle4::<_, f32x4>(x, x, [0; 4]);
5959
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6060

6161
error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32`
62-
--> $DIR/simd-intrinsic-generic-elements.rs:81:9
62+
--> $DIR/simd-intrinsic-generic-elements.rs:77:9
6363
|
6464
LL | simd_shuffle8::<_, f32x8>(x, x, [0; 8]);
6565
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6666

6767
error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected return type of length 2, found `i32x8` with length 8
68-
--> $DIR/simd-intrinsic-generic-elements.rs:84:9
68+
--> $DIR/simd-intrinsic-generic-elements.rs:80:9
6969
|
7070
LL | simd_shuffle2::<_, i32x8>(x, x, [0; 2]);
7171
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7272

7373
error[E0511]: invalid monomorphization of `simd_shuffle3` intrinsic: expected return type of length 3, found `i32x4` with length 4
74-
--> $DIR/simd-intrinsic-generic-elements.rs:86:9
74+
--> $DIR/simd-intrinsic-generic-elements.rs:82:9
7575
|
7676
LL | simd_shuffle3::<_, i32x4>(x, x, [0; 3]);
7777
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7878

7979
error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return type of length 4, found `i32x3` with length 3
80-
--> $DIR/simd-intrinsic-generic-elements.rs:88:9
80+
--> $DIR/simd-intrinsic-generic-elements.rs:84:9
8181
|
8282
LL | simd_shuffle4::<_, i32x3>(x, x, [0; 4]);
8383
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8484

8585
error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected return type of length 8, found `i32x2` with length 2
86-
--> $DIR/simd-intrinsic-generic-elements.rs:90:9
86+
--> $DIR/simd-intrinsic-generic-elements.rs:86:9
8787
|
8888
LL | simd_shuffle8::<_, i32x2>(x, x, [0; 8]);
8989
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/simd-intrinsic/simd-intrinsic-inlining-issue67557-ice.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
//
44
// run-pass
55
// compile-flags: -Zmir-opt-level=3
6-
#![feature(platform_intrinsics, repr_simd, rustc_attrs)]
6+
#![feature(platform_intrinsics, repr_simd)]
77

88
extern "platform-intrinsic" {
9-
#[rustc_args_required_const(2)]
109
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
1110
}
1211

src/test/ui/simd-intrinsic/simd-intrinsic-inlining-issue67557.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
//
44
// run-pass
55
// compile-flags: -Zmir-opt-level=3
6-
#![feature(platform_intrinsics, repr_simd, rustc_attrs)]
6+
#![feature(platform_intrinsics, repr_simd)]
77

88
extern "platform-intrinsic" {
9-
#[rustc_args_required_const(2)]
109
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
1110
}
1211

src/test/ui/simd/simd-intrinsic-generic-elements.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-pass
22
// ignore-emscripten FIXME(#45351) hits an LLVM assert
33

4-
#![feature(repr_simd, platform_intrinsics, rustc_attrs)]
4+
#![feature(repr_simd, platform_intrinsics)]
55

66
#[repr(simd)]
77
#[derive(Copy, Clone, Debug, PartialEq)]
@@ -25,13 +25,9 @@ extern "platform-intrinsic" {
2525
fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;
2626
fn simd_extract<T, E>(x: T, idx: u32) -> E;
2727

28-
#[rustc_args_required_const(2)]
2928
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
30-
#[rustc_args_required_const(2)]
3129
fn simd_shuffle3<T, U>(x: T, y: T, idx: [u32; 3]) -> U;
32-
#[rustc_args_required_const(2)]
3330
fn simd_shuffle4<T, U>(x: T, y: T, idx: [u32; 4]) -> U;
34-
#[rustc_args_required_const(2)]
3531
fn simd_shuffle8<T, U>(x: T, y: T, idx: [u32; 8]) -> U;
3632
}
3733

0 commit comments

Comments
 (0)