From ffc69c752ed278a6f49d804c114e863a1b264650 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Sep 2017 11:29:53 +0200 Subject: [PATCH] [arm] fix aarch64 cls intrinsic --- library/stdarch/src/arm/v8.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/library/stdarch/src/arm/v8.rs b/library/stdarch/src/arm/v8.rs index 9a875bae2202..17972164d4d3 100644 --- a/library/stdarch/src/arm/v8.rs +++ b/library/stdarch/src/arm/v8.rs @@ -39,10 +39,9 @@ pub unsafe fn _rbit_u64(x: u64) -> u64 { /// When all bits of the operand are set it returns the size of the operand in /// bits. #[inline(always)] -// LLVM Bug (should be cls): https://bugs.llvm.org/show_bug.cgi?id=31802 -#[cfg_attr(test, assert_instr(clz))] +#[cfg_attr(test, assert_instr(cls))] pub unsafe fn _cls_u32(x: u32) -> u32 { - u32::leading_zeros(!x) as u32 + u32::leading_zeros(((((((x as i32) >> 31) as u32) ^ x) << 1) | 1)) as u32 } /// Counts the leading most significant bits set. @@ -50,8 +49,7 @@ pub unsafe fn _cls_u32(x: u32) -> u32 { /// When all bits of the operand are set it returns the size of the operand in /// bits. #[inline(always)] -// LLVM Bug (should be cls): https://bugs.llvm.org/show_bug.cgi?id=31802 -#[cfg_attr(test, assert_instr(clz))] +#[cfg_attr(test, assert_instr(cls))] pub unsafe fn _cls_u64(x: u64) -> u64 { - u64::leading_zeros(!x) as u64 + u64::leading_zeros(((((((x as i64) >> 63) as u64) ^ x) << 1) | 1)) as u64 }