Handle overflow of 64-bit loop conditions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71008 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Greene
2009-05-05 20:22:36 +00:00
parent 1777d0c6c5
commit 58deef5559
2 changed files with 125 additions and 2 deletions

View File

@@ -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.