[llvm] r176366 - LoopVectorize: Don't hang forever if a PHI only has skipped PHI uses.
Benjamin Kramer
benny.kra at googlemail.com
Fri Mar 1 11:07:31 PST 2013
Author: d0k
Date: Fri Mar 1 13:07:31 2013
New Revision: 176366
URL: http://llvm.org/viewvc/llvm-project?rev=176366&view=rev
Log:
LoopVectorize: Don't hang forever if a PHI only has skipped PHI uses.
Fixes PR15384.
Added:
llvm/trunk/test/Transforms/LoopVectorize/phi-hang.ll
Modified:
llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=176366&r1=176365&r2=176366&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Fri Mar 1 13:07:31 2013
@@ -2724,6 +2724,9 @@ bool LoopVectorizationLegality::AddReduc
// 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::AddReduc
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::AddReduc
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.
Added: llvm/trunk/test/Transforms/LoopVectorize/phi-hang.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVectorize/phi-hang.ll?rev=176366&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LoopVectorize/phi-hang.ll (added)
+++ llvm/trunk/test/Transforms/LoopVectorize/phi-hang.ll Fri Mar 1 13:07:31 2013
@@ -0,0 +1,29 @@
+; RUN: opt -S -loop-vectorize < %s
+
+; PR15384
+define void @test1(i32 %arg) {
+bb:
+ br label %bb1
+
+bb1: ; preds = %bb5, %bb
+ %tmp = phi i32 [ 1, %bb ], [ %tmp7, %bb5 ]
+ %tmp2 = phi i32 [ %arg, %bb ], [ %tmp9, %bb5 ]
+ br i1 true, label %bb5, label %bb3
+
+bb3: ; preds = %bb1
+ br label %bb4
+
+bb4: ; preds = %bb3
+ br label %bb5
+
+bb5: ; preds = %bb4, %bb1
+ %tmp6 = phi i32 [ 0, %bb4 ], [ %tmp, %bb1 ]
+ %tmp7 = phi i32 [ 0, %bb4 ], [ %tmp6, %bb1 ]
+ %tmp8 = phi i32 [ 0, %bb4 ], [ %tmp, %bb1 ]
+ %tmp9 = add nsw i32 %tmp2, 1
+ %tmp10 = icmp eq i32 %tmp9, 0
+ br i1 %tmp10, label %bb11, label %bb1
+
+bb11: ; preds = %bb5
+ ret void
+}
More information about the llvm-commits
mailing list