forked from OSchip/llvm-project
[SimplifyCFG] Teach SimplifyEqualityComparisonWithOnlyPredecessor() to preserve DomTree, part 2
This commit is contained in:
parent
6027e05dbf
commit
fe9bdd9621
|
@ -970,12 +970,15 @@ bool SimplifyCFGOpt::SimplifyEqualityComparisonWithOnlyPredecessor(
|
|||
if (!TheRealDest)
|
||||
TheRealDest = ThisDef;
|
||||
|
||||
SmallVector<DominatorTree::UpdateType, 2> Updates;
|
||||
|
||||
// Remove PHI node entries for dead edges.
|
||||
BasicBlock *CheckEdge = TheRealDest;
|
||||
for (BasicBlock *Succ : successors(TIBB))
|
||||
if (Succ != CheckEdge)
|
||||
if (Succ != CheckEdge) {
|
||||
Succ->removePredecessor(TIBB);
|
||||
else
|
||||
Updates.push_back({DominatorTree::Delete, TIBB, Succ});
|
||||
} else
|
||||
CheckEdge = nullptr;
|
||||
|
||||
// Insert the new branch.
|
||||
|
@ -987,6 +990,8 @@ bool SimplifyCFGOpt::SimplifyEqualityComparisonWithOnlyPredecessor(
|
|||
<< "\n");
|
||||
|
||||
EraseTerminatorAndDCECond(TI);
|
||||
if (DTU)
|
||||
DTU->applyUpdatesPermissive(Updates);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; RUN: opt < %s -simplifycfg -disable-output
|
||||
; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -disable-output
|
||||
; END.
|
||||
|
||||
target datalayout = "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; RUN: opt %s -S -simplifycfg | FileCheck %s
|
||||
; RUN: opt %s -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s
|
||||
|
||||
; cmp1 implies cmp2 is false
|
||||
; CHECK-LABEL: @test1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; RUN: opt < %s -simplifycfg -S | not grep bb17
|
||||
; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | not grep bb17
|
||||
; PR1786
|
||||
|
||||
define i32 @main() {
|
||||
|
|
Loading…
Reference in New Issue