forked from OSchip/llvm-project
[SimplifyCFG] Teach SimplifyCondBranchToTwoReturns() to preserve DomTree, part 1
... for the general case of returning a value.
This commit is contained in:
parent
4d87a6ad13
commit
b94520c9ee
|
@ -2688,6 +2688,11 @@ bool SimplifyCFGOpt::SimplifyCondBranchToTwoReturns(BranchInst *BI,
|
|||
|
||||
EraseTerminatorAndDCECond(BI);
|
||||
|
||||
if (DTU) {
|
||||
DTU->applyUpdatesPermissive({{DominatorTree::Delete, BB, TrueSucc},
|
||||
{DominatorTree::Delete, BB, FalseSucc}});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; RUN: opt < %s -S -indvars -loop-deletion -simplifycfg | FileCheck %s
|
||||
; RUN: opt < %s -S -indvars -loop-deletion -simplifycfg -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s
|
||||
; PR5794
|
||||
|
||||
; Indvars and loop deletion should be able to eliminate all looping
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; RUN: opt < %s -simplifycfg -disable-output
|
||||
; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -disable-output
|
||||
; PR 2777
|
||||
@g_103 = common global i32 0 ; <i32*> [#uses=1]
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -simplifycfg-dup-ret -S | FileCheck %s
|
||||
|
||||
declare void @bar()
|
||||
declare void @baz()
|
||||
|
||||
define i8 @foo(i1 %c, i8 %v0, i8 %v1) {
|
||||
; CHECK-LABEL: @foo(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[C:%.*]], i8 [[V0:%.*]], i8 [[V1:%.*]]
|
||||
; CHECK-NEXT: ret i8 [[SPEC_SELECT]]
|
||||
;
|
||||
entry:
|
||||
br i1 %c, label %true, label %false
|
||||
|
||||
true:
|
||||
ret i8 %v0
|
||||
|
||||
false:
|
||||
ret i8 %v1
|
||||
}
|
Loading…
Reference in New Issue