[InstCombine] Add additional test for phi to condition fold (NFC)

This one does not have an intermediate block for the true branch,
and demonstrates the importance of using edge dominance.
This commit is contained in:
Nikita Popov 2022-03-01 16:07:47 +01:00
parent 8f4ea36bfe
commit 0bb698a2fb
1 changed files with 20 additions and 0 deletions

View File

@ -52,6 +52,26 @@ merge:
ret i1 %ret
}
define i1 @test_edge_dominance(i1 %cmp) {
; CHECK-LABEL: @test_edge_dominance(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[CMP:%.*]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
; CHECK: if.then:
; CHECK-NEXT: br label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: ret i1 [[CMP]]
;
entry:
br i1 %cmp, label %if.end, label %if.then
if.then:
br label %if.end
if.end:
%phi = phi i1 [ true, %entry ], [ false, %if.then ]
ret i1 %phi
}
define i1 @test_direct_implication_complex_cfg(i1 %cond, i32 %cnt1) {
; CHECK-LABEL: @test_direct_implication_complex_cfg(
; CHECK-NEXT: entry: