If BitWidth equals to ShtAmt, the RHSKnownZero[BitWidth-ShiftAmt-1] will

crash the opt. Just fix this.

Test case in llvm/test/Transforms/InstCombine/2008-06-05-ashr-crash.ll

llvm-svn: 52003
This commit is contained in:
Zhou Sheng 2008-06-05 14:23:44 +00:00
parent ebf00c0f65
commit eaa93efd52

View File

@ -1236,7 +1236,7 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, APInt DemandedMask,
// If the input sign bit is known to be zero, or if none of the top bits
// are demanded, turn this into an unsigned shift right.
if (RHSKnownZero[BitWidth-ShiftAmt-1] ||
if (BitWidth == ShiftAmt || RHSKnownZero[BitWidth-ShiftAmt-1] ||
(HighBits & ~DemandedMask) == HighBits) {
// Perform the logical shift right.
Value *NewVal = BinaryOperator::CreateLShr(