diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index 6f1de466043..735a70c5092 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -160,10 +160,7 @@ void DominanceFrontier::splitBlock(BasicBlock *NewBB) { break; } } - - if (!BlockDominatesAny) - continue; - + // If NewBBSucc should not stay in our dominator frontier, remove it. // We remove it unless there is a predecessor of NewBBSucc that we // dominate, but we don't strictly dominate NewBBSucc. @@ -181,7 +178,8 @@ void DominanceFrontier::splitBlock(BasicBlock *NewBB) { if (ShouldRemove) removeFromFrontier(DFI, NewBBSucc); - addToFrontier(DFI, NewBB); + if (BlockDominatesAny && (&*FI == NewBB || !DT.dominates(FI, NewBB))) + addToFrontier(DFI, NewBB); } } diff --git a/test/Transforms/LoopSimplify/2004-04-13-LoopSimplifyUpdateDomFrontier.ll b/test/Transforms/LoopSimplify/2004-04-13-LoopSimplifyUpdateDomFrontier.ll index 427631c07f2..bd0515c476e 100644 --- a/test/Transforms/LoopSimplify/2004-04-13-LoopSimplifyUpdateDomFrontier.ll +++ b/test/Transforms/LoopSimplify/2004-04-13-LoopSimplifyUpdateDomFrontier.ll @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -scalarrepl -loopsimplify -licm -disable-output +; RUN: llvm-as < %s | opt -scalarrepl -loopsimplify -licm -disable-output -verify-dom-info define void @inflate() { entry: