]> granicus.if.org Git - llvm/commitdiff
[SelectionDAG] Use getActiveBits() and countTrailingZeros() to avoid creating tempora...
authorCraig Topper <craig.topper@gmail.com>
Thu, 20 Apr 2017 04:23:43 +0000 (04:23 +0000)
committerCraig Topper <craig.topper@gmail.com>
Thu, 20 Apr 2017 04:23:43 +0000 (04:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300819 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/TargetLowering.cpp

index 24fd206a2d46980af0b0eb7bbc22d16be82f6ea6..8006b8045971ae1aa0d027d64a092b5d1f25e671 100644 (file)
@@ -839,7 +839,7 @@ bool TargetLowering::SimplifyDemandedBits(SDValue Op,
         SDValue InnerOp = InOp.getNode()->getOperand(0);
         EVT InnerVT = InnerOp.getValueType();
         unsigned InnerBits = InnerVT.getSizeInBits();
-        if (ShAmt < InnerBits && NewMask.lshr(InnerBits) == 0 &&
+        if (ShAmt < InnerBits && NewMask.getActiveBits() <= InnerBits &&
             isTypeDesirableForOp(ISD::SHL, InnerVT)) {
           EVT ShTy = getShiftAmountTy(InnerVT, DL);
           if (!APInt(BitWidth, ShAmt).isIntN(ShTy.getSizeInBits()))
@@ -865,9 +865,8 @@ bool TargetLowering::SimplifyDemandedBits(SDValue Op,
             ->getZExtValue();
           if (InnerShAmt < ShAmt &&
               InnerShAmt < InnerBits &&
-              NewMask.lshr(std::min(InnerBits - InnerShAmt + ShAmt,
-                                    BitWidth)) == 0 &&
-              NewMask.trunc(ShAmt) == 0) {
+              NewMask.getActiveBits() <= (InnerBits - InnerShAmt + ShAmt) &&
+              NewMask.countTrailingZeros() >= ShAmt) {
             SDValue NewSA =
               TLO.DAG.getConstant(ShAmt - InnerShAmt, dl,
                                   Op.getOperand(1).getValueType());