forked from OSchip/llvm-project
Make sure to use signed arithmetic in APInt to fix a regression.
llvm-svn: 71090
This commit is contained in:
parent
9a6fef0a52
commit
0dec5b9a75
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue