diff options
author | David Greene <greened@obbligato.org> | 2009-05-06 17:39:26 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2009-05-06 17:39:26 +0000 |
commit | e19c840d6c6fe075b61a21a0f6abe338afba666d (patch) | |
tree | 77b1c8567c919909c4a5d556ab350c1f088c5628 /lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
parent | e9d87f49063cb1bd213d8e9c339b9b63393cc2d9 (diff) |
Make sure to use signed arithmetic in APInt to fix a regression.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71090 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-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 e2cbbc2d27..9e6f2b02bc 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, true); + Mul = Mul * APInt(BitWidth*2, Scale, true); // Check for overflow. - if (Mul.getSExtValue() != NewCmpVal) + if (!Mul.isSignedIntN(BitWidth)) { continue; // Watch out for overflow. |