forked from OSchip/llvm-project
avoid constructing out of range shift amounts.
llvm-svn: 22230
This commit is contained in:
parent
a2e8779b0d
commit
c53cb9d3ff
|
@ -2511,8 +2511,10 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) {
|
||||||
if (!CanFold) {
|
if (!CanFold) {
|
||||||
// To test for the bad case of the signed shr, see if any
|
// To test for the bad case of the signed shr, see if any
|
||||||
// of the bits shifted in could be tested after the mask.
|
// of the bits shifted in could be tested after the mask.
|
||||||
Constant *OShAmt = ConstantUInt::get(Type::UByteTy,
|
int ShAmtVal = Ty->getPrimitiveSizeInBits()-ShAmt->getValue();
|
||||||
Ty->getPrimitiveSizeInBits()-ShAmt->getValue());
|
if (ShAmtVal < 0) ShAmtVal = 0; // Out of range shift.
|
||||||
|
|
||||||
|
Constant *OShAmt = ConstantUInt::get(Type::UByteTy, ShAmtVal);
|
||||||
Constant *ShVal =
|
Constant *ShVal =
|
||||||
ConstantExpr::getShl(ConstantInt::getAllOnesValue(Ty), OShAmt);
|
ConstantExpr::getShl(ConstantInt::getAllOnesValue(Ty), OShAmt);
|
||||||
if (ConstantExpr::getAnd(ShVal, AndCST)->isNullValue())
|
if (ConstantExpr::getAnd(ShVal, AndCST)->isNullValue())
|
||||||
|
|
Loading…
Reference in New Issue