@@ -812,27 +812,22 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
812
812
return I;
813
813
}
814
814
815
- // Compute the new bits that are at the top now plus sign bits.
816
- APInt HighBits (APInt::getHighBitsSet (
817
- BitWidth, std::min (SignBits + ShiftAmt - 1 , BitWidth)));
818
- Known.Zero .lshrInPlace (ShiftAmt);
819
- Known.One .lshrInPlace (ShiftAmt);
815
+ Known = KnownBits::ashr (
816
+ Known, KnownBits::makeConstant (APInt (BitWidth, ShiftAmt)),
817
+ ShiftAmt != 0 , I->isExact ());
820
818
821
819
// If the input sign bit is known to be zero, or if none of the top bits
822
820
// are demanded, turn this into an unsigned shift right.
823
821
assert (BitWidth > ShiftAmt && " Shift amount not saturated?" );
822
+ APInt HighBits (APInt::getHighBitsSet (
823
+ BitWidth, std::min (SignBits + ShiftAmt - 1 , BitWidth)));
824
824
if (Known.Zero [BitWidth-ShiftAmt-1 ] ||
825
825
!DemandedMask.intersects (HighBits)) {
826
826
BinaryOperator *LShr = BinaryOperator::CreateLShr (I->getOperand (0 ),
827
827
I->getOperand (1 ));
828
828
LShr->setIsExact (cast<BinaryOperator>(I)->isExact ());
829
829
LShr->takeName (I);
830
830
return InsertNewInstWith (LShr, I->getIterator ());
831
- } else if (Known.One [BitWidth-ShiftAmt-1 ]) { // New bits are known one.
832
- Known.One |= HighBits;
833
- // SignBits may be out-of-sync with Known.countMinSignBits(). Mask out
834
- // high bits of Known.Zero to avoid conflicts.
835
- Known.Zero &= ~HighBits;
836
831
}
837
832
} else {
838
833
llvm::computeKnownBits (I, Known, Depth, Q);
0 commit comments