about summary refs log tree commit diff
path: root/tests/ui/simd/issue-105439.rs
blob: 1d57eff341c01a26e8cdd4e243970b4a4cef5ecd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//@ run-pass
//@ compile-flags: -O -Zverify-llvm-ir

#![feature(repr_simd, core_intrinsics)]

#[allow(non_camel_case_types)]
#[derive(Clone, Copy)]
#[repr(simd)]
struct i32x4([i32; 4]);

#[inline(always)]
fn to_array(a: i32x4) -> [i32; 4] {
    // 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) }
}

fn main() {
    let a = i32x4([1, 2, 3, 4]);
    let b = unsafe { std::intrinsics::simd::simd_add(a, a) };
    assert_eq!(to_array(b), [2, 4, 6, 8]);
}