Skip to content

Commit 203b2da

Browse files
tests: Copy dont-shuffle-bswaps per tested opt level
1 parent f315e61 commit 203b2da

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
}

tests/codegen/dont-shuffle-bswaps.rs renamed to tests/codegen/autovec/dont-shuffle-bswaps-opt3.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
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

0 commit comments

Comments
 (0)