Skip to content

Commit 0dec5b9

Browse files
committed
Make sure to use signed arithmetic in APInt to fix a regression. llvm-svn: 71090
1 parent 9a6fef0 commit 0dec5b9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,9 +2027,10 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond,
20272027

20282028
Scale = SSInt / CmpSSInt;
20292029
int64_t NewCmpVal = CmpVal * Scale;
2030-
APInt Mul = APInt(BitWidth, NewCmpVal);
2030+
APInt Mul = APInt(BitWidth*2, CmpVal, true);
2031+
Mul = Mul * APInt(BitWidth*2, Scale, true);
20312032
// Check for overflow.
2032-
if (Mul.getSExtValue() != NewCmpVal)
2033+
if (!Mul.isSignedIntN(BitWidth)) {
20332034
continue;
20342035

20352036
// Watch out for overflow.

0 commit comments

Comments
 (0)