diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-03-01 19:07:31 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-03-01 19:07:31 +0000 |
commit | 5d79bb8770a5a655af0dccc87b952c3ea9bad45e (patch) | |
tree | 4cebc6854c070d85f1567d75ae9d8cedbfad2958 /lib | |
parent | 4c8e74f0b75cb10820c45c86399fbd02e4a8832a (diff) | |
download | external_llvm-5d79bb8770a5a655af0dccc87b952c3ea9bad45e.zip external_llvm-5d79bb8770a5a655af0dccc87b952c3ea9bad45e.tar.gz external_llvm-5d79bb8770a5a655af0dccc87b952c3ea9bad45e.tar.bz2 |
LoopVectorize: Don't hang forever if a PHI only has skipped PHI uses.
Fixes PR15384.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176366 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Vectorize/LoopVectorize.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index a696a2f..ef9c7c9 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -2724,6 +2724,9 @@ bool LoopVectorizationLegality::AddReductionVar(PHINode *Phi, // Is this a bin op ? FoundBinOp |= !isa<PHINode>(Iter); + // Remember the current instruction. + Instruction *OldIter = Iter; + // For each of the *users* of iter. for (Value::use_iterator it = Iter->use_begin(), e = Iter->use_end(); it != e; ++it) { @@ -2749,7 +2752,7 @@ bool LoopVectorizationLegality::AddReductionVar(PHINode *Phi, if (isa<PHINode>(Iter) && isa<PHINode>(U) && U->getParent() != TheLoop->getHeader() && TheLoop->contains(U) && - Iter->getNumUses() > 1) + Iter->hasNUsesOrMore(2)) continue; // We can't have multiple inside users. @@ -2769,6 +2772,10 @@ bool LoopVectorizationLegality::AddReductionVar(PHINode *Phi, Iter = U; } + // If all uses were skipped this can't be a reduction variable. + if (Iter == OldIter) + return false; + // We found a reduction var if we have reached the original // phi node and we only have a single instruction with out-of-loop // users. |