• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -codegenprepare < %s | FileCheck %s
3
4target triple = "x86_64-unknown-linux-gnu"
5
6define void @f1(i32 %a) {
7; CHECK-LABEL: @f1(
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:%.*]]
11; CHECK:       A:
12; CHECK-NEXT:    call void @g1()
13; CHECK-NEXT:    ret void
14; CHECK:       B:
15; CHECK-NEXT:    call void @g2()
16; CHECK-NEXT:    ret void
17;
18  %c = icmp eq i32 %a, 0
19  %fr = freeze i1 %c
20  br i1 %fr, label %A, label %B
21A:
22  call void @g1()
23  ret void
24B:
25  call void @g2()
26  ret void
27}
28
29define void @f2(i32 %a) {
30; CHECK-LABEL: @f2(
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:%.*]]
34; CHECK:       A:
35; CHECK-NEXT:    call void @g1()
36; CHECK-NEXT:    ret void
37; CHECK:       B:
38; CHECK-NEXT:    call void @g2()
39; CHECK-NEXT:    ret void
40;
41  %c = icmp eq i32 0, %a
42  %fr = freeze i1 %c
43  br i1 %fr, label %A, label %B
44A:
45  call void @g1()
46  ret void
47B:
48  call void @g2()
49  ret void
50}
51
52define void @f3(i32 %a) {
53; CHECK-LABEL: @f3(
54; CHECK-NEXT:    [[C:%.*]] = icmp eq i32 0, 1
55; CHECK-NEXT:    br i1 [[C]], label [[A:%.*]], label [[B:%.*]]
56; CHECK:       A:
57; CHECK-NEXT:    call void @g1()
58; CHECK-NEXT:    ret void
59; CHECK:       B:
60; CHECK-NEXT:    call void @g2()
61; CHECK-NEXT:    ret void
62;
63  %c = icmp eq i32 0, 1
64  %fr = freeze i1 %c
65  br i1 %fr, label %A, label %B
66A:
67  call void @g1()
68  ret void
69B:
70  call void @g2()
71  ret void
72}
73
74define i1 @ptrcmp(i8* %p) {
75; CHECK-LABEL: @ptrcmp(
76; CHECK-NEXT:    [[FR:%.*]] = freeze i8* [[P:%.*]]
77; CHECK-NEXT:    [[C:%.*]] = icmp eq i8* [[FR]], null
78; CHECK-NEXT:    ret i1 [[C]]
79;
80  %c = icmp eq i8* %p, null
81  %fr = freeze i1 %c
82  ret i1 %fr
83}
84
85
86define i1 @fcmp(float %a) {
87; CHECK-LABEL: @fcmp(
88; CHECK-NEXT:    [[FR:%.*]] = freeze float [[A:%.*]]
89; CHECK-NEXT:    [[C:%.*]] = fcmp oeq float [[FR]], 0.000000e+00
90; CHECK-NEXT:    ret i1 [[C]]
91;
92  %c = fcmp oeq float %a, 0.0
93  %fr = freeze i1 %c
94  ret i1 %fr
95}
96
97define 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]]
102;
103  %c = fcmp nnan oeq float %a, 0.0
104  %fr = freeze i1 %c
105  ret i1 %fr
106}
107
108define 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:%.*]]
114; CHECK:       A:
115; CHECK-NEXT:    call void @g1()
116; CHECK-NEXT:    ret void
117; CHECK:       B:
118; CHECK-NEXT:    call void @g2()
119; CHECK-NEXT:    ret void
120;
121  %v = and i32 %flag, 1
122  %c = icmp eq i32 %v, 0
123  %fr = freeze i1 %c
124  br i1 %fr, label %A, label %B
125A:
126  call void @g1()
127  ret void
128B:
129  call void @g2()
130  ret void
131}
132
133define 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:%.*]]
139; CHECK:       A:
140; CHECK-NEXT:    call void @g1()
141; CHECK-NEXT:    ret void
142; CHECK:       B:
143; CHECK-NEXT:    call void @g2()
144; CHECK-NEXT:    ret void
145;
146  %v = and i32 1, %flag
147  %c = icmp eq i32 0, %v
148  %fr = freeze i1 %c
149  br i1 %fr, label %A, label %B
150A:
151  call void @g1()
152  ret void
153B:
154  call void @g2()
155  ret void
156}
157
158define 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:%.*]]
167; CHECK:       A:
168; CHECK-NEXT:    call void @g1()
169; CHECK-NEXT:    ret void
170; CHECK:       B:
171; CHECK-NEXT:    call void @g2()
172; CHECK-NEXT:    ret void
173;
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
181A:
182  call void @g1()
183  ret void
184B:
185  call void @g2()
186  ret void
187}
188
189define void @and(i1 %a, i1 %b, i1 %c) {
190; CHECK-LABEL: @and(
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:%.*]]
195; CHECK:       A:
196; CHECK-NEXT:    call void @g1()
197; CHECK-NEXT:    ret void
198; CHECK:       B:
199; CHECK-NEXT:    call void @g2()
200; CHECK-NEXT:    ret void
201;
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
206A:
207  call void @g1()
208  ret void
209B:
210  call void @g2()
211  ret void
212}
213
214define 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:%.*]]
224; CHECK:       A:
225; CHECK-NEXT:    call void @g1()
226; CHECK-NEXT:    ret void
227; CHECK:       B:
228; CHECK-NEXT:    call void @g2()
229; CHECK-NEXT:    ret void
230;
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
239A:
240  call void @g1()
241  ret void
242B:
243  call void @g2()
244  ret void
245}
246
247define 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:%.*]]
256; CHECK:       A:
257; CHECK-NEXT:    call void @g1()
258; CHECK-NEXT:    ret void
259; CHECK:       B:
260; CHECK-NEXT:    call void @g2()
261; CHECK-NEXT:    ret void
262;
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
270A:
271  call void @g1()
272  ret void
273B:
274  call void @g2()
275  ret void
276}
277
278define void @or(i1 %a, i1 %b, i1 %c) {
279; CHECK-LABEL: @or(
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:%.*]]
284; CHECK:       A:
285; CHECK-NEXT:    call void @g1()
286; CHECK-NEXT:    ret void
287; CHECK:       B:
288; CHECK-NEXT:    call void @g2()
289; CHECK-NEXT:    ret void
290;
291  %cond = or i1 %a, %b
292  %cond2 = or i1 %c, %cond
293  %fr = freeze i1 %cond2
294  br i1 %fr, label %A, label %B
295A:
296  call void @g1()
297  ret void
298B:
299  call void @g2()
300  ret void
301}
302
303define 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:%.*]]
310; CHECK:       EXIT:
311; CHECK-NEXT:    ret void
312;
313  ret void
314UNREACHABLE:
315  %c = and i1 %a, %c
316  %fr = freeze i1 %c
317  br i1 %fr, label %UNREACHABLE, label %EXIT
318EXIT:
319  ret void
320}
321
322declare void @g1()
323declare void @g2()
324