Skip to content

Commit cbd61f9

Browse files
authored
Unrolled build for #142176
Rollup merge of #142176 - workingjubilee:dont-shuffle-bswaps-per-arch, r=nikic tests: Split dont-shuffle-bswaps along opt-levels and arches This duplicates dont-shuffle-bswaps in order to make each opt level its own test. Then -opt3.rs gets split into a revision per arch we want to test, with certain architectures gaining new target-cpu minimums.
2 parents 0d6ab20 + 6b0deb2 commit cbd61f9

File tree

2 files changed

+45
-16
lines changed

2 files changed

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

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
//@ revisions: OPT2 OPT3 OPT3_S390X
2-
//@[OPT2] compile-flags: -Copt-level=2
3-
//@[OPT3] compile-flags: -C opt-level=3
4-
// some targets don't do the opt we are looking for
5-
//@[OPT3] only-64bit
6-
//@[OPT3] ignore-s390x
7-
//@[OPT3_S390X] compile-flags: -C opt-level=3 -C target-cpu=z13
8-
//@[OPT3_S390X] only-s390x
1+
//@ revisions: AARCH64 X86_64 Z13
2+
//@ compile-flags: -Copt-level=3
3+
//@[AARCH64] only-aarch64
4+
//@[X86_64] only-x86_64
5+
//@[Z13] only-s390x
6+
//@[Z13] compile-flags: -Ctarget-cpu=z13
97

108
#![crate_type = "lib"]
119
#![no_std]
1210

11+
// This test is paired with the arch-neutral -opt2.rs test
12+
1313
// The code is from https://github.com/rust-lang/rust/issues/122805.
1414
// Ensure we do not generate the shufflevector instruction
1515
// to avoid complicating the code.
16+
1617
// CHECK-LABEL: define{{.*}}void @convert(
1718
// CHECK-NOT: shufflevector
19+
1820
// On higher opt levels, this should just be a bswap:
19-
// OPT3: load <8 x i16>
20-
// OPT3-NEXT: call <8 x i16> @llvm.bswap
21-
// OPT3-NEXT: store <8 x i16>
22-
// OPT3-NEXT: ret void
23-
// OPT3_S390X: load <8 x i16>
24-
// OPT3_S390X-NEXT: call <8 x i16> @llvm.bswap
25-
// OPT3_S390X-NEXT: store <8 x i16>
26-
// OPT3_S390X-NEXT: ret void
21+
// CHECK: load <8 x i16>
22+
// CHECK-NEXT: call <8 x i16> @llvm.bswap
23+
// CHECK-NEXT: store <8 x i16>
24+
// CHECK-NEXT: ret void
2725
#[no_mangle]
2826
pub fn convert(value: [u16; 8]) -> [u8; 16] {
2927
#[cfg(target_endian = "little")]

0 commit comments

Comments
 (0)