2023-05-05 21:58:52 +00:00
|
|
|
//@ run-pass
|
|
|
|
//@ compile-flags: -O -Zverify-llvm-ir
|
2022-12-12 23:52:02 +00:00
|
|
|
|
|
|
|
#![feature(repr_simd)]
|
2024-02-23 17:36:24 +00:00
|
|
|
#![feature(intrinsics)]
|
2022-12-12 23:52:02 +00:00
|
|
|
|
|
|
|
#[allow(non_camel_case_types)]
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
#[repr(simd)]
|
2023-05-05 21:58:52 +00:00
|
|
|
struct i32x4([i32; 4]);
|
|
|
|
|
2024-02-23 17:36:24 +00:00
|
|
|
extern "rust-intrinsic" {
|
2023-05-05 21:58:52 +00:00
|
|
|
pub(crate) fn simd_add<T>(x: T, y: T) -> T;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
fn to_array(a: i32x4) -> [i32; 4] {
|
|
|
|
a.0
|
|
|
|
}
|
2022-12-12 23:52:02 +00:00
|
|
|
|
2023-05-05 21:58:52 +00:00
|
|
|
fn main() {
|
|
|
|
let a = i32x4([1, 2, 3, 4]);
|
|
|
|
let b = unsafe { simd_add(a, a) };
|
|
|
|
assert_eq!(to_array(b), [2, 4, 6, 8]);
|
2022-12-12 03:21:51 +00:00
|
|
|
}
|