Skip to content

Commit a777754

Browse files
authored
Rollup merge of rust-lang#56855 - nikic:remove-cttz-hack, r=nagisa
Remove u8 cttz hack This issue has since been fixed in LLVM: llvm-mirror/llvm@1886c8e 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 rust-lang#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
2 parents 8662946 + c0ed771 commit a777754

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

src/libcore/num/mod.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -2150,19 +2150,6 @@ impl isize {
21502150
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" }
21512151
}
21522152

2153-
// Emits the correct `cttz` call, depending on the size of the type.
2154-
macro_rules! uint_cttz_call {
2155-
// As of LLVM 3.6 the codegen for the zero-safe cttz8 intrinsic
2156-
// emits two conditional moves on x86_64. By promoting the value to
2157-
// u16 and setting bit 8, we get better code without any conditional
2158-
// operations.
2159-
// FIXME: There's a LLVM patch (http://reviews.llvm.org/D9284)
2160-
// pending, remove this workaround once LLVM generates better code
2161-
// for cttz8.
2162-
($value:expr, 8) => { intrinsics::cttz($value as u16 | 0x100) };
2163-
($value:expr, $_BITS:expr) => { intrinsics::cttz($value) }
2164-
}
2165-
21662153
// `Int` + `UnsignedInt` implemented for unsigned integers
21672154
macro_rules! uint_impl {
21682155
($SelfT:ty, $ActualT:ty, $BITS:expr, $MaxV:expr, $Feature:expr, $EndFeature:expr,
@@ -2306,7 +2293,7 @@ assert_eq!(n.trailing_zeros(), 3);", $EndFeature, "
23062293
#[rustc_const_unstable(feature = "const_int_ops")]
23072294
#[inline]
23082295
pub const fn trailing_zeros(self) -> u32 {
2309-
unsafe { uint_cttz_call!(self, $BITS) as u32 }
2296+
unsafe { intrinsics::cttz(self) as u32 }
23102297
}
23112298
}
23122299

0 commit comments

Comments
 (0)