Skip to content

Commit 697a38b

Browse files
committed
Add test cases which exercise the fix.
1 parent a5bc786 commit 697a38b

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// This used to cause an ICE for an internal index out of range due to simd_shuffle_indices being
2+
// passed the wrong Instance, causing issues with inlining. See #67557.
3+
//
4+
// run-pass
5+
// compile-flags: -Zmir-opt-level=3
6+
#![feature(platform_intrinsics, repr_simd)]
7+
8+
extern "platform-intrinsic" {
9+
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
10+
}
11+
12+
#[repr(simd)]
13+
#[derive(Debug, PartialEq)]
14+
struct Simd2(u8, u8);
15+
16+
fn main() {
17+
unsafe {
18+
let _: Simd2 = inline_me();
19+
}
20+
}
21+
22+
#[inline(always)]
23+
unsafe fn inline_me() -> Simd2 {
24+
simd_shuffle2(Simd2(10, 11), Simd2(12, 13), [0, 3])
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// This used to cause assert_10_13 to unexpectingly fail, due to simd_shuffle_indices being passed
2+
// the wrong Instance, causing issues with inlining. See #67557.
3+
//
4+
// run-pass
5+
// compile-flags: -Zmir-opt-level=3
6+
#![feature(platform_intrinsics, repr_simd)]
7+
8+
extern "platform-intrinsic" {
9+
fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
10+
}
11+
12+
#[repr(simd)]
13+
#[derive(Debug, PartialEq)]
14+
struct Simd2(u8, u8);
15+
16+
fn main() {
17+
unsafe {
18+
let p_res: Simd2 = simd_shuffle2(Simd2(10, 11), Simd2(12, 13), [0, 1]);
19+
let a_res: Simd2 = inline_me();
20+
21+
assert_10_11(p_res);
22+
assert_10_13(a_res);
23+
}
24+
}
25+
26+
#[inline(never)]
27+
fn assert_10_11(x: Simd2) {
28+
assert_eq!(x, Simd2(10, 11));
29+
}
30+
31+
#[inline(never)]
32+
fn assert_10_13(x: Simd2) {
33+
assert_eq!(x, Simd2(10, 13));
34+
}
35+
36+
37+
#[inline(always)]
38+
unsafe fn inline_me() -> Simd2 {
39+
simd_shuffle2(Simd2(10, 11), Simd2(12, 13), [0, 3])
40+
}

0 commit comments

Comments
 (0)