Attempt to workaround MIPS bug

This commit is contained in:
Caleb Zulawski 2021-04-29 03:34:28 +00:00 committed by Jubilee Young
parent 98dad13526
commit 589fce0313
2 changed files with 14 additions and 3 deletions

View File

@ -112,7 +112,18 @@ pub fn to_bitmask<U: crate::Mask>(self) -> U::BitMask {
// TODO remove the transmute when rustc is more flexible
assert_eq!(core::mem::size_of::<U::IntBitMask>(), core::mem::size_of::<U::BitMask>());
let mask: U::IntBitMask = crate::intrinsics::simd_bitmask(self.0);
core::mem::transmute_copy(&mask)
let mut bitmask: U::BitMask = core::mem::transmute_copy(&mask);
// There is a bug where LLVM appears to implement this operation with the wrong
// bit order.
// TODO fix this in a better way
if cfg!(any(target_arch = "mips", target_arch = "mips64")) {
for x in bitmask.as_mut() {
*x = x.reverse_bits();
}
}
bitmask
}
}
}

View File

@ -70,10 +70,10 @@ fn roundtrip_int_conversion() {
fn to_bitmask() {
let values = [
true, false, false, true, false, false, true, false,
false, false, false, false, false, false, false, false,
true, true, false, false, false, false, false, true,
];
let mask = core_simd::$name::<16>::from_array(values);
assert_eq!(mask.to_bitmask(), [0b01001001, 0]);
assert_eq!(mask.to_bitmask(), [0b01001001, 0b10000011]);
}
}
}