1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' < %s | FileCheck %s
4 target triple = "x86_64-unknown-linux-gnu"
6 define void @f1(i32 %a) {
8 ; CHECK-NEXT: [[FR:%.*]] = freeze i32 [[A:%.*]]
9 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[FR]], 0
10 ; CHECK-NEXT: br i1 [[C]], label [[A:%.*]], label [[B:%.*]]
12 ; CHECK-NEXT: call void @g1()
13 ; CHECK-NEXT: ret void
15 ; CHECK-NEXT: call void @g2()
16 ; CHECK-NEXT: ret void
18 %c = icmp eq i32 %a, 0
20 br i1 %fr, label %A, label %B
29 define void @f2(i32 %a) {
31 ; CHECK-NEXT: [[FR:%.*]] = freeze i32 [[A:%.*]]
32 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 0, [[FR]]
33 ; CHECK-NEXT: br i1 [[C]], label [[A:%.*]], label [[B:%.*]]
35 ; CHECK-NEXT: call void @g1()
36 ; CHECK-NEXT: ret void
38 ; CHECK-NEXT: call void @g2()
39 ; CHECK-NEXT: ret void
41 %c = icmp eq i32 0, %a
43 br i1 %fr, label %A, label %B
52 define void @f3(i32 %a) {
54 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 0, 1
55 ; CHECK-NEXT: br i1 [[C]], label [[A:%.*]], label [[B:%.*]]
57 ; CHECK-NEXT: call void @g1()
58 ; CHECK-NEXT: ret void
60 ; CHECK-NEXT: call void @g2()
61 ; CHECK-NEXT: ret void
65 br i1 %fr, label %A, label %B
74 define i1 @ptrcmp(ptr %p) {
75 ; CHECK-LABEL: @ptrcmp(
76 ; CHECK-NEXT: [[FR:%.*]] = freeze ptr [[P:%.*]]
77 ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[FR]], null
78 ; CHECK-NEXT: ret i1 [[C]]
80 %c = icmp eq ptr %p, null
86 define i1 @fcmp(float %a) {
88 ; CHECK-NEXT: [[FR:%.*]] = freeze float [[A:%.*]]
89 ; CHECK-NEXT: [[C:%.*]] = fcmp oeq float [[FR]], 0.000000e+00
90 ; CHECK-NEXT: ret i1 [[C]]
92 %c = fcmp oeq float %a, 0.0
97 define i1 @fcmp_nan(float %a) {
98 ; CHECK-LABEL: @fcmp_nan(
99 ; CHECK-NEXT: [[C:%.*]] = fcmp nnan oeq float [[A:%.*]], 0.000000e+00
100 ; CHECK-NEXT: [[FR:%.*]] = freeze i1 [[C]]
101 ; CHECK-NEXT: ret i1 [[FR]]
103 %c = fcmp nnan oeq float %a, 0.0
108 define void @and_bitmask(i32 %flag) {
109 ; CHECK-LABEL: @and_bitmask(
110 ; CHECK-NEXT: [[V:%.*]] = and i32 [[FLAG:%.*]], 1
111 ; CHECK-NEXT: [[FR:%.*]] = freeze i32 [[V]]
112 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[FR]], 0
113 ; CHECK-NEXT: br i1 [[C]], label [[A:%.*]], label [[B:%.*]]
115 ; CHECK-NEXT: call void @g1()
116 ; CHECK-NEXT: ret void
118 ; CHECK-NEXT: call void @g2()
119 ; CHECK-NEXT: ret void
121 %v = and i32 %flag, 1
122 %c = icmp eq i32 %v, 0
124 br i1 %fr, label %A, label %B
133 define void @and_bitmask_r(i32 %flag) {
134 ; CHECK-LABEL: @and_bitmask_r(
135 ; CHECK-NEXT: [[V:%.*]] = and i32 1, [[FLAG:%.*]]
136 ; CHECK-NEXT: [[FR:%.*]] = freeze i32 [[V]]
137 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 0, [[FR]]
138 ; CHECK-NEXT: br i1 [[C]], label [[A:%.*]], label [[B:%.*]]
140 ; CHECK-NEXT: call void @g1()
141 ; CHECK-NEXT: ret void
143 ; CHECK-NEXT: call void @g2()
144 ; CHECK-NEXT: ret void
146 %v = and i32 1, %flag
147 %c = icmp eq i32 0, %v
149 br i1 %fr, label %A, label %B
158 define void @and_bitmask2(i32 %flag, i32 %flag2) {
159 ; CHECK-LABEL: @and_bitmask2(
160 ; CHECK-NEXT: [[V:%.*]] = and i32 [[FLAG:%.*]], 1
161 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[V]], 0
162 ; CHECK-NEXT: [[V2:%.*]] = and i32 [[FLAG2:%.*]], 2
163 ; CHECK-NEXT: [[C2:%.*]] = icmp eq i32 [[V2]], 0
164 ; CHECK-NEXT: [[COND:%.*]] = or i1 [[C]], [[C2]]
165 ; CHECK-NEXT: [[FR:%.*]] = freeze i1 [[COND]]
166 ; CHECK-NEXT: br i1 [[FR]], label [[A:%.*]], label [[B:%.*]]
168 ; CHECK-NEXT: call void @g1()
169 ; CHECK-NEXT: ret void
171 ; CHECK-NEXT: call void @g2()
172 ; CHECK-NEXT: ret void
174 %v = and i32 %flag, 1
175 %c = icmp eq i32 %v, 0
176 %v2 = and i32 %flag2, 2
177 %c2 = icmp eq i32 %v2, 0
178 %cond = or i1 %c, %c2
179 %fr = freeze i1 %cond
180 br i1 %fr, label %A, label %B
189 define void @and(i1 %a, i1 %b, i1 %c) {
191 ; CHECK-NEXT: [[COND:%.*]] = and i1 [[A:%.*]], [[B:%.*]]
192 ; CHECK-NEXT: [[COND2:%.*]] = and i1 [[C:%.*]], [[COND]]
193 ; CHECK-NEXT: [[FR:%.*]] = freeze i1 [[COND2]]
194 ; CHECK-NEXT: br i1 [[FR]], label [[A:%.*]], label [[B:%.*]]
196 ; CHECK-NEXT: call void @g1()
197 ; CHECK-NEXT: ret void
199 ; CHECK-NEXT: call void @g2()
200 ; CHECK-NEXT: ret void
202 %cond = and i1 %a, %b
203 %cond2 = and i1 %c, %cond
204 %fr = freeze i1 %cond2
205 br i1 %fr, label %A, label %B
214 define void @and_long(i1 %a, i1 %b, i1 %c, i1 %d, i1 %e, i1 %f, i1 %g) {
215 ; CHECK-LABEL: @and_long(
216 ; CHECK-NEXT: [[COND:%.*]] = and i1 [[A:%.*]], [[B:%.*]]
217 ; CHECK-NEXT: [[COND2:%.*]] = and i1 [[C:%.*]], [[COND]]
218 ; CHECK-NEXT: [[COND3:%.*]] = and i1 [[D:%.*]], [[COND2]]
219 ; CHECK-NEXT: [[COND4:%.*]] = and i1 [[E:%.*]], [[COND3]]
220 ; CHECK-NEXT: [[COND5:%.*]] = and i1 [[F:%.*]], [[COND4]]
221 ; CHECK-NEXT: [[COND6:%.*]] = and i1 [[G:%.*]], [[COND5]]
222 ; CHECK-NEXT: [[FR:%.*]] = freeze i1 [[COND6]]
223 ; CHECK-NEXT: br i1 [[FR]], label [[A:%.*]], label [[B:%.*]]
225 ; CHECK-NEXT: call void @g1()
226 ; CHECK-NEXT: ret void
228 ; CHECK-NEXT: call void @g2()
229 ; CHECK-NEXT: ret void
231 %cond = and i1 %a, %b
232 %cond2 = and i1 %c, %cond
233 %cond3 = and i1 %d, %cond2
234 %cond4 = and i1 %e, %cond3
235 %cond5 = and i1 %f, %cond4
236 %cond6 = and i1 %g, %cond5
237 %fr = freeze i1 %cond6
238 br i1 %fr, label %A, label %B
247 define void @and_cmp(i32 %v, float %w, i32 %v2) {
248 ; CHECK-LABEL: @and_cmp(
249 ; CHECK-NEXT: [[C1:%.*]] = icmp eq i32 [[V:%.*]], 0
250 ; CHECK-NEXT: [[C2:%.*]] = fcmp oeq float [[W:%.*]], 0.000000e+00
251 ; CHECK-NEXT: [[COND:%.*]] = and i1 [[C1]], [[C2]]
252 ; CHECK-NEXT: [[C3:%.*]] = icmp eq i32 [[V2:%.*]], 1
253 ; CHECK-NEXT: [[COND2:%.*]] = and i1 [[COND]], [[C3]]
254 ; CHECK-NEXT: [[FR:%.*]] = freeze i1 [[COND2]]
255 ; CHECK-NEXT: br i1 [[FR]], label [[A:%.*]], label [[B:%.*]]
257 ; CHECK-NEXT: call void @g1()
258 ; CHECK-NEXT: ret void
260 ; CHECK-NEXT: call void @g2()
261 ; CHECK-NEXT: ret void
263 %c1 = icmp eq i32 %v, 0
264 %c2 = fcmp oeq float %w, 0.0
265 %cond = and i1 %c1, %c2
266 %c3 = icmp eq i32 %v2, 1
267 %cond2 = and i1 %cond, %c3
268 %fr = freeze i1 %cond2
269 br i1 %fr, label %A, label %B
278 define void @or(i1 %a, i1 %b, i1 %c) {
280 ; CHECK-NEXT: [[COND:%.*]] = or i1 [[A:%.*]], [[B:%.*]]
281 ; CHECK-NEXT: [[COND2:%.*]] = or i1 [[C:%.*]], [[COND]]
282 ; CHECK-NEXT: [[FR:%.*]] = freeze i1 [[COND2]]
283 ; CHECK-NEXT: br i1 [[FR]], label [[A:%.*]], label [[B:%.*]]
285 ; CHECK-NEXT: call void @g1()
286 ; CHECK-NEXT: ret void
288 ; CHECK-NEXT: call void @g2()
289 ; CHECK-NEXT: ret void
292 %cond2 = or i1 %c, %cond
293 %fr = freeze i1 %cond2
294 br i1 %fr, label %A, label %B
303 define void @and_loop(i1 %a, i1 %b) {
304 ; CHECK-LABEL: @and_loop(
305 ; CHECK-NEXT: ret void
306 ; CHECK: UNREACHABLE:
307 ; CHECK-NEXT: [[C:%.*]] = and i1 [[A:%.*]], [[C]]
308 ; CHECK-NEXT: [[FR:%.*]] = freeze i1 [[C]]
309 ; CHECK-NEXT: br i1 [[FR]], label [[UNREACHABLE:%.*]], label [[EXIT:%.*]]
311 ; CHECK-NEXT: ret void
317 br i1 %fr, label %UNREACHABLE, label %EXIT