File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 1+ //@ revisions: OPT2
2+ //@[OPT2] compile-flags: -Copt-level=2
3+
4+ #![ crate_type = "lib" ]
5+ #![ no_std]
6+
7+ // The code is from https://github.com/rust-lang/rust/issues/122805.
8+ // Ensure we do not generate the shufflevector instruction
9+ // to avoid complicating the code.
10+
11+ // CHECK-LABEL: define{{.*}}void @convert(
12+ // CHECK-NOT: shufflevector
13+ #[ no_mangle]
14+ pub fn convert ( value : [ u16 ; 8 ] ) -> [ u8 ; 16 ] {
15+ #[ cfg( target_endian = "little" ) ]
16+ let bswap = u16:: to_be;
17+ #[ cfg( target_endian = "big" ) ]
18+ let bswap = u16:: to_le;
19+ let addr16 = [
20+ bswap ( value[ 0 ] ) ,
21+ bswap ( value[ 1 ] ) ,
22+ bswap ( value[ 2 ] ) ,
23+ bswap ( value[ 3 ] ) ,
24+ bswap ( value[ 4 ] ) ,
25+ bswap ( value[ 5 ] ) ,
26+ bswap ( value[ 6 ] ) ,
27+ bswap ( value[ 7 ] ) ,
28+ ] ;
29+ unsafe { core:: mem:: transmute :: < _ , [ u8 ; 16 ] > ( addr16) }
30+ }
Original file line number Diff line number Diff line change 1- //@ revisions: OPT2 OPT3 OPT3_S390X
2- //@[OPT2] compile-flags: -Copt-level=2
1+ //@ revisions: OPT3 OPT3_S390X
32//@[OPT3] compile-flags: -C opt-level=3
43// some targets don't do the opt we are looking for
54//@[OPT3] only-64bit
You can’t perform that action at this time.
0 commit comments