File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
branches/stable/src/libcore/num Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -29,5 +29,5 @@ refs/heads/tmp: 378a370ff2057afeb1eae86eb6e78c476866a4a6
29
29
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
30
30
refs/tags/homu-tmp: a5286998df566e736b32f6795bfc3803bdaf453d
31
31
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32
- refs/heads/stable: 8f991d1fc27a176254ebfe99ed7e5a339cb9c7e2
32
+ refs/heads/stable: 36dccec2f39c7e1da7f056ea421ad5256df3fb0b
33
33
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
Original file line number Diff line number Diff line change @@ -745,7 +745,20 @@ macro_rules! uint_impl {
745
745
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
746
746
#[ inline]
747
747
pub fn trailing_zeros( self ) -> u32 {
748
- unsafe { $cttz( self as $ActualT) as u32 }
748
+ // As of LLVM 3.6 the codegen for the zero-safe cttz8 intrinsic
749
+ // emits two conditional moves on x86_64. By promoting the value to
750
+ // u16 and setting bit 8, we get better code without any conditional
751
+ // operations.
752
+ // FIXME: There's a LLVM patch (http://reviews.llvm.org/D9284)
753
+ // pending, remove this workaround once LLVM generates better code
754
+ // for cttz8.
755
+ unsafe {
756
+ if $BITS == 8 {
757
+ intrinsics:: cttz16( self as u16 | 0x100 ) as u32
758
+ } else {
759
+ $cttz( self as $ActualT) as u32
760
+ }
761
+ }
749
762
}
750
763
751
764
/// Shifts the bits to the left by a specified amount, `n`,
You can’t perform that action at this time.
0 commit comments