summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit246a3dfb1026cea2abcc1d197ef88bcf962907ab (patch)
tree3daa7263b90af31e7c96af0ea850b8d707444464 /llvm/lib/Transforms
parentb732397343abc6c17bfac35dbf85b57faff436b7 (diff)
downloadbcm5719-llvm-246a3dfb1026cea2abcc1d197ef88bcf962907ab.tar.gz
bcm5719-llvm-246a3dfb1026cea2abcc1d197ef88bcf962907ab.zip
Handle overflow of 64-bit loop conditions.
llvm-svn: 71008
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 4365adc629f..23f75630b76 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/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.
OpenPOWER on IntegriCloud