[llvm] r233736 - [SystemZ] Address review comments for r233689
Ulrich Weigand
ulrich.weigand at de.ibm.com
Tue Mar 31 12:28:51 PDT 2015
Author: uweigand
Date: Tue Mar 31 14:28:50 2015
New Revision: 233736
URL: http://llvm.org/viewvc/llvm-project?rev=233736&view=rev
Log:
[SystemZ] Address review comments for r233689
Change lowerCTPOP to:
- Gracefully handle a known-zero input value
- Simplify computation of significant bit size
Thanks to Jay Foad for the review!
Modified:
llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=233736&r1=233735&r2=233736&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Tue Mar 31 14:28:50 2015
@@ -2319,12 +2319,13 @@ SDValue SystemZTargetLowering::lowerCTPO
Op = Op.getOperand(0);
APInt KnownZero, KnownOne;
DAG.computeKnownBits(Op, KnownZero, KnownOne);
- uint64_t Mask = ~KnownZero.getZExtValue();
+ unsigned NumSignificantBits = (~KnownZero).getActiveBits();
+ if (NumSignificantBits == 0)
+ return DAG.getConstant(0, VT);
// Skip known-zero high parts of the operand.
- int64_t BitSize = OrigBitSize;
- while ((Mask & ((((uint64_t)1 << (BitSize / 2)) - 1) << (BitSize / 2))) == 0)
- BitSize = BitSize / 2;
+ int64_t BitSize = (int64_t)1 << Log2_32_Ceil(NumSignificantBits);
+ BitSize = std::min(BitSize, OrigBitSize);
// The POPCNT instruction counts the number of bits in each byte.
Op = DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, Op);
More information about the llvm-commits
mailing list