aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2009-05-05 20:22:36 +0000
committerDavid Greene <greened@obbligato.org>2009-05-05 20:22:36 +0000
commit58deef5559db65f742fc67adcdaba04ce83f0764 (patch)
tree96a70492ad59983bc77c40d53ba036f2d72fb8f1 /lib/Transforms
parent1777d0c6c555fb20177b3a60b40eef265c2b842a (diff)
Handle overflow of 64-bit loop conditions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71008 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 4365adc629..23f75630b7 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -2027,9 +2027,10 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond,
Scale = SSInt / CmpSSInt;
int64_t NewCmpVal = CmpVal * Scale;
- APInt Mul = APInt(BitWidth, NewCmpVal);
+ APInt Mul = APInt(BitWidth*2, CmpVal);
+ Mul = Mul * APInt(BitWidth*2, Scale);
// Check for overflow.
- if (Mul.getSExtValue() != NewCmpVal)
+ if (!Mul.isSignedIntN(BitWidth))
continue;
// Watch out for overflow.