summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2019-08-23 04:03:23 +0000
committerPhilip Reames <listmail@philipreames.com>2019-08-23 04:03:23 +0000
commit2a52583d670046f05053fcd7da978e060205b372 (patch)
tree86638babd3a5fa979a75121cae6d369bb9f1bc7f /llvm/lib/Transforms
parent85f7294e5af0cb7ea8e2d0469b96d0369627c48c (diff)
downloadbcm5719-llvm-2a52583d670046f05053fcd7da978e060205b372.tar.gz
bcm5719-llvm-2a52583d670046f05053fcd7da978e060205b372.zip
[IndVars] Fix a bug noticed by inspection
We were computing the loop exit value, but not ensuring the addrec belonged to the loop whose exit value we were computing. I couldn't actually trip this; the test case shows the basic setup which *might* trip this, but none of the variations I've tried actually do. llvm-svn: 369730
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/IndVarSimplify.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index bb524f7ad69..aa35fa11f67 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -644,7 +644,8 @@ bool IndVarSimplify::rewriteLoopExitValues(Loop *L, SCEVExpander &Rewriter) {
if (isa<SCEVCouldNotCompute>(ExitCount))
continue;
if (auto *AddRec = dyn_cast<SCEVAddRecExpr>(SE->getSCEV(Inst)))
- ExitValue = AddRec->evaluateAtIteration(ExitCount, *SE);
+ if (AddRec->getLoop() == L)
+ ExitValue = AddRec->evaluateAtIteration(ExitCount, *SE);
if (isa<SCEVCouldNotCompute>(ExitValue) ||
!SE->isLoopInvariant(ExitValue, L) ||
!isSafeToExpand(ExitValue, *SE))
OpenPOWER on IntegriCloud