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.
This commit is contained in:
parent
aec67e238d
commit
26fa5c2c30
@ -39,17 +39,20 @@
|
|||||||
// OPT3WINX64-NEXT: store <8 x i16>
|
// OPT3WINX64-NEXT: store <8 x i16>
|
||||||
// CHECK-NEXT: ret void
|
// CHECK-NEXT: ret void
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[cfg(target_endian = "little")]
|
|
||||||
pub fn convert(value: [u16; 8]) -> [u8; 16] {
|
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 = [
|
let addr16 = [
|
||||||
value[0].to_be(),
|
bswap(value[0]),
|
||||||
value[1].to_be(),
|
bswap(value[1]),
|
||||||
value[2].to_be(),
|
bswap(value[2]),
|
||||||
value[3].to_be(),
|
bswap(value[3]),
|
||||||
value[4].to_be(),
|
bswap(value[4]),
|
||||||
value[5].to_be(),
|
bswap(value[5]),
|
||||||
value[6].to_be(),
|
bswap(value[6]),
|
||||||
value[7].to_be(),
|
bswap(value[7]),
|
||||||
];
|
];
|
||||||
unsafe { core::mem::transmute::<_, [u8; 16]>(addr16) }
|
unsafe { core::mem::transmute::<_, [u8; 16]>(addr16) }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user