aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2009-05-06 17:39:26 +0000
committerDavid Greene <greened@obbligato.org>2009-05-06 17:39:26 +0000
commite19c840d6c6fe075b61a21a0f6abe338afba666d (patch)
tree77b1c8567c919909c4a5d556ab350c1f088c5628 /lib/Transforms/Scalar/LoopStrengthReduce.cpp
parente9d87f49063cb1bd213d8e9c339b9b63393cc2d9 (diff)
downloadexternal_llvm-e19c840d6c6fe075b61a21a0f6abe338afba666d.zip
external_llvm-e19c840d6c6fe075b61a21a0f6abe338afba666d.tar.gz
external_llvm-e19c840d6c6fe075b61a21a0f6abe338afba666d.tar.bz2
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.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index e2cbbc2..9e6f2b0 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.