Skip to content

Commit

Permalink
CTFE SIMD: also test 1-element array
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Nov 18, 2021
1 parent 2f1a1f5 commit 0304e16
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/test/ui/consts/const-eval/simd/insert_extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

#[repr(simd)] struct i8x1(i8);
#[repr(simd)] struct u16x2(u16, u16);
// Make one of them an array type to ensure those also work.
// Make some of them array types to ensure those also work.
#[repr(simd)] struct i8x1_arr([i8; 1]);
#[repr(simd)] struct f32x4([f32; 4]);

extern "platform-intrinsic" {
Expand All @@ -26,6 +27,14 @@ fn main() {
assert_eq!(X0, 42);
assert_eq!(Y0, 42);
}
{
const U: i8x1_arr = i8x1_arr([13]);
const V: i8x1_arr = unsafe { simd_insert(U, 0_u32, 42_i8) };
const X0: i8 = V.0[0];
const Y0: i8 = unsafe { simd_extract(V, 0) };
assert_eq!(X0, 42);
assert_eq!(Y0, 42);
}
{
const U: u16x2 = u16x2(13, 14);
const V: u16x2 = unsafe { simd_insert(U, 1_u32, 42_u16) };
Expand Down

0 comments on commit 0304e16

Please sign in to comment.