Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4457ef2

Browse files
committedAug 3, 2023
Forbid old-style simd_shuffleN intrinsics
1 parent 2e6ac7f commit 4457ef2

File tree

16 files changed

+393
-380
lines changed

16 files changed

+393
-380
lines changed
 

‎compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
117117
});
118118
}
119119

120-
// simd_shuffle32<T, U>(x: T, y: T, idx: [u32; 32]) -> U
121-
_ if intrinsic.as_str().starts_with("simd_shuffle") => {
120+
// simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U
121+
sym::simd_shuffle => {
122122
let (x, y, idx) = match args {
123123
[x, y, idx] => (x, y, idx),
124124
_ => {
@@ -133,36 +133,26 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
133133
return;
134134
}
135135

136-
// If this intrinsic is the older "simd_shuffleN" form, simply parse the integer.
137-
// If there is no suffix, use the index array length.
138-
let n: u16 = if intrinsic == sym::simd_shuffle {
139-
// Make sure this is actually an array, since typeck only checks the length-suffixed
140-
// version of this intrinsic.
141-
let idx_ty = fx.monomorphize(idx.ty(fx.mir, fx.tcx));
142-
match idx_ty.kind() {
143-
ty::Array(ty, len) if matches!(ty.kind(), ty::Uint(ty::UintTy::U32)) => len
144-
.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
145-
.unwrap_or_else(|| {
146-
span_bug!(span, "could not evaluate shuffle index array length")
147-
})
148-
.try_into()
149-
.unwrap(),
150-
_ => {
151-
fx.tcx.sess.span_err(
152-
span,
153-
format!(
154-
"simd_shuffle index must be an array of `u32`, got `{}`",
155-
idx_ty,
156-
),
157-
);
158-
// Prevent verifier error
159-
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
160-
return;
161-
}
136+
// Make sure this is actually an array, since typeck only checks the length-suffixed
137+
// version of this intrinsic.
138+
let idx_ty = fx.monomorphize(idx.ty(fx.mir, fx.tcx));
139+
let n: u16 = match idx_ty.kind() {
140+
ty::Array(ty, len) if matches!(ty.kind(), ty::Uint(ty::UintTy::U32)) => len
141+
.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
142+
.unwrap_or_else(|| {
143+
span_bug!(span, "could not evaluate shuffle index array length")
144+
})
145+
.try_into()
146+
.unwrap(),
147+
_ => {
148+
fx.tcx.sess.span_err(
149+
span,
150+
format!("simd_shuffle index must be an array of `u32`, got `{}`", idx_ty),
151+
);
152+
// Prevent verifier error
153+
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
154+
return;
162155
}
163-
} else {
164-
// FIXME remove this case
165-
intrinsic.as_str()["simd_shuffle".len()..].parse().unwrap()
166156
};
167157

168158
assert_eq!(x.layout(), y.layout());
@@ -179,7 +169,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
179169
let indexes = {
180170
use rustc_middle::mir::interpret::*;
181171
let idx_const = crate::constant::mir_operand_get_const_val(fx, idx)
182-
.expect("simd_shuffle* idx not const");
172+
.expect("simd_shuffle idx not const");
183173

184174
let idx_bytes = match idx_const {
185175
ConstValue::ByRef { alloc, offset } => {

‎compiler/rustc_codegen_gcc/src/intrinsic/simd.rs

Lines changed: 250 additions & 195 deletions
Large diffs are not rendered by default.

‎compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,28 +1020,20 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
10201020
));
10211021
}
10221022

1023-
if let Some(stripped) = name.as_str().strip_prefix("simd_shuffle") {
1024-
// If this intrinsic is the older "simd_shuffleN" form, simply parse the integer.
1025-
// If there is no suffix, use the index array length.
1026-
let n: u64 = if stripped.is_empty() {
1027-
// Make sure this is actually an array, since typeck only checks the length-suffixed
1028-
// version of this intrinsic.
1029-
match args[2].layout.ty.kind() {
1030-
ty::Array(ty, len) if matches!(ty.kind(), ty::Uint(ty::UintTy::U32)) => {
1031-
len.try_eval_target_usize(bx.cx.tcx, ty::ParamEnv::reveal_all()).unwrap_or_else(
1032-
|| span_bug!(span, "could not evaluate shuffle index array length"),
1033-
)
1034-
}
1035-
_ => return_error!(InvalidMonomorphization::SimdShuffle {
1036-
span,
1037-
name,
1038-
ty: args[2].layout.ty
1039-
}),
1023+
if name == sym::simd_shuffle {
1024+
// Make sure this is actually an array, since typeck only checks the length-suffixed
1025+
// version of this intrinsic.
1026+
let n: u64 = match args[2].layout.ty.kind() {
1027+
ty::Array(ty, len) if matches!(ty.kind(), ty::Uint(ty::UintTy::U32)) => {
1028+
len.try_eval_target_usize(bx.cx.tcx, ty::ParamEnv::reveal_all()).unwrap_or_else(
1029+
|| span_bug!(span, "could not evaluate shuffle index array length"),
1030+
)
10401031
}
1041-
} else {
1042-
stripped.parse().unwrap_or_else(|_| {
1043-
span_bug!(span, "bad `simd_shuffle` instruction only caught in codegen?")
1044-
})
1032+
_ => return_error!(InvalidMonomorphization::SimdShuffle {
1033+
span,
1034+
name,
1035+
ty: args[2].layout.ty
1036+
}),
10451037
};
10461038

10471039
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });

‎compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,11 +862,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
862862
.iter()
863863
.enumerate()
864864
.map(|(i, arg)| {
865-
// The indices passed to simd_shuffle* in the
865+
// The indices passed to simd_shuffle in the
866866
// third argument must be constant. This is
867867
// checked by const-qualification, which also
868868
// promotes any complex rvalues to constants.
869-
if i == 2 && intrinsic.as_str().starts_with("simd_shuffle") {
869+
if i == 2 && intrinsic == sym::simd_shuffle {
870870
if let mir::Operand::Constant(constant) = arg {
871871
let (llval, ty) = self.simd_shuffle_indices(&bx, constant);
872872
return OperandRef {

‎compiler/rustc_error_codes/src/error_codes/E0439.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern "platform-intrinsic" {
1616
The `simd_shuffle` function needs the length of the array passed as
1717
last parameter in its name. Example:
1818

19-
```
19+
```ignore (no longer compiles)
2020
#![feature(platform_intrinsics)]
2121
2222
extern "platform-intrinsic" {

‎compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -567,20 +567,6 @@ pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>)
567567
| sym::simd_reduce_min_nanless
568568
| sym::simd_reduce_max_nanless => (2, vec![param(0)], param(1)),
569569
sym::simd_shuffle => (3, vec![param(0), param(0), param(1)], param(2)),
570-
name if name.as_str().starts_with("simd_shuffle") => {
571-
match name.as_str()["simd_shuffle".len()..].parse() {
572-
Ok(n) => {
573-
let params = vec![param(0), param(0), Ty::new_array(tcx, tcx.types.u32, n)];
574-
(2, params, param(1))
575-
}
576-
Err(_) => {
577-
let msg =
578-
format!("unrecognized platform-specific intrinsic function: `{name}`");
579-
tcx.sess.struct_span_err(it.span, msg).emit();
580-
return;
581-
}
582-
}
583-
}
584570
_ => {
585571
let msg = format!("unrecognized platform-specific intrinsic function: `{name}`");
586572
tcx.sess.struct_span_err(it.span, msg).emit();

‎compiler/rustc_mir_transform/src/lower_intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
305305
terminator.kind = TerminatorKind::Unreachable;
306306
}
307307
}
308-
_ if intrinsic_name.as_str().starts_with("simd_shuffle") => {
308+
sym::simd_shuffle => {
309309
validate_simd_shuffle(tcx, args, terminator.source_info.span);
310310
}
311311
_ => {}

‎tests/incremental/issue-61530.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
struct I32x2(i32, i32);
77

88
extern "platform-intrinsic" {
9-
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
9+
fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U;
1010
}
1111

1212
fn main() {
1313
unsafe {
1414
const IDX: [u32; 2] = [0, 0];
15-
let _: I32x2 = simd_shuffle2(I32x2(1, 2), I32x2(3, 4), IDX);
16-
let _: I32x2 = simd_shuffle2(I32x2(1, 2), I32x2(3, 4), IDX);
15+
let _: I32x2 = simd_shuffle(I32x2(1, 2), I32x2(3, 4), IDX);
16+
let _: I32x2 = simd_shuffle(I32x2(1, 2), I32x2(3, 4), IDX);
1717
}
1818
}

‎tests/ui/simd/intrinsic/generic-elements-pass.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ extern "platform-intrinsic" {
2222
fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;
2323
fn simd_extract<T, E>(x: T, idx: u32) -> E;
2424

25-
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
26-
fn simd_shuffle4<T, U>(x: T, y: T, idx: [u32; 4]) -> U;
27-
fn simd_shuffle8<T, U>(x: T, y: T, idx: [u32; 8]) -> U;
25+
fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U;
2826
}
2927

3028
macro_rules! all_eq {
@@ -83,19 +81,19 @@ fn main() {
8381
let y4 = i32x4(140, 141, 142, 143);
8482
let y8 = i32x8(180, 181, 182, 183, 184, 185, 186, 187);
8583
unsafe {
86-
all_eq!(simd_shuffle2(x2, y2, const { [3u32, 0] }), i32x2(121, 20));
87-
all_eq!(simd_shuffle4(x2, y2, const { [3u32, 0, 1, 2] }), i32x4(121, 20, 21, 120));
88-
all_eq!(simd_shuffle8(x2, y2, const { [3u32, 0, 1, 2, 1, 2, 3, 0] }),
84+
all_eq!(simd_shuffle(x2, y2, const { [3u32, 0] }), i32x2(121, 20));
85+
all_eq!(simd_shuffle(x2, y2, const { [3u32, 0, 1, 2] }), i32x4(121, 20, 21, 120));
86+
all_eq!(simd_shuffle(x2, y2, const { [3u32, 0, 1, 2, 1, 2, 3, 0] }),
8987
i32x8(121, 20, 21, 120, 21, 120, 121, 20));
9088

91-
all_eq!(simd_shuffle2(x4, y4, const { [7u32, 2] }), i32x2(143, 42));
92-
all_eq!(simd_shuffle4(x4, y4, const { [7u32, 2, 5, 0] }), i32x4(143, 42, 141, 40));
93-
all_eq!(simd_shuffle8(x4, y4, const { [7u32, 2, 5, 0, 3, 6, 4, 1] }),
89+
all_eq!(simd_shuffle(x4, y4, const { [7u32, 2] }), i32x2(143, 42));
90+
all_eq!(simd_shuffle(x4, y4, const { [7u32, 2, 5, 0] }), i32x4(143, 42, 141, 40));
91+
all_eq!(simd_shuffle(x4, y4, const { [7u32, 2, 5, 0, 3, 6, 4, 1] }),
9492
i32x8(143, 42, 141, 40, 43, 142, 140, 41));
9593

96-
all_eq!(simd_shuffle2(x8, y8, const { [11u32, 5] }), i32x2(183, 85));
97-
all_eq!(simd_shuffle4(x8, y8, const { [11u32, 5, 15, 0] }), i32x4(183, 85, 187, 80));
98-
all_eq!(simd_shuffle8(x8, y8, const { [11u32, 5, 15, 0, 3, 8, 12, 1] }),
94+
all_eq!(simd_shuffle(x8, y8, const { [11u32, 5] }), i32x2(183, 85));
95+
all_eq!(simd_shuffle(x8, y8, const { [11u32, 5, 15, 0] }), i32x4(183, 85, 187, 80));
96+
all_eq!(simd_shuffle(x8, y8, const { [11u32, 5, 15, 0, 3, 8, 12, 1] }),
9997
i32x8(183, 85, 187, 80, 83, 180, 184, 81));
10098
}
10199

‎tests/ui/simd/intrinsic/generic-elements.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ extern "platform-intrinsic" {
3434
fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;
3535
fn simd_extract<T, E>(x: T, idx: u32) -> E;
3636

37-
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
38-
fn simd_shuffle4<T, U>(x: T, y: T, idx: [u32; 4]) -> U;
39-
fn simd_shuffle8<T, U>(x: T, y: T, idx: [u32; 8]) -> U;
37+
fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U;
4038
}
4139

4240
fn main() {
@@ -51,27 +49,27 @@ fn main() {
5149
//~^ ERROR expected return type `i32` (element of input `i32x4`), found `f32`
5250

5351
const IDX2: [u32; 2] = [0; 2];
54-
simd_shuffle2::<i32, i32>(0, 0, IDX2);
52+
simd_shuffle::<i32, _, i32>(0, 0, IDX2);
5553
//~^ ERROR expected SIMD input type, found non-SIMD `i32`
5654
const IDX4: [u32; 4] = [0; 4];
57-
simd_shuffle4::<i32, i32>(0, 0, IDX4);
55+
simd_shuffle::<i32, _, i32>(0, 0, IDX4);
5856
//~^ ERROR expected SIMD input type, found non-SIMD `i32`
5957
const IDX8: [u32; 8] = [0; 8];
60-
simd_shuffle8::<i32, i32>(0, 0, IDX8);
58+
simd_shuffle::<i32, _, i32>(0, 0, IDX8);
6159
//~^ ERROR expected SIMD input type, found non-SIMD `i32`
6260

63-
simd_shuffle2::<_, f32x2>(x, x, IDX2);
61+
simd_shuffle::<_, _, f32x2>(x, x, IDX2);
6462
//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32`
65-
simd_shuffle4::<_, f32x4>(x, x, IDX4);
63+
simd_shuffle::<_, _, f32x4>(x, x, IDX4);
6664
//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32`
67-
simd_shuffle8::<_, f32x8>(x, x, IDX8);
65+
simd_shuffle::<_, _, f32x8>(x, x, IDX8);
6866
//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32`
6967

70-
simd_shuffle2::<_, i32x8>(x, x, IDX2);
68+
simd_shuffle::<_, _, i32x8>(x, x, IDX2);
7169
//~^ ERROR expected return type of length 2, found `i32x8` with length 8
72-
simd_shuffle4::<_, i32x8>(x, x, IDX4);
70+
simd_shuffle::<_, _, i32x8>(x, x, IDX4);
7371
//~^ ERROR expected return type of length 4, found `i32x8` with length 8
74-
simd_shuffle8::<_, i32x2>(x, x, IDX8);
72+
simd_shuffle::<_, _, i32x2>(x, x, IDX8);
7573
//~^ ERROR expected return type of length 8, found `i32x2` with length 2
7674
}
7775
}

‎tests/ui/simd/intrinsic/generic-elements.stderr

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
11
error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected SIMD input type, found non-SIMD `i32`
2-
--> $DIR/generic-elements.rs:46:9
2+
--> $DIR/generic-elements.rs:44: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/generic-elements.rs:48:9
8+
--> $DIR/generic-elements.rs:46: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/generic-elements.rs:50:9
14+
--> $DIR/generic-elements.rs:48:9
1515
|
1616
LL | simd_extract::<_, f32>(x, 0);
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818

19-
error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected SIMD input type, found non-SIMD `i32`
20-
--> $DIR/generic-elements.rs:54:9
19+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32`
20+
--> $DIR/generic-elements.rs:52:9
2121
|
22-
LL | simd_shuffle2::<i32, i32>(0, 0, IDX2);
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22+
LL | simd_shuffle::<i32, _, i32>(0, 0, IDX2);
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424

25-
error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected SIMD input type, found non-SIMD `i32`
26-
--> $DIR/generic-elements.rs:57:9
25+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32`
26+
--> $DIR/generic-elements.rs:55:9
2727
|
28-
LL | simd_shuffle4::<i32, i32>(0, 0, IDX4);
29-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28+
LL | simd_shuffle::<i32, _, i32>(0, 0, IDX4);
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3030

31-
error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected SIMD input type, found non-SIMD `i32`
32-
--> $DIR/generic-elements.rs:60:9
31+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32`
32+
--> $DIR/generic-elements.rs:58:9
3333
|
34-
LL | simd_shuffle8::<i32, i32>(0, 0, IDX8);
35-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34+
LL | simd_shuffle::<i32, _, i32>(0, 0, IDX8);
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3636

37-
error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32`
37+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32`
38+
--> $DIR/generic-elements.rs:61:9
39+
|
40+
LL | simd_shuffle::<_, _, f32x2>(x, x, IDX2);
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42+
43+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32`
3844
--> $DIR/generic-elements.rs:63:9
3945
|
40-
LL | simd_shuffle2::<_, f32x2>(x, x, IDX2);
41-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46+
LL | simd_shuffle::<_, _, f32x4>(x, x, IDX4);
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4248

43-
error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32`
49+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32`
4450
--> $DIR/generic-elements.rs:65:9
4551
|
46-
LL | simd_shuffle4::<_, f32x4>(x, x, IDX4);
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
52+
LL | simd_shuffle::<_, _, f32x8>(x, x, IDX8);
53+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4854

49-
error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32`
50-
--> $DIR/generic-elements.rs:67:9
55+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 2, found `i32x8` with length 8
56+
--> $DIR/generic-elements.rs:68:9
5157
|
52-
LL | simd_shuffle8::<_, f32x8>(x, x, IDX8);
53-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
LL | simd_shuffle::<_, _, i32x8>(x, x, IDX2);
59+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5460

55-
error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected return type of length 2, found `i32x8` with length 8
61+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 4, found `i32x8` with length 8
5662
--> $DIR/generic-elements.rs:70:9
5763
|
58-
LL | simd_shuffle2::<_, i32x8>(x, x, IDX2);
59-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
64+
LL | simd_shuffle::<_, _, i32x8>(x, x, IDX4);
65+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6066

61-
error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return type of length 4, found `i32x8` with length 8
67+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 8, found `i32x2` with length 2
6268
--> $DIR/generic-elements.rs:72:9
6369
|
64-
LL | simd_shuffle4::<_, i32x8>(x, x, IDX4);
65-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66-
67-
error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected return type of length 8, found `i32x2` with length 2
68-
--> $DIR/generic-elements.rs:74:9
69-
|
70-
LL | simd_shuffle8::<_, i32x2>(x, x, IDX8);
71-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
70+
LL | simd_shuffle::<_, _, i32x2>(x, x, IDX8);
71+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7272

7373
error: aborting due to 12 previous errors
7474

‎tests/ui/simd/intrinsic/inlining-issue67557-ice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![feature(platform_intrinsics, repr_simd)]
77

88
extern "platform-intrinsic" {
9-
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
9+
fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U;
1010
}
1111

1212
#[repr(simd)]
@@ -22,5 +22,5 @@ fn main() {
2222
#[inline(always)]
2323
unsafe fn inline_me() -> Simd2 {
2424
const IDX: [u32; 2] = [0, 3];
25-
simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX)
25+
simd_shuffle(Simd2(10, 11), Simd2(12, 13), IDX)
2626
}

‎tests/ui/simd/intrinsic/inlining-issue67557.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![feature(platform_intrinsics, repr_simd)]
77

88
extern "platform-intrinsic" {
9-
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
9+
fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U;
1010
}
1111

1212
#[repr(simd)]
@@ -16,7 +16,7 @@ struct Simd2(u8, u8);
1616
fn main() {
1717
unsafe {
1818
const IDX: [u32; 2] = [0, 1];
19-
let p_res: Simd2 = simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX);
19+
let p_res: Simd2 = simd_shuffle(Simd2(10, 11), Simd2(12, 13), IDX);
2020
let a_res: Simd2 = inline_me();
2121

2222
assert_10_11(p_res);
@@ -38,5 +38,5 @@ fn assert_10_13(x: Simd2) {
3838
#[inline(always)]
3939
unsafe fn inline_me() -> Simd2 {
4040
const IDX: [u32; 2] = [0, 3];
41-
simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX)
41+
simd_shuffle(Simd2(10, 11), Simd2(12, 13), IDX)
4242
}

‎tests/ui/simd/shuffle-not-out-of-bounds.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ struct u8x32([u8; 32]);
2929
struct u8x64([u8; 64]);
3030

3131
extern "platform-intrinsic" {
32-
pub fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
33-
pub fn simd_shuffle4<T, U>(x: T, y: T, idx: [u32; 4]) -> U;
34-
pub fn simd_shuffle8<T, U>(x: T, y: T, idx: [u32; 8]) -> U;
35-
pub fn simd_shuffle16<T, U>(x: T, y: T, idx: [u32; 16]) -> U;
36-
pub fn simd_shuffle32<T, U>(x: T, y: T, idx: [u32; 32]) -> U;
37-
pub fn simd_shuffle64<T, U>(x: T, y: T, idx: [u32; 64]) -> U;
32+
pub fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U;
3833
}
3934

4035
// Test vectors by lane size. Since LLVM does not distinguish between a shuffle
@@ -58,22 +53,22 @@ macro_rules! test_shuffle_lanes {
5853
}
5954
}
6055
}
61-
//~^^^^^ ERROR: invalid monomorphization of `simd_shuffle2` intrinsic
62-
//~| ERROR: invalid monomorphization of `simd_shuffle4` intrinsic
63-
//~| ERROR: invalid monomorphization of `simd_shuffle8` intrinsic
64-
//~| ERROR: invalid monomorphization of `simd_shuffle16` intrinsic
65-
//~| ERROR: invalid monomorphization of `simd_shuffle32` intrinsic
66-
//~| ERROR: invalid monomorphization of `simd_shuffle64` intrinsic
56+
//~^^^^^ ERROR: invalid monomorphization of `simd_shuffle` intrinsic
57+
//~| ERROR: invalid monomorphization of `simd_shuffle` intrinsic
58+
//~| ERROR: invalid monomorphization of `simd_shuffle` intrinsic
59+
//~| ERROR: invalid monomorphization of `simd_shuffle` intrinsic
60+
//~| ERROR: invalid monomorphization of `simd_shuffle` intrinsic
61+
//~| ERROR: invalid monomorphization of `simd_shuffle` intrinsic
6762
// Because the test is mostly embedded in a macro, all the errors have the same origin point.
6863
// And unfortunately, standard comments, as in the UI test harness, disappear in macros!
6964

7065
fn main() {
71-
test_shuffle_lanes!(2, u8x2, simd_shuffle2);
72-
test_shuffle_lanes!(4, u8x4, simd_shuffle4);
73-
test_shuffle_lanes!(8, u8x8, simd_shuffle8);
74-
test_shuffle_lanes!(16, u8x16, simd_shuffle16);
75-
test_shuffle_lanes!(32, u8x32, simd_shuffle32);
76-
test_shuffle_lanes!(64, u8x64, simd_shuffle64);
66+
test_shuffle_lanes!(2, u8x2, simd_shuffle);
67+
test_shuffle_lanes!(4, u8x4, simd_shuffle);
68+
test_shuffle_lanes!(8, u8x8, simd_shuffle);
69+
test_shuffle_lanes!(16, u8x16, simd_shuffle);
70+
test_shuffle_lanes!(32, u8x32, simd_shuffle);
71+
test_shuffle_lanes!(64, u8x64, simd_shuffle);
7772

7873
extern "platform-intrinsic" {
7974
fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U;

‎tests/ui/simd/shuffle-not-out-of-bounds.stderr

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: shuffle index #0 is out of bounds (limit 4)
2-
--> $DIR/shuffle-not-out-of-bounds.rs:56:21
1+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 4)
2+
--> $DIR/shuffle-not-out-of-bounds.rs:51:21
33
|
44
LL | $y(vec1, vec2, ARR)
55
| ^^^^^^^^^^^^^^^^^^^
66
...
7-
LL | test_shuffle_lanes!(2, u8x2, simd_shuffle2);
8-
| ------------------------------------------- in this macro invocation
7+
LL | test_shuffle_lanes!(2, u8x2, simd_shuffle);
8+
| ------------------------------------------ in this macro invocation
99
|
1010
= note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
1111

12-
error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: shuffle index #0 is out of bounds (limit 8)
13-
--> $DIR/shuffle-not-out-of-bounds.rs:56:21
12+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 8)
13+
--> $DIR/shuffle-not-out-of-bounds.rs:51:21
1414
|
1515
LL | $y(vec1, vec2, ARR)
1616
| ^^^^^^^^^^^^^^^^^^^
1717
...
18-
LL | test_shuffle_lanes!(4, u8x4, simd_shuffle4);
19-
| ------------------------------------------- in this macro invocation
18+
LL | test_shuffle_lanes!(4, u8x4, simd_shuffle);
19+
| ------------------------------------------ in this macro invocation
2020
|
2121
= note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
2222

23-
error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: shuffle index #0 is out of bounds (limit 16)
24-
--> $DIR/shuffle-not-out-of-bounds.rs:56:21
23+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 16)
24+
--> $DIR/shuffle-not-out-of-bounds.rs:51:21
2525
|
2626
LL | $y(vec1, vec2, ARR)
2727
| ^^^^^^^^^^^^^^^^^^^
2828
...
29-
LL | test_shuffle_lanes!(8, u8x8, simd_shuffle8);
30-
| ------------------------------------------- in this macro invocation
29+
LL | test_shuffle_lanes!(8, u8x8, simd_shuffle);
30+
| ------------------------------------------ in this macro invocation
3131
|
3232
= note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
3333

34-
error[E0511]: invalid monomorphization of `simd_shuffle16` intrinsic: shuffle index #0 is out of bounds (limit 32)
35-
--> $DIR/shuffle-not-out-of-bounds.rs:56:21
34+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 32)
35+
--> $DIR/shuffle-not-out-of-bounds.rs:51:21
3636
|
3737
LL | $y(vec1, vec2, ARR)
3838
| ^^^^^^^^^^^^^^^^^^^
3939
...
40-
LL | test_shuffle_lanes!(16, u8x16, simd_shuffle16);
41-
| ---------------------------------------------- in this macro invocation
40+
LL | test_shuffle_lanes!(16, u8x16, simd_shuffle);
41+
| -------------------------------------------- in this macro invocation
4242
|
4343
= note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
4444

45-
error[E0511]: invalid monomorphization of `simd_shuffle32` intrinsic: shuffle index #0 is out of bounds (limit 64)
46-
--> $DIR/shuffle-not-out-of-bounds.rs:56:21
45+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 64)
46+
--> $DIR/shuffle-not-out-of-bounds.rs:51:21
4747
|
4848
LL | $y(vec1, vec2, ARR)
4949
| ^^^^^^^^^^^^^^^^^^^
5050
...
51-
LL | test_shuffle_lanes!(32, u8x32, simd_shuffle32);
52-
| ---------------------------------------------- in this macro invocation
51+
LL | test_shuffle_lanes!(32, u8x32, simd_shuffle);
52+
| -------------------------------------------- in this macro invocation
5353
|
5454
= note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
5555

56-
error[E0511]: invalid monomorphization of `simd_shuffle64` intrinsic: shuffle index #0 is out of bounds (limit 128)
57-
--> $DIR/shuffle-not-out-of-bounds.rs:56:21
56+
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 128)
57+
--> $DIR/shuffle-not-out-of-bounds.rs:51:21
5858
|
5959
LL | $y(vec1, vec2, ARR)
6060
| ^^^^^^^^^^^^^^^^^^^
6161
...
62-
LL | test_shuffle_lanes!(64, u8x64, simd_shuffle64);
63-
| ---------------------------------------------- in this macro invocation
62+
LL | test_shuffle_lanes!(64, u8x64, simd_shuffle);
63+
| -------------------------------------------- in this macro invocation
6464
|
6565
= note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
6666

6767
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 4)
68-
--> $DIR/shuffle-not-out-of-bounds.rs:84:23
68+
--> $DIR/shuffle-not-out-of-bounds.rs:79:23
6969
|
7070
LL | let _: u8x2 = simd_shuffle(v, v, I);
7171
| ^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/simd/shuffle.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88

99
extern "platform-intrinsic" {
1010
fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U;
11-
fn simd_shuffle16<T, U>(x: T, y: T, idx: [u32; 16]) -> U;
1211
}
1312

1413
#[derive(Copy, Clone)]
1514
#[repr(simd)]
1615
struct Simd<T, const N: usize>([T; N]);
1716

1817
pub unsafe fn __shuffle_vector16<const IDX: [u32; 16], T, U>(x: T, y: T) -> U {
19-
simd_shuffle16(x, y, IDX)
18+
simd_shuffle(x, y, IDX)
2019
}
2120

2221
fn main() {

1 commit comments

Comments
 (1)

KonradHoeffner commented on Aug 7, 2023

@KonradHoeffner
Contributor

This breaks the packed_simd2 crate, see rust-lang/packed_simd#356.
If anyone who uses packed_simd2 reads this, you need to change your packed_simd2 dependency to packed_simd (without the 2) version 0.3.9 and onwards.

Please sign in to comment.