Skip to content

Commit 5906998

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

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ compile-flags: -Copt-level=2
2+
3+
#![crate_type = "lib"]
4+
#![no_std]
5+
6+
// The code is from https://github.com/rust-lang/rust/issues/122805.
7+
// Ensure we do not generate the shufflevector instruction
8+
// to avoid complicating the code.
9+
10+
// CHECK-LABEL: define{{.*}}void @convert(
11+
// CHECK-NOT: shufflevector
12+
#[no_mangle]
13+
pub fn convert(value: [u16; 8]) -> [u8; 16] {
14+
#[cfg(target_endian = "little")]
15+
let bswap = u16::to_be;
16+
#[cfg(target_endian = "big")]
17+
let bswap = u16::to_le;
18+
let addr16 = [
19+
bswap(value[0]),
20+
bswap(value[1]),
21+
bswap(value[2]),
22+
bswap(value[3]),
23+
bswap(value[4]),
24+
bswap(value[5]),
25+
bswap(value[6]),
26+
bswap(value[7]),
27+
];
28+
unsafe { core::mem::transmute::<_, [u8; 16]>(addr16) }
29+
}

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)