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 | c53cb9d3ff5813763f2ef9ccaf957c4547c8046b (patch) | |
| tree | a0ba69fd4f89a14383942649efc300e8e3594e5f /llvm/lib | |
| parent | a2e8779b0d91006ed1699f46816ddd7f703457db (diff) | |
| download | bcm5719-llvm-c53cb9d3ff5813763f2ef9ccaf957c4547c8046b.tar.gz bcm5719-llvm-c53cb9d3ff5813763f2ef9ccaf957c4547c8046b.zip | |
avoid constructing out of range shift amounts.
llvm-svn: 22230
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 76f11a52b28..321b032505c 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/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()) |

