2024-02-16 20:02:50 +00:00
|
|
|
//@ run-pass
|
|
|
|
|
//@ compile-flags: -O -Zverify-llvm-ir
|
2022-12-12 15:52:02 -08:00
|
|
|
|
2025-02-24 17:26:56 +01:00
|
|
|
#![feature(repr_simd, core_intrinsics)]
|
2022-12-12 15:52:02 -08:00
|
|
|
|
|
|
|
|
#[allow(non_camel_case_types)]
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
|
#[repr(simd)]
|
2023-05-05 14:58:52 -07:00
|
|
|
struct i32x4([i32; 4]);
|
|
|
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_array(a: i32x4) -> [i32; 4] {
|
2025-03-06 19:13:46 -08:00
|
|
|
// This was originally just `a.0`, but that ended up being annoying enough
|
|
|
|
|
// that it was banned by <https://github.com/rust-lang/compiler-team/issues/838>
|
|
|
|
|
unsafe { std::mem::transmute(a) }
|
2023-05-05 14:58:52 -07:00
|
|
|
}
|
2022-12-12 15:52:02 -08:00
|
|
|
|
2023-05-05 14:58:52 -07:00
|
|
|
fn main() {
|
|
|
|
|
let a = i32x4([1, 2, 3, 4]);
|
2025-02-24 17:26:56 +01:00
|
|
|
let b = unsafe { std::intrinsics::simd::simd_add(a, a) };
|
2023-05-05 14:58:52 -07:00
|
|
|
assert_eq!(to_array(b), [2, 4, 6, 8]);
|
2022-12-11 19:21:51 -08:00
|
|
|
}
|