1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -jump-threading -S < %s | FileCheck %s
8 define i32 @test1(i1 %cond) {
10 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[T2:%.*]], label [[F2:%.*]]
12 ; CHECK-NEXT: [[V1:%.*]] = call i32 @f1()
13 ; CHECK-NEXT: call void @f3()
14 ; CHECK-NEXT: ret i32 [[V1]]
16 ; CHECK-NEXT: [[V2:%.*]] = call i32 @f2()
17 ; CHECK-NEXT: ret i32 [[V2]]
19 br i1 %cond, label %T1, label %F1
30 %A = phi i1 [true, %T1], [false, %F1]
31 %B = phi i32 [%v1, %T1], [%v2, %F1]
33 br i1 %A.fr, label %T2, label %F2
43 define i32 @test1_cast(i1 %cond) {
44 ; CHECK-LABEL: @test1_cast(
45 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[T2:%.*]], label [[F2:%.*]]
47 ; CHECK-NEXT: [[V1:%.*]] = call i32 @f1()
48 ; CHECK-NEXT: call void @f3()
49 ; CHECK-NEXT: ret i32 [[V1]]
51 ; CHECK-NEXT: [[V2:%.*]] = call i32 @f2()
52 ; CHECK-NEXT: [[A:%.*]] = trunc i32 0 to i1
53 ; CHECK-NEXT: ret i32 [[V2]]
55 br i1 %cond, label %T1, label %F1
66 %A0 = phi i32 [1, %T1], [0, %F1]
67 %B = phi i32 [%v1, %T1], [%v2, %F1]
68 %A = trunc i32 %A0 to i1
70 br i1 %A.fr, label %T2, label %F2
80 define i32 @test1_cast2(i1 %cond) {
81 ; CHECK-LABEL: @test1_cast2(
82 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[T2:%.*]], label [[F2:%.*]]
84 ; CHECK-NEXT: [[V1:%.*]] = call i32 @f1()
85 ; CHECK-NEXT: call void @f3()
86 ; CHECK-NEXT: ret i32 [[V1]]
88 ; CHECK-NEXT: [[V2:%.*]] = call i32 @f2()
89 ; CHECK-NEXT: [[A0_FR:%.*]] = freeze i32 0
90 ; CHECK-NEXT: ret i32 [[V2]]
92 br i1 %cond, label %T1, label %F1
103 %A0 = phi i32 [1, %T1], [0, %F1]
104 %B = phi i32 [%v1, %T1], [%v2, %F1]
105 %A0.fr = freeze i32 %A0
106 %A.fr = trunc i32 %A0.fr to i1
107 br i1 %A.fr, label %T2, label %F2
117 define i32 @test1_undef(i1 %cond) {
118 ; CHECK-LABEL: @test1_undef(
119 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[T2:%.*]], label [[F2:%.*]]
121 ; CHECK-NEXT: [[V1:%.*]] = call i32 @f1()
122 ; CHECK-NEXT: call void @f3()
123 ; CHECK-NEXT: ret i32 [[V1]]
125 ; CHECK-NEXT: [[V2:%.*]] = call i32 @f2()
126 ; CHECK-NEXT: ret i32 [[V2]]
128 br i1 %cond, label %T1, label %F1
139 %A = phi i1 [true, %T1], [undef, %F1]
140 %B = phi i32 [%v1, %T1], [%v2, %F1]
142 br i1 %A.fr, label %T2, label %F2
152 define i32 @test2(i1 %cond, i1 %cond2) {
153 ; CHECK-LABEL: @test2(
154 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[MERGE_THREAD:%.*]], label [[MERGE:%.*]]
155 ; CHECK: Merge.thread:
156 ; CHECK-NEXT: [[V1:%.*]] = call i32 @f1()
157 ; CHECK-NEXT: br label [[T2:%.*]]
159 ; CHECK-NEXT: [[V2:%.*]] = call i32 @f2()
160 ; CHECK-NEXT: [[A_FR:%.*]] = freeze i1 [[COND2:%.*]]
161 ; CHECK-NEXT: br i1 [[A_FR]], label [[T2]], label [[F2:%.*]]
163 ; CHECK-NEXT: [[B4:%.*]] = phi i32 [ [[V1]], [[MERGE_THREAD]] ], [ [[V2]], [[MERGE]] ]
164 ; CHECK-NEXT: call void @f3()
165 ; CHECK-NEXT: ret i32 [[B4]]
167 ; CHECK-NEXT: ret i32 [[V2]]
169 br i1 %cond, label %T1, label %F1
180 %A = phi i1 [true, %T1], [%cond2, %F1]
181 %B = phi i32 [%v1, %T1], [%v2, %F1]
183 br i1 %A.fr, label %T2, label %F2