diff options
author | Andrew Trick <atrick@apple.com> | 2012-05-30 03:35:20 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-05-30 03:35:20 +0000 |
commit | fe3516f9a5f238ecf6872b5315706c7c7942a496 (patch) | |
tree | 5a671bdb757ae2a22b56e0a563c2b21a8bab94e8 /lib/Analysis/ScalarEvolution.cpp | |
parent | 97178aedb5f337ad9a6ac86fa052e777c7ad50d0 (diff) |
SCEV: Handle a corner case reducing AddRecExpr * AddRecExpr
If integer overflow causes one of the terms to reach zero, that can
force the entire expression to zero.
Fixes PR12929: cast<Ty>() argument of incompatible type
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157673 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 59f441e700..8781441fd4 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -2088,9 +2088,12 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops, const SCEV *NewAddRec = getAddRecExpr(AddRecOps, AddRec->getLoop(), SCEV::FlagAnyWrap); if (Ops.size() == 2) return NewAddRec; - Ops[Idx] = AddRec = cast<SCEVAddRecExpr>(NewAddRec); + Ops[Idx] = NewAddRec; Ops.erase(Ops.begin() + OtherIdx); --OtherIdx; OpsModified = true; + AddRec = dyn_cast<SCEVAddRecExpr>(NewAddRec); + if (!AddRec) + break; } } if (OpsModified) |