diff options
| author | David Greene <greened@obbligato.org> | 2009-05-05 20:22:36 +0000 |
|---|---|---|
| committer | David Greene <greened@obbligato.org> | 2009-05-05 20:22:36 +0000 |
| commit | 246a3dfb1026cea2abcc1d197ef88bcf962907ab (patch) | |
| tree | 3daa7263b90af31e7c96af0ea850b8d707444464 /llvm/lib/Transforms | |
| parent | b732397343abc6c17bfac35dbf85b57faff436b7 (diff) | |
| download | bcm5719-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.cpp | 5 |
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. |

