File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ //@ add-minicore
2+ //@ revisions: X86 AARCH64 RISCV
3+ //@ [X86] compile-flags: -Copt-level=3 --target=x86_64-unknown-linux-gnu
4+ //@ [X86] needs-llvm-components: x86
5+ //@ [AARCH64] compile-flags: -Copt-level=3 --target=aarch64-unknown-linux-gnu
6+ //@ [AARCH64] needs-llvm-components: aarch64
7+ //@ [RISCV] compile-flags: --target riscv64gc-unknown-none-elf
8+ //@ [RISCV] needs-llvm-components: riscv
9+ #![ crate_type = "lib" ]
10+ #![ feature( repr_simd) ]
11+ #![ feature( no_core) ]
12+ #![ no_std]
13+ #![ no_core]
14+ extern crate minicore;
15+ use minicore:: * ;
16+
17+ #[ repr( simd) ]
18+ pub struct Simd < T , const N : usize > ( pub [ T ; N ] ) ;
19+
20+ pub type u8x16 = Simd < u8 , 16 > ;
21+
22+ // Regression test for https://github.com/rust-lang/rust/issues/97804.
23+
24+ #[ unsafe( no_mangle) ]
25+ fn foo ( v : u16 , p : & mut [ u8 ; 16 ] ) {
26+ // An array repeat transmuted into a SIMD type should emit a canonical LLVM splat sequence:
27+ //
28+ // CHECK-LABEL: foo
29+ // CHECK: start
30+ // CHECK-NEXT: %0 = insertelement <8 x i16> poison, i16 %v, i64 0
31+ // CHECK-NEXT: %1 = shufflevector <8 x i16> %0, <8 x i16> poison, <8 x i32> zeroinitializer
32+ // CHECK-NEXT: store <8 x i16> %1, ptr %p, align 1
33+ // CHECK-NEXT: ret void
34+ unsafe {
35+ let v: u8x16 = mem:: transmute ( [ v; 8 ] ) ;
36+ * p = mem:: transmute ( v) ;
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments