diff options
author | Chris Lattner <sabre@nondot.org> | 2005-06-17 01:29:28 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-06-17 01:29:28 +0000 |
commit | d7e31cfaaec586f13c74886f4fe67b4abcd2dd33 (patch) | |
tree | f8b80cacc60ae1b67a882def45fbac4586e3c75e /lib/Transforms | |
parent | 41aaf7016ebf205d8b02c857461f679a3e82f9d0 (diff) |
avoid constructing out of range shift amounts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22230 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 76f11a52b2..321b032505 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2511,8 +2511,10 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { if (!CanFold) { // To test for the bad case of the signed shr, see if any // of the bits shifted in could be tested after the mask. - Constant *OShAmt = ConstantUInt::get(Type::UByteTy, - Ty->getPrimitiveSizeInBits()-ShAmt->getValue()); + int ShAmtVal = Ty->getPrimitiveSizeInBits()-ShAmt->getValue(); + if (ShAmtVal < 0) ShAmtVal = 0; // Out of range shift. + + Constant *OShAmt = ConstantUInt::get(Type::UByteTy, ShAmtVal); Constant *ShVal = ConstantExpr::getShl(ConstantInt::getAllOnesValue(Ty), OShAmt); if (ConstantExpr::getAnd(ShVal, AndCST)->isNullValue()) |