1; RUN: opt -S -instcombine < %s | FileCheck %s
2
3; CHECK-LABEL: @i32_cast_cmp_oeq_int_0_uitofp(
4; CHECK-NEXT: icmp eq i32 %i, 0
5; CHECK-NEXT: ret
6define i1 @i32_cast_cmp_oeq_int_0_uitofp(i32 %i) {
7  %f = uitofp i32 %i to float
8  %cmp = fcmp oeq float %f, 0.0
9  ret i1 %cmp
10}
11
12; CHECK-LABEL: @i32_cast_cmp_oeq_int_n0_uitofp(
13; CHECK: uitofp
14; CHECK: fcmp oeq
15define i1 @i32_cast_cmp_oeq_int_n0_uitofp(i32 %i) {
16  %f = uitofp i32 %i to float
17  %cmp = fcmp oeq float %f, -0.0
18  ret i1 %cmp
19}
20
21; CHECK-LABEL: @i32_cast_cmp_oeq_int_0_sitofp(
22; CHECK-NEXT: icmp eq i32 %i, 0
23; CHECK-NEXT: ret
24define i1 @i32_cast_cmp_oeq_int_0_sitofp(i32 %i) {
25  %f = sitofp i32 %i to float
26  %cmp = fcmp oeq float %f, 0.0
27  ret i1 %cmp
28}
29
30; CHECK-LABEL: @i32_cast_cmp_oeq_int_n0_sitofp(
31; CHECK: sitofp
32; CHECK: fcmp oeq
33define i1 @i32_cast_cmp_oeq_int_n0_sitofp(i32 %i) {
34  %f = sitofp i32 %i to float
35  %cmp = fcmp oeq float %f, -0.0
36  ret i1 %cmp
37}
38
39; CHECK-LABEL: @i32_cast_cmp_one_int_0_uitofp(
40; CHECK-NEXT: icmp ne i32 %i, 0
41; CHECK-NEXT: ret
42define i1 @i32_cast_cmp_one_int_0_uitofp(i32 %i) {
43  %f = uitofp i32 %i to float
44  %cmp = fcmp one float %f, 0.0
45  ret i1 %cmp
46}
47
48; CHECK-LABEL: @i32_cast_cmp_one_int_n0_uitofp(
49; CHECK: uitofp
50; CHECK: fcmp one
51define i1 @i32_cast_cmp_one_int_n0_uitofp(i32 %i) {
52  %f = uitofp i32 %i to float
53  %cmp = fcmp one float %f, -0.0
54  ret i1 %cmp
55}
56
57; CHECK-LABEL: @i32_cast_cmp_one_int_0_sitofp(
58; CHECK-NEXT: icmp ne i32 %i, 0
59; CHECK-NEXT: ret
60define i1 @i32_cast_cmp_one_int_0_sitofp(i32 %i) {
61  %f = sitofp i32 %i to float
62  %cmp = fcmp one float %f, 0.0
63  ret i1 %cmp
64}
65
66; CHECK-LABEL: @i32_cast_cmp_one_int_n0_sitofp(
67; CHECK: sitofp
68; CHECK: fcmp one
69define i1 @i32_cast_cmp_one_int_n0_sitofp(i32 %i) {
70  %f = sitofp i32 %i to float
71  %cmp = fcmp one float %f, -0.0
72  ret i1 %cmp
73}
74
75; CHECK-LABEL: @i32_cast_cmp_ueq_int_0_uitofp(
76; CHECK-NEXT: icmp eq i32 %i, 0
77; CHECK-NEXT: ret
78define i1 @i32_cast_cmp_ueq_int_0_uitofp(i32 %i) {
79  %f = uitofp i32 %i to float
80  %cmp = fcmp ueq float %f, 0.0
81  ret i1 %cmp
82}
83
84; CHECK-LABEL: @i32_cast_cmp_ueq_int_n0_uitofp(
85; CHECK: uitofp
86; CHECK: fcmp ueq
87define i1 @i32_cast_cmp_ueq_int_n0_uitofp(i32 %i) {
88  %f = uitofp i32 %i to float
89  %cmp = fcmp ueq float %f, -0.0
90  ret i1 %cmp
91}
92
93; CHECK-LABEL: @i32_cast_cmp_ueq_int_0_sitofp(
94; CHECK-NEXT: icmp eq i32 %i, 0
95; CHECK-NEXT: ret
96define i1 @i32_cast_cmp_ueq_int_0_sitofp(i32 %i) {
97  %f = sitofp i32 %i to float
98  %cmp = fcmp ueq float %f, 0.0
99  ret i1 %cmp
100}
101
102; CHECK-LABEL: @i32_cast_cmp_ueq_int_n0_sitofp(
103; CHECK: sitofp
104; CHECK: fcmp ueq
105define i1 @i32_cast_cmp_ueq_int_n0_sitofp(i32 %i) {
106  %f = sitofp i32 %i to float
107  %cmp = fcmp ueq float %f, -0.0
108  ret i1 %cmp
109}
110
111; CHECK-LABEL: @i32_cast_cmp_une_int_0_uitofp(
112; CHECK-NEXT: icmp ne i32 %i, 0
113; CHECK-NEXT: ret
114define i1 @i32_cast_cmp_une_int_0_uitofp(i32 %i) {
115  %f = uitofp i32 %i to float
116  %cmp = fcmp une float %f, 0.0
117  ret i1 %cmp
118}
119
120; CHECK-LABEL: @i32_cast_cmp_une_int_n0_uitofp(
121; CHECK: uitofp
122; CHECK: fcmp une
123define i1 @i32_cast_cmp_une_int_n0_uitofp(i32 %i) {
124  %f = uitofp i32 %i to float
125  %cmp = fcmp une float %f, -0.0
126  ret i1 %cmp
127}
128
129; CHECK-LABEL: @i32_cast_cmp_une_int_0_sitofp(
130; CHECK-NEXT: icmp ne i32 %i, 0
131; CHECK-NEXT: ret
132define i1 @i32_cast_cmp_une_int_0_sitofp(i32 %i) {
133  %f = sitofp i32 %i to float
134  %cmp = fcmp une float %f, 0.0
135  ret i1 %cmp
136}
137
138; CHECK-LABEL: @i32_cast_cmp_une_int_n0_sitofp(
139; CHECK: sitofp
140; CHECK: fcmp une
141define i1 @i32_cast_cmp_une_int_n0_sitofp(i32 %i) {
142  %f = sitofp i32 %i to float
143  %cmp = fcmp une float %f, -0.0
144  ret i1 %cmp
145}
146
147; CHECK-LABEL: @i32_cast_cmp_ogt_int_0_uitofp(
148; CHECK: icmp ne i32 %i, 0
149; CHECK-NEXT: ret
150define i1 @i32_cast_cmp_ogt_int_0_uitofp(i32 %i) {
151  %f = uitofp i32 %i to float
152  %cmp = fcmp ogt float %f, 0.0
153  ret i1 %cmp
154}
155
156; CHECK-LABEL: @i32_cast_cmp_ogt_int_n0_uitofp(
157; CHECK: uitofp
158; CHECK: fcmp ogt
159define i1 @i32_cast_cmp_ogt_int_n0_uitofp(i32 %i) {
160  %f = uitofp i32 %i to float
161  %cmp = fcmp ogt float %f, -0.0
162  ret i1 %cmp
163}
164
165; CHECK-LABEL: @i32_cast_cmp_ogt_int_0_sitofp(
166; CHECK: icmp sgt i32 %i, 0
167; CHECK-NEXT: ret
168define i1 @i32_cast_cmp_ogt_int_0_sitofp(i32 %i) {
169  %f = sitofp i32 %i to float
170  %cmp = fcmp ogt float %f, 0.0
171  ret i1 %cmp
172}
173
174; CHECK-LABEL: @i32_cast_cmp_ogt_int_n0_sitofp(
175; CHECK: sitofp
176; CHECK: fcmp ogt
177define i1 @i32_cast_cmp_ogt_int_n0_sitofp(i32 %i) {
178  %f = sitofp i32 %i to float
179  %cmp = fcmp ogt float %f, -0.0
180  ret i1 %cmp
181}
182
183; CHECK-LABEL: @i32_cast_cmp_ole_int_0_uitofp(
184; CHECK: icmp eq i32 %i, 0
185; CHECK-NEXT: ret
186define i1 @i32_cast_cmp_ole_int_0_uitofp(i32 %i) {
187  %f = uitofp i32 %i to float
188  %cmp = fcmp ole float %f, 0.0
189  ret i1 %cmp
190}
191
192; CHECK-LABEL: @i32_cast_cmp_ole_int_0_sitofp(
193; CHECK: icmp slt i32 %i, 1
194; CHECK-NEXT: ret
195define i1 @i32_cast_cmp_ole_int_0_sitofp(i32 %i) {
196  %f = sitofp i32 %i to float
197  %cmp = fcmp ole float %f, 0.0
198  ret i1 %cmp
199}
200
201; CHECK-LABEL: @i32_cast_cmp_olt_int_0_uitofp(
202; CHECK: ret i1 false
203define i1 @i32_cast_cmp_olt_int_0_uitofp(i32 %i) {
204  %f = uitofp i32 %i to float
205  %cmp = fcmp olt float %f, 0.0
206  ret i1 %cmp
207}
208
209; CHECK-LABEL: @i32_cast_cmp_olt_int_0_sitofp(
210; CHECK: icmp slt i32 %i, 0
211; CHECK-NEXT: ret
212define i1 @i32_cast_cmp_olt_int_0_sitofp(i32 %i) {
213  %f = sitofp i32 %i to float
214  %cmp = fcmp olt float %f, 0.0
215  ret i1 %cmp
216}
217
218; CHECK-LABEL: @i64_cast_cmp_oeq_int_0_uitofp(
219; CHECK-NEXT: icmp eq i64 %i, 0
220; CHECK-NEXT: ret
221define i1 @i64_cast_cmp_oeq_int_0_uitofp(i64 %i) {
222  %f = uitofp i64 %i to float
223  %cmp = fcmp oeq float %f, 0.0
224  ret i1 %cmp
225}
226
227; CHECK-LABEL: @i64_cast_cmp_oeq_int_0_sitofp(
228; CHECK-NEXT: icmp eq i64 %i, 0
229; CHECK-NEXT: ret
230define i1 @i64_cast_cmp_oeq_int_0_sitofp(i64 %i) {
231  %f = sitofp i64 %i to float
232  %cmp = fcmp oeq float %f, 0.0
233  ret i1 %cmp
234}
235
236; CHECK-LABEL: @i64_cast_cmp_oeq_int_0_uitofp_half(
237; CHECK-NEXT: icmp eq i64 %i, 0
238; CHECK-NEXT: ret
239define i1 @i64_cast_cmp_oeq_int_0_uitofp_half(i64 %i) {
240  %f = uitofp i64 %i to half
241  %cmp = fcmp oeq half %f, 0.0
242  ret i1 %cmp
243}
244
245; CHECK-LABEL: @i64_cast_cmp_oeq_int_0_sitofp_half(
246; CHECK-NEXT: icmp eq i64 %i, 0
247; CHECK-NEXT: ret
248define i1 @i64_cast_cmp_oeq_int_0_sitofp_half(i64 %i) {
249  %f = sitofp i64 %i to half
250  %cmp = fcmp oeq half %f, 0.0
251  ret i1 %cmp
252}
253
254; CHECK-LABEL: @i32_cast_cmp_oeq_int_0_uitofp_ppcf128(
255; CHECK: uitofp
256; CHECK: fcmp oeq
257; CHECK-NEXT: ret
258define i1 @i32_cast_cmp_oeq_int_0_uitofp_ppcf128(i32 %i) {
259  %f = uitofp i32 %i to ppc_fp128
260  %cmp = fcmp oeq ppc_fp128 %f, 0xM00000000000000000000000000000000
261  ret i1 %cmp
262}
263
264; CHECK-LABEL: @i32_cast_cmp_oeq_int_i24max_uitofp(
265; CHECK: uitofp
266; CHECK: fcmp oeq
267
268; XCHECK: icmp eq i32 %i, 16777215
269; XCHECK-NEXT: ret
270define i1 @i32_cast_cmp_oeq_int_i24max_uitofp(i32 %i) {
271  %f = uitofp i32 %i to float
272  %cmp = fcmp oeq float %f, 0x416FFFFFE0000000
273  ret i1 %cmp
274}
275
276; CHECK-LABEL: @i32_cast_cmp_oeq_int_i24max_sitofp(
277; CHECK: sitofp
278; CHECK: fcmp oeq
279
280; XCHECK: icmp eq i32 %i, 16777215
281; XCHECK-NEXT: ret
282define i1 @i32_cast_cmp_oeq_int_i24max_sitofp(i32 %i) {
283  %f = sitofp i32 %i to float
284  %cmp = fcmp oeq float %f, 0x416FFFFFE0000000
285  ret i1 %cmp
286}
287
288; CHECK-LABEL: @i32_cast_cmp_oeq_int_i24maxp1_uitofp(
289; CHECK: uitofp
290; CHECK: fcmp oeq
291
292; XCHECK: icmp eq i32 %i, 16777216
293; XCHECK-NEXT: ret
294define i1 @i32_cast_cmp_oeq_int_i24maxp1_uitofp(i32 %i) {
295  %f = uitofp i32 %i to float
296  %cmp = fcmp oeq float %f, 0x4170000000000000
297  ret i1 %cmp
298}
299
300; CHECK-LABEL: @i32_cast_cmp_oeq_int_i24maxp1_sitofp(
301; CHECK: sitofp
302; CHECK: fcmp oeq
303
304; XCHECK: icmp eq i32 %i, 16777216
305; XCHECK-NEXT: ret
306define i1 @i32_cast_cmp_oeq_int_i24maxp1_sitofp(i32 %i) {
307  %f = sitofp i32 %i to float
308  %cmp = fcmp oeq float %f, 0x4170000000000000
309  ret i1 %cmp
310}
311
312; CHECK-LABEL: @i32_cast_cmp_oeq_int_i32umax_uitofp(
313; CHECK: uitofp
314; CHECK: fcmp oeq
315; CHECK-NEXT: ret
316define i1 @i32_cast_cmp_oeq_int_i32umax_uitofp(i32 %i) {
317  %f = uitofp i32 %i to float
318  %cmp = fcmp oeq float %f, 0x41F0000000000000
319  ret i1 %cmp
320}
321
322; CHECK-LABEL: @i32_cast_cmp_oeq_int_i32umax_sitofp(
323; CHECK: sitofp
324; CHECK: fcmp oeq
325; CHECK-NEXT: ret
326define i1 @i32_cast_cmp_oeq_int_i32umax_sitofp(i32 %i) {
327  %f = sitofp i32 %i to float
328  %cmp = fcmp oeq float %f, 0x41F0000000000000
329  ret i1 %cmp
330}
331
332; CHECK-LABEL: @i32_cast_cmp_oeq_int_i32imin_uitofp(
333; CHECK: uitofp
334; CHECK: fcmp oeq
335; CHECK-NEXT: ret
336define i1 @i32_cast_cmp_oeq_int_i32imin_uitofp(i32 %i) {
337  %f = uitofp i32 %i to float
338  %cmp = fcmp oeq float %f, 0xC1E0000000000000
339  ret i1 %cmp
340}
341
342; CHECK-LABEL: @i32_cast_cmp_oeq_int_i32imin_sitofp(
343; CHECK: sitofp
344; CHECK: fcmp oeq
345; CHECK-NEXT: ret
346define i1 @i32_cast_cmp_oeq_int_i32imin_sitofp(i32 %i) {
347  %f = sitofp i32 %i to float
348  %cmp = fcmp oeq float %f, 0xC1E0000000000000
349  ret i1 %cmp
350}
351
352; CHECK-LABEL: @i32_cast_cmp_oeq_int_i32imax_uitofp(
353; CHECK: uitofp
354; CHECK: fcmp oeq
355; CHECK-NEXT: ret
356define i1 @i32_cast_cmp_oeq_int_i32imax_uitofp(i32 %i) {
357  %f = uitofp i32 %i to float
358  %cmp = fcmp oeq float %f, 0x41E0000000000000
359  ret i1 %cmp
360}
361
362; CHECK-LABEL: @i32_cast_cmp_oeq_int_i32imax_sitofp(
363; CHECK: sitofp
364; CHECK: fcmp oeq
365; CHECK-NEXT: ret
366define i1 @i32_cast_cmp_oeq_int_i32imax_sitofp(i32 %i) {
367  %f = sitofp i32 %i to float
368  %cmp = fcmp oeq float %f, 0x41E0000000000000
369  ret i1 %cmp
370}
371
372; CHECK-LABEL: @i32_cast_cmp_oeq_int_negi32umax_uitofp(
373; CHECK: uitofp
374; CHECK: fcmp oeq
375; CHECK-NEXT: ret
376define i1 @i32_cast_cmp_oeq_int_negi32umax_uitofp(i32 %i) {
377  %f = uitofp i32 %i to float
378  %cmp = fcmp oeq float %f, 0xC1F0000000000000
379  ret i1 %cmp
380}
381
382; CHECK-LABEL: @i32_cast_cmp_oeq_int_negi32umax_sitofp(
383; CHECK: sitofp
384; CHECK: fcmp oeq
385; CHECK-NEXT: ret
386define i1 @i32_cast_cmp_oeq_int_negi32umax_sitofp(i32 %i) {
387  %f = sitofp i32 %i to float
388  %cmp = fcmp oeq float %f, 0xC1F0000000000000
389  ret i1 %cmp
390}
391
392; CHECK-LABEL: @i32_cast_cmp_oeq_half_uitofp(
393; CHECK: ret i1 false
394define i1 @i32_cast_cmp_oeq_half_uitofp(i32 %i) {
395  %f = uitofp i32 %i to float
396  %cmp = fcmp oeq float %f, 0.5
397  ret i1 %cmp
398}
399
400; CHECK-LABEL: @i32_cast_cmp_oeq_half_sitofp(
401; CHECK: ret i1 false
402define i1 @i32_cast_cmp_oeq_half_sitofp(i32 %i) {
403  %f = sitofp i32 %i to float
404  %cmp = fcmp oeq float %f, 0.5
405  ret i1 %cmp
406}
407
408; CHECK-LABEL: @i32_cast_cmp_one_half_uitofp(
409; CHECK: ret i1 true
410define i1 @i32_cast_cmp_one_half_uitofp(i32 %i) {
411  %f = uitofp i32 %i to float
412  %cmp = fcmp one float %f, 0.5
413  ret i1 %cmp
414}
415
416; CHECK-LABEL: @i32_cast_cmp_one_half_sitofp(
417; CHECK: ret i1 true
418define i1 @i32_cast_cmp_one_half_sitofp(i32 %i) {
419  %f = sitofp i32 %i to float
420  %cmp = fcmp one float %f, 0.5
421  ret i1 %cmp
422}
423
424; CHECK-LABEL: @i32_cast_cmp_ueq_half_uitofp(
425; CHECK: ret i1 false
426define i1 @i32_cast_cmp_ueq_half_uitofp(i32 %i) {
427  %f = uitofp i32 %i to float
428  %cmp = fcmp ueq float %f, 0.5
429  ret i1 %cmp
430}
431
432; CHECK-LABEL: @i32_cast_cmp_ueq_half_sitofp(
433; CHECK: ret i1 false
434define i1 @i32_cast_cmp_ueq_half_sitofp(i32 %i) {
435  %f = sitofp i32 %i to float
436  %cmp = fcmp ueq float %f, 0.5
437  ret i1 %cmp
438}
439
440; CHECK-LABEL: @i32_cast_cmp_une_half_uitofp(
441; CHECK: ret i1 true
442define i1 @i32_cast_cmp_une_half_uitofp(i32 %i) {
443  %f = uitofp i32 %i to float
444  %cmp = fcmp une float %f, 0.5
445  ret i1 %cmp
446}
447
448; CHECK-LABEL: @i32_cast_cmp_une_half_sitofp(
449; CHECK: ret i1 true
450define i1 @i32_cast_cmp_une_half_sitofp(i32 %i) {
451  %f = sitofp i32 %i to float
452  %cmp = fcmp une float %f, 0.5
453  ret i1 %cmp
454}
455