[SCCP] Add additional multi-edge + phi tests (NFC)

This commit is contained in:
Nikita Popov 2020-07-22 21:56:47 +02:00
parent 33f6542014
commit e20b3079c1
2 changed files with 51 additions and 0 deletions

View File

@ -140,3 +140,27 @@ define i32 @indbrtest5_callee(i1 %c) {
%r = call i32 @indbrtest5(i1 %c)
ret i32 %r
}
define i32 @indbr_duplicate_successors_phi(i1 %c, i32 %x) {
; CHECK-LABEL: @indbr_duplicate_successors_phi(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[C:%.*]], label [[INDBR:%.*]], label [[BB0:%.*]]
; CHECK: indbr:
; CHECK-NEXT: br label [[BB0]]
; CHECK: BB0:
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[X:%.*]], [[ENTRY:%.*]] ], [ 0, [[INDBR]] ]
; CHECK-NEXT: ret i32 [[PHI]]
;
entry:
br i1 %c, label %indbr, label %BB0
indbr:
indirectbr i8* blockaddress(@indbr_duplicate_successors_phi, %BB0), [label %BB0, label %BB0, label %BB1]
BB0:
%phi = phi i32 [ %x, %entry ], [ 0, %indbr ], [ 0, %indbr ]
ret i32 %phi
BB1:
ret i32 0
}

View File

@ -50,6 +50,33 @@ end:
ret i32 %phi
}
define i32 @test_duplicate_successors_phi_2(i1 %c, i32 %x) {
; CHECK-LABEL: @test_duplicate_successors_phi_2(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[C:%.*]], label [[SWITCH:%.*]], label [[END:%.*]]
; CHECK: switch:
; CHECK-NEXT: br label [[END]]
; CHECK: end:
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[X:%.*]], [[ENTRY:%.*]] ], [ 1, [[SWITCH]] ]
; CHECK-NEXT: ret i32 [[PHI]]
;
entry:
br i1 %c, label %switch, label %end
switch:
switch i32 0, label %switch.default [
i32 0, label %end
i32 1, label %end
]
switch.default:
ret i32 -1
end:
%phi = phi i32 [ %x, %entry ], [ 1, %switch ], [ 1, %switch ]
ret i32 %phi
}
define i32 @test_local_range(i32 %x) {
; CHECK-LABEL: @test_local_range(
; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[X:%.*]], 3