summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorMichael Kuperstein <mkuper@google.com>2017-07-12 19:53:55 +0000
committerMichael Kuperstein <mkuper@google.com>2017-07-12 19:53:55 +0000
commitfdb46b2fb4d28088c1bf87758a4ec1dc9662971b (patch)
tree2641dfe3305b419ffbc1289dcbc42c3e8b247db6 /llvm/lib/Transforms
parente171a913d62bdc8a5434d0d1915fabb6e907fc6a (diff)
downloadbcm5719-llvm-fdb46b2fb4d28088c1bf87758a4ec1dc9662971b.tar.gz
bcm5719-llvm-fdb46b2fb4d28088c1bf87758a4ec1dc9662971b.zip
[LV] Don't allow outside uses of IVs if the SCEV is predicated on loop conditions.
This fixes PR33706. Differential Revision: https://reviews.llvm.org/D35227 llvm-svn: 307837
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 193cc4d1378..eb82ee283d4 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5315,8 +5315,13 @@ void LoopVectorizationLegality::addInductionPhi(
// Both the PHI node itself, and the "post-increment" value feeding
// back into the PHI node may have external users.
- AllowedExit.insert(Phi);
- AllowedExit.insert(Phi->getIncomingValueForBlock(TheLoop->getLoopLatch()));
+ // We can allow those uses, except if the SCEVs we have for them rely
+ // on predicates that only hold within the loop, since allowing the exit
+ // currently means re-using this SCEV outside the loop.
+ if (PSE.getUnionPredicate().isAlwaysTrue()) {
+ AllowedExit.insert(Phi);
+ AllowedExit.insert(Phi->getIncomingValueForBlock(TheLoop->getLoopLatch()));
+ }
DEBUG(dbgs() << "LV: Found an induction variable.\n");
return;
OpenPOWER on IntegriCloud