From: Zhou Sheng Date: Fri, 6 Jun 2008 08:32:05 +0000 (+0000) Subject: As Chris suggested, handle the situation if ShAmt larger than BitWidth, X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=cc41940dff771c98321d601e04e60dc8c67b6e87;p=oota-llvm.git As Chris suggested, handle the situation if ShAmt larger than BitWidth, otherwise, opt might crash. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52041 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 05e12692f4c..67c40fe21c9 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -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 (BitWidth == ShiftAmt || RHSKnownZero[BitWidth-ShiftAmt-1] || + if (BitWidth <= ShiftAmt || RHSKnownZero[BitWidth-ShiftAmt-1] || (HighBits & ~DemandedMask) == HighBits) { // Perform the logical shift right. Value *NewVal = BinaryOperator::CreateLShr(