Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 612181d

Browse files
authoredJun 12, 2024
Unrolled build for rust-lang#126263
Rollup merge of rust-lang#126263 - nikic:s390x-codegen-test-fix, r=jieyouxu Make issue-122805.rs big endian compatible Instead of not generating the function at all on big endian (which makes the CHECK lines fail), instead use to_le() on big endian, so that we essentially perform a bswap for both endiannesses.
2 parents 02c7a59 + 26fa5c2 commit 612181d

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed
 

‎tests/codegen/issues/issue-122805.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,20 @@
3939
// OPT3WINX64-NEXT: store <8 x i16>
4040
// CHECK-NEXT: ret void
4141
#[no_mangle]
42-
#[cfg(target_endian = "little")]
4342
pub fn convert(value: [u16; 8]) -> [u8; 16] {
43+
#[cfg(target_endian = "little")]
44+
let bswap = u16::to_be;
45+
#[cfg(target_endian = "big")]
46+
let bswap = u16::to_le;
4447
let addr16 = [
45-
value[0].to_be(),
46-
value[1].to_be(),
47-
value[2].to_be(),
48-
value[3].to_be(),
49-
value[4].to_be(),
50-
value[5].to_be(),
51-
value[6].to_be(),
52-
value[7].to_be(),
48+
bswap(value[0]),
49+
bswap(value[1]),
50+
bswap(value[2]),
51+
bswap(value[3]),
52+
bswap(value[4]),
53+
bswap(value[5]),
54+
bswap(value[6]),
55+
bswap(value[7]),
5356
];
5457
unsafe { core::mem::transmute::<_, [u8; 16]>(addr16) }
5558
}

0 commit comments

Comments
 (0)
Failed to load comments.