Index: lib/IR/Verifier.cpp =================================================================== --- lib/IR/Verifier.cpp +++ lib/IR/Verifier.cpp @@ -3397,8 +3397,14 @@ return; } + // Quick check whether the def has already been encountered in the same block, + // unless it is a PHI node that never can use defs from its own block + // (eg. other PHIs) + 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: test/Transforms/LoopVectorize/phi-hang.ll =================================================================== --- test/Transforms/LoopVectorize/phi-hang.ll +++ 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: test/Verifier/dominates.ll =================================================================== --- test/Verifier/dominates.ll +++ 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 ] +}