about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2018-12-16 14:08:37 +0100
committerGitHub <noreply@github.com>2018-12-16 14:08:37 +0100
commita777754c4d3dc88ac5a0e9e4dd9e5847779206c3 (patch)
tree931f2f7d6f951e0c887efa41a8b67ba4a6ce8f74
parent8662946cee6e4b3ac6a9789c0da49340337e2794 (diff)
parentc0ed771382cafb03232a9b8e7e1c5ef83a98a836 (diff)
downloadrust-a777754c4d3dc88ac5a0e9e4dd9e5847779206c3.tar.gz
rust-a777754c4d3dc88ac5a0e9e4dd9e5847779206c3.zip
Rollup merge of #56855 - nikic:remove-cttz-hack, r=nagisa
Remove u8 cttz hack

This issue has since been fixed in LLVM: https://github.com/llvm-mirror/llvm/commit/1886c8e29a9992d73c5e6ba0d52eb98ee036ab5d

Furthermore this code doesn't actually work, because the 8 literal does not match the $BITS provided from the macro invocation, so effectively this was just dead code. Ref #43024.

What LLVM does is still not ideal for CPUs that only have bsf but not tzcnt, will create a patch for that later.

r? @nagisa
-rw-r--r--src/libcore/num/mod.rs15
1 files changed, 1 insertions, 14 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index fd74e713416..f1df1f2856e 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -2150,19 +2150,6 @@ impl isize {
          "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" }
 }
 
-// Emits the correct `cttz` call, depending on the size of the type.
-macro_rules! uint_cttz_call {
-    // As of LLVM 3.6 the codegen for the zero-safe cttz8 intrinsic
-    // emits two conditional moves on x86_64. By promoting the value to
-    // u16 and setting bit 8, we get better code without any conditional
-    // operations.
-    // FIXME: There's a LLVM patch (http://reviews.llvm.org/D9284)
-    // pending, remove this workaround once LLVM generates better code
-    // for cttz8.
-    ($value:expr, 8) => { intrinsics::cttz($value as u16 | 0x100) };
-    ($value:expr, $_BITS:expr) => { intrinsics::cttz($value) }
-}
-
 // `Int` + `UnsignedInt` implemented for unsigned integers
 macro_rules! uint_impl {
     ($SelfT:ty, $ActualT:ty, $BITS:expr, $MaxV:expr, $Feature:expr, $EndFeature:expr,
@@ -2306,7 +2293,7 @@ assert_eq!(n.trailing_zeros(), 3);", $EndFeature, "
             #[rustc_const_unstable(feature = "const_int_ops")]
             #[inline]
             pub const fn trailing_zeros(self) -> u32 {
-                unsafe { uint_cttz_call!(self, $BITS) as u32 }
+                unsafe { intrinsics::cttz(self) as u32 }
             }
         }