Index: llvm/trunk/lib/IR/Verifier.cpp =================================================================== --- llvm/trunk/lib/IR/Verifier.cpp +++ llvm/trunk/lib/IR/Verifier.cpp @@ -3397,8 +3397,14 @@ return; } + // Quick check whether the def has already been encountered in the same block. + // PHI nodes are not checked to prevent accepting preceeding PHIs, because PHI + // uses are defined to happen on the incoming edge, not at the instruction. + if (!isa(I) && InstsInThisBlock.count(Op)) + return; + const Use &U = I.getOperandUse(i); - Assert(InstsInThisBlock.count(Op) || DT.dominates(Op, U), + Assert(DT.dominates(Op, U), "Instruction does not dominate all uses!", Op, &I); } Index: llvm/trunk/test/Transforms/LoopVectorize/phi-hang.ll =================================================================== --- llvm/trunk/test/Transforms/LoopVectorize/phi-hang.ll +++ llvm/trunk/test/Transforms/LoopVectorize/phi-hang.ll @@ -18,7 +18,7 @@ bb5: ; preds = %bb4, %bb1 %tmp6 = phi i32 [ 0, %bb4 ], [ %tmp, %bb1 ] - %tmp7 = phi i32 [ 0, %bb4 ], [ %tmp6, %bb1 ] + %tmp7 = phi i32 [ 0, %bb4 ], [ %tmp, %bb1 ] %tmp8 = phi i32 [ 0, %bb4 ], [ %tmp, %bb1 ] %tmp9 = add nsw i32 %tmp2, 1 %tmp10 = icmp eq i32 %tmp9, 0 Index: llvm/trunk/test/Verifier/dominates.ll =================================================================== --- llvm/trunk/test/Verifier/dominates.ll +++ llvm/trunk/test/Verifier/dominates.ll @@ -55,3 +55,16 @@ ; CHECK-NEXT: %y1 = add i32 %x, 1 ; CHECK-NEXT: %y3 = phi i32 [ %y1, %bb0 ] } + +define void @f5() { +entry: + br label %next + +next: + %y = phi i32 [ 0, %entry ] + %x = phi i32 [ %y, %entry ] + ret void +; CHECK: Instruction does not dominate all uses! +; CHECK-NEXT: %y = phi i32 [ 0, %entry ] +; CHECK-NEXT: %x = phi i32 [ %y, %entry ] +}