diff options
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/LoopStrengthReduce.cpp | 5 |
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. |