diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-04-18 14:29:13 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-04-18 14:29:13 +0000 |
commit | 8df2cfb858056f66c3f713383fe2b4de7c2e561d (patch) | |
tree | 49af11af860b054578f613f3cafe9b768b41e096 /llvm/lib/Transforms | |
parent | 7ee3b9c0e4bcfec216d87b8e1127f8dc8312b827 (diff) | |
download | bcm5719-llvm-8df2cfb858056f66c3f713383fe2b4de7c2e561d.tar.gz bcm5719-llvm-8df2cfb858056f66c3f713383fe2b4de7c2e561d.zip |
LoopVectorize: Use a set to avoid longer cycles in the reduction chain too.
Fixes PR15748.
llvm-svn: 179757
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 238fc8bfb70..f40964f813d 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -2733,7 +2733,10 @@ bool LoopVectorizationLegality::AddReductionVar(PHINode *Phi, // used as reduction variables (such as ADD). We may have a single // out-of-block user. The cycle must end with the original PHI. Instruction *Iter = Phi; - while (true) { + + // Avoid cycles in the chain. + SmallPtrSet<Instruction *, 8> VisitedInsts; + while (VisitedInsts.insert(Iter)) { // If the instruction has no users then this is a broken // chain and can't be a reduction variable. if (Iter->use_empty()) @@ -2747,9 +2750,6 @@ 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) { @@ -2795,10 +2795,6 @@ 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. @@ -2814,6 +2810,8 @@ bool LoopVectorizationLegality::AddReductionVar(PHINode *Phi, return FoundBinOp && ExitInstruction; } } + + return false; } bool |