diff --git a/llvm/lib/VMCore/Dominators.cpp b/llvm/lib/VMCore/Dominators.cpp index 6f1de466043d..735a70c50927 100644 --- a/llvm/lib/VMCore/Dominators.cpp +++ b/llvm/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/llvm/test/Transforms/LoopSimplify/2004-04-13-LoopSimplifyUpdateDomFrontier.ll b/llvm/test/Transforms/LoopSimplify/2004-04-13-LoopSimplifyUpdateDomFrontier.ll index 427631c07f2a..bd0515c476e9 100644 --- a/llvm/test/Transforms/LoopSimplify/2004-04-13-LoopSimplifyUpdateDomFrontier.ll +++ b/llvm/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: