Changes in directory llvm/lib/Target:
TargetLowering.cpp updated: 1.59 -> 1.60 --- Log message: Use ComputeMaskedBits to determine # sign bits as a fallback. This allows us to handle all kinds of stuff, including silly things like: sextinreg(setcc,i16) -> setcc. --- Diffs of the changes: (+23 -2) TargetLowering.cpp | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-) Index: llvm/lib/Target/TargetLowering.cpp diff -u llvm/lib/Target/TargetLowering.cpp:1.59 llvm/lib/Target/TargetLowering.cpp:1.60 --- llvm/lib/Target/TargetLowering.cpp:1.59 Sat May 6 18:40:29 2006 +++ llvm/lib/Target/TargetLowering.cpp Sat May 6 18:48:13 2006 @@ -1176,8 +1176,29 @@ if (NumBits > 1) return NumBits; } - // FIXME: Should use computemaskedbits to look at the top bits. - return 1; + // Finally, if we can prove that the top bits of the result are 0's or 1's, + // use this information. + uint64_t KnownZero, KnownOne; + uint64_t Mask = MVT::getIntVTBitMask(VT); + ComputeMaskedBits(Op, Mask, KnownZero, KnownOne, Depth); + + uint64_t SignBit = MVT::getIntVTSignBit(VT); + if (KnownZero & SignBit) { // SignBit is 0 + Mask = KnownZero; + } else if (KnownOne & SignBit) { // SignBit is 1; + Mask = KnownOne; + } else { + // Nothing known. + return 1; + } + + // Okay, we know that the sign bit in Mask is set. Use CLZ to determine + // the number of identical bits in the top of the input value. + Mask ^= ~0ULL; + Mask <<= 64-VTBits; + // Return # leading zeros. We use 'min' here in case Val was zero before + // shifting. We don't want to return '64' as for an i32 "0". + return std::min(VTBits, CountLeadingZeros_64(Mask)); } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits