diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index d6465f599cf4..e7bd75e04931 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1102,7 +1102,6 @@ static bool FoldCondBranchOnPHI(BranchInst *BI) { // Degenerate case of a single entry PHI. if (PN->getNumIncomingValues() == 1) { FoldSingleEntryPHINodes(PN->getParent()); - PN->eraseFromParent(); return true; } diff --git a/llvm/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll b/llvm/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll new file mode 100644 index 000000000000..7b4aee489b55 --- /dev/null +++ b/llvm/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll @@ -0,0 +1,13 @@ +; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis +define i32 @test() { +entry: + br label %T +T: + %C = phi i1 [false, %entry] + br i1 %C, label %X, label %Y +X: + ret i32 2 +Y: + add i32 1, 2 + ret i32 1 +}