diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-02-15 16:07:18 -0800 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-02-19 12:03:40 -0800 |
| commit | 6f9cfd694d67ad24af6c7e2235a2da5d22918df0 (patch) | |
| tree | 476873c2bb132949bdfc0178229f4dfb753666c6 /tests/codegen/simd/project-to-simd-array-field.rs | |
| parent | 642a705f714eaa73875b9bc9e7848568efc4b890 (diff) | |
| download | rust-6f9cfd694d67ad24af6c7e2235a2da5d22918df0.tar.gz rust-6f9cfd694d67ad24af6c7e2235a2da5d22918df0.zip | |
Rework `OperandRef::extract_field` to stop calling `to_immediate_scalar` on things which are already immediates
That means it stops trying to truncate things that are already `i1`s.
Diffstat (limited to 'tests/codegen/simd/project-to-simd-array-field.rs')
| -rw-r--r-- | tests/codegen/simd/project-to-simd-array-field.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/codegen/simd/project-to-simd-array-field.rs b/tests/codegen/simd/project-to-simd-array-field.rs new file mode 100644 index 00000000000..29fab640633 --- /dev/null +++ b/tests/codegen/simd/project-to-simd-array-field.rs @@ -0,0 +1,31 @@ +//@compile-flags: -Copt-level=3 + +#![crate_type = "lib"] +#![feature(repr_simd, core_intrinsics)] + +#[allow(non_camel_case_types)] +#[derive(Clone, Copy)] +#[repr(simd)] +struct i32x4([i32; 4]); + +#[inline(always)] +fn to_array4(a: i32x4) -> [i32; 4] { + a.0 +} + +// CHECK-LABEL: simd_add_self_then_return_array( +// CHECK-SAME: ptr{{.+}}sret{{.+}}%[[RET:.+]], +// CHECK-SAME: ptr{{.+}}%a) +#[no_mangle] +pub fn simd_add_self_then_return_array(a: &i32x4) -> [i32; 4] { + // It would be nice to just ban `.0` into simd types, + // but until we do this has to keep working. + // See also <https://github.com/rust-lang/rust/issues/105439> + + // CHECK: %[[T1:.+]] = load <4 x i32>, ptr %a + // CHECK: %[[T2:.+]] = shl <4 x i32> %[[T1]], {{splat \(i32 1\)|<i32 1, i32 1, i32 1, i32 1>}} + // CHECK: store <4 x i32> %[[T2]], ptr %[[RET]] + let a = *a; + let b = unsafe { core::intrinsics::simd::simd_add(a, a) }; + to_array4(b) +} |
