[JumpThreading] Add a test case that has a phi with undef; NFC

This commit is contained in:
Juneyoung Lee 2020-07-27 19:08:45 +09:00
parent c891f519e1
commit 6701c0bf73
1 changed files with 44 additions and 0 deletions

View File

@ -49,6 +49,50 @@ F2:
ret i32 %B
}
define i32 @test1_undef(i1 %cond) {
; CHECK-LABEL: @test1_undef(
; CHECK-NEXT: br i1 [[COND:%.*]], label [[T1:%.*]], label [[F1:%.*]]
; CHECK: T1:
; CHECK-NEXT: [[V1:%.*]] = call i32 @f1()
; CHECK-NEXT: br label [[MERGE:%.*]]
; CHECK: F1:
; CHECK-NEXT: [[V2:%.*]] = call i32 @f2()
; CHECK-NEXT: br label [[MERGE]]
; CHECK: Merge:
; CHECK-NEXT: [[A:%.*]] = phi i1 [ true, [[T1]] ], [ undef, [[F1]] ]
; CHECK-NEXT: [[B:%.*]] = phi i32 [ [[V1]], [[T1]] ], [ [[V2]], [[F1]] ]
; CHECK-NEXT: [[A_FR:%.*]] = freeze i1 [[A]]
; CHECK-NEXT: br i1 [[A_FR]], label [[T2:%.*]], label [[F2:%.*]]
; CHECK: T2:
; CHECK-NEXT: call void @f3()
; CHECK-NEXT: ret i32 [[B]]
; CHECK: F2:
; CHECK-NEXT: ret i32 [[B]]
;
br i1 %cond, label %T1, label %F1
T1:
%v1 = call i32 @f1()
br label %Merge
F1:
%v2 = call i32 @f2()
br label %Merge
Merge:
%A = phi i1 [true, %T1], [undef, %F1]
%B = phi i32 [%v1, %T1], [%v2, %F1]
%A.fr = freeze i1 %A
br i1 %A.fr, label %T2, label %F2
T2:
call void @f3()
ret i32 %B
F2:
ret i32 %B
}
define i32 @test2(i1 %cond, i1 %cond2) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: br i1 [[COND:%.*]], label [[T1:%.*]], label [[F1:%.*]]