From 26fa5c2c300f3c3a3ee3109c009bd4a6803a2a4c Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 11 Jun 2024 10:13:07 +0200 Subject: [PATCH] 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. --- tests/codegen/issues/issue-122805.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/codegen/issues/issue-122805.rs b/tests/codegen/issues/issue-122805.rs index 6d108ada6dd..8e03c6c8884 100644 --- a/tests/codegen/issues/issue-122805.rs +++ b/tests/codegen/issues/issue-122805.rs @@ -39,17 +39,20 @@ // OPT3WINX64-NEXT: store <8 x i16> // CHECK-NEXT: ret void #[no_mangle] -#[cfg(target_endian = "little")] pub fn convert(value: [u16; 8]) -> [u8; 16] { + #[cfg(target_endian = "little")] + let bswap = u16::to_be; + #[cfg(target_endian = "big")] + let bswap = u16::to_le; let addr16 = [ - value[0].to_be(), - value[1].to_be(), - value[2].to_be(), - value[3].to_be(), - value[4].to_be(), - value[5].to_be(), - value[6].to_be(), - value[7].to_be(), + bswap(value[0]), + bswap(value[1]), + bswap(value[2]), + bswap(value[3]), + bswap(value[4]), + bswap(value[5]), + bswap(value[6]), + bswap(value[7]), ]; unsafe { core::mem::transmute::<_, [u8; 16]>(addr16) } } -- 2.40.0