]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/InstCombine/amdgcn-intrinsics.ll
Vendor import of llvm trunk r291274:
[FreeBSD/FreeBSD.git] / test / Transforms / InstCombine / amdgcn-intrinsics.ll
1 ; RUN: opt -instcombine -S < %s | FileCheck %s
2
3 ; --------------------------------------------------------------------
4 ; llvm.amdgcn.rcp
5 ; --------------------------------------------------------------------
6
7 declare float @llvm.amdgcn.rcp.f32(float) nounwind readnone
8 declare double @llvm.amdgcn.rcp.f64(double) nounwind readnone
9
10
11 ; CHECK-LABEL: @test_constant_fold_rcp_f32_1
12 ; CHECK-NEXT: ret float 1.000000e+00
13 define float @test_constant_fold_rcp_f32_1() nounwind {
14   %val = call float @llvm.amdgcn.rcp.f32(float 1.0) nounwind readnone
15   ret float %val
16 }
17
18 ; CHECK-LABEL: @test_constant_fold_rcp_f64_1
19 ; CHECK-NEXT:  ret double 1.000000e+00
20 define double @test_constant_fold_rcp_f64_1() nounwind {
21   %val = call double @llvm.amdgcn.rcp.f64(double 1.0) nounwind readnone
22   ret double %val
23 }
24
25 ; CHECK-LABEL: @test_constant_fold_rcp_f32_half
26 ; CHECK-NEXT: ret float 2.000000e+00
27 define float @test_constant_fold_rcp_f32_half() nounwind {
28   %val = call float @llvm.amdgcn.rcp.f32(float 0.5) nounwind readnone
29   ret float %val
30 }
31
32 ; CHECK-LABEL: @test_constant_fold_rcp_f64_half
33 ; CHECK-NEXT:  ret double 2.000000e+00
34 define double @test_constant_fold_rcp_f64_half() nounwind {
35   %val = call double @llvm.amdgcn.rcp.f64(double 0.5) nounwind readnone
36   ret double %val
37 }
38
39 ; CHECK-LABEL: @test_constant_fold_rcp_f32_43
40 ; CHECK-NEXT: call float @llvm.amdgcn.rcp.f32(float 4.300000e+01)
41 define float @test_constant_fold_rcp_f32_43() nounwind {
42  %val = call float @llvm.amdgcn.rcp.f32(float 4.300000e+01) nounwind readnone
43  ret float %val
44 }
45
46 ; CHECK-LABEL: @test_constant_fold_rcp_f64_43
47 ; CHECK-NEXT: call double @llvm.amdgcn.rcp.f64(double 4.300000e+01)
48 define double @test_constant_fold_rcp_f64_43() nounwind {
49   %val = call double @llvm.amdgcn.rcp.f64(double 4.300000e+01) nounwind readnone
50   ret double %val
51 }
52
53
54 ; --------------------------------------------------------------------
55 ; llvm.amdgcn.frexp.mant
56 ; --------------------------------------------------------------------
57
58 declare float @llvm.amdgcn.frexp.mant.f32(float) nounwind readnone
59 declare double @llvm.amdgcn.frexp.mant.f64(double) nounwind readnone
60
61
62 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_undef(
63 ; CHECK-NEXT: ret float undef
64 define float @test_constant_fold_frexp_mant_f32_undef() nounwind {
65   %val = call float @llvm.amdgcn.frexp.mant.f32(float undef)
66   ret float %val
67 }
68
69 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_undef(
70 ; CHECK-NEXT:  ret double undef
71 define double @test_constant_fold_frexp_mant_f64_undef() nounwind {
72   %val = call double @llvm.amdgcn.frexp.mant.f64(double undef)
73   ret double %val
74 }
75
76 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_0(
77 ; CHECK-NEXT: ret float 0.000000e+00
78 define float @test_constant_fold_frexp_mant_f32_0() nounwind {
79   %val = call float @llvm.amdgcn.frexp.mant.f32(float 0.0)
80   ret float %val
81 }
82
83 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_0(
84 ; CHECK-NEXT:  ret double 0.000000e+00
85 define double @test_constant_fold_frexp_mant_f64_0() nounwind {
86   %val = call double @llvm.amdgcn.frexp.mant.f64(double 0.0)
87   ret double %val
88 }
89
90
91 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_n0(
92 ; CHECK-NEXT: ret float -0.000000e+00
93 define float @test_constant_fold_frexp_mant_f32_n0() nounwind {
94   %val = call float @llvm.amdgcn.frexp.mant.f32(float -0.0)
95   ret float %val
96 }
97
98 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_n0(
99 ; CHECK-NEXT:  ret double -0.000000e+00
100 define double @test_constant_fold_frexp_mant_f64_n0() nounwind {
101   %val = call double @llvm.amdgcn.frexp.mant.f64(double -0.0)
102   ret double %val
103 }
104
105 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_1(
106 ; CHECK-NEXT: ret float 5.000000e-01
107 define float @test_constant_fold_frexp_mant_f32_1() nounwind {
108   %val = call float @llvm.amdgcn.frexp.mant.f32(float 1.0)
109   ret float %val
110 }
111
112 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_1(
113 ; CHECK-NEXT:  ret double 5.000000e-01
114 define double @test_constant_fold_frexp_mant_f64_1() nounwind {
115   %val = call double @llvm.amdgcn.frexp.mant.f64(double 1.0)
116   ret double %val
117 }
118
119 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_n1(
120 ; CHECK-NEXT: ret float -5.000000e-01
121 define float @test_constant_fold_frexp_mant_f32_n1() nounwind {
122   %val = call float @llvm.amdgcn.frexp.mant.f32(float -1.0)
123   ret float %val
124 }
125
126 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_n1(
127 ; CHECK-NEXT:  ret double -5.000000e-01
128 define double @test_constant_fold_frexp_mant_f64_n1() nounwind {
129   %val = call double @llvm.amdgcn.frexp.mant.f64(double -1.0)
130   ret double %val
131 }
132
133 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_nan(
134 ; CHECK-NEXT: ret float 0x7FF8000000000000
135 define float @test_constant_fold_frexp_mant_f32_nan() nounwind {
136   %val = call float @llvm.amdgcn.frexp.mant.f32(float 0x7FF8000000000000)
137   ret float %val
138 }
139
140 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_nan(
141 ; CHECK-NEXT:  ret double 0x7FF8000000000000
142 define double @test_constant_fold_frexp_mant_f64_nan() nounwind {
143   %val = call double @llvm.amdgcn.frexp.mant.f64(double 0x7FF8000000000000)
144   ret double %val
145 }
146
147 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_inf(
148 ; CHECK-NEXT: ret float 0x7FF0000000000000
149 define float @test_constant_fold_frexp_mant_f32_inf() nounwind {
150   %val = call float @llvm.amdgcn.frexp.mant.f32(float 0x7FF0000000000000)
151   ret float %val
152 }
153
154 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_inf(
155 ; CHECK-NEXT:  ret double 0x7FF0000000000000
156 define double @test_constant_fold_frexp_mant_f64_inf() nounwind {
157   %val = call double @llvm.amdgcn.frexp.mant.f64(double 0x7FF0000000000000)
158   ret double %val
159 }
160
161 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_ninf(
162 ; CHECK-NEXT: ret float 0xFFF0000000000000
163 define float @test_constant_fold_frexp_mant_f32_ninf() nounwind {
164   %val = call float @llvm.amdgcn.frexp.mant.f32(float 0xFFF0000000000000)
165   ret float %val
166 }
167
168 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_ninf(
169 ; CHECK-NEXT:  ret double 0xFFF0000000000000
170 define double @test_constant_fold_frexp_mant_f64_ninf() nounwind {
171   %val = call double @llvm.amdgcn.frexp.mant.f64(double 0xFFF0000000000000)
172   ret double %val
173 }
174
175 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_max_num(
176 ; CHECK-NEXT: ret float 0x3FEFFFFFE0000000
177 define float @test_constant_fold_frexp_mant_f32_max_num() nounwind {
178   %val = call float @llvm.amdgcn.frexp.mant.f32(float 0x47EFFFFFE0000000)
179   ret float %val
180 }
181
182 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_max_num(
183 ; CHECK-NEXT:  ret double 0x3FEFFFFFFFFFFFFF
184 define double @test_constant_fold_frexp_mant_f64_max_num() nounwind {
185   %val = call double @llvm.amdgcn.frexp.mant.f64(double 0x7FEFFFFFFFFFFFFF)
186   ret double %val
187 }
188
189 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_min_num(
190 ; CHECK-NEXT: ret float 5.000000e-01
191 define float @test_constant_fold_frexp_mant_f32_min_num() nounwind {
192   %val = call float @llvm.amdgcn.frexp.mant.f32(float 0x36A0000000000000)
193   ret float %val
194 }
195
196 ; CHECK-LABEL: @test_constant_fold_frexp_mant_f64_min_num(
197 ; CHECK-NEXT:  ret double 5.000000e-01
198 define double @test_constant_fold_frexp_mant_f64_min_num() nounwind {
199   %val = call double @llvm.amdgcn.frexp.mant.f64(double 4.940656e-324)
200   ret double %val
201 }
202
203
204 ; --------------------------------------------------------------------
205 ; llvm.amdgcn.frexp.exp
206 ; --------------------------------------------------------------------
207
208 declare i32 @llvm.amdgcn.frexp.exp.f32(float) nounwind readnone
209 declare i32 @llvm.amdgcn.frexp.exp.f64(double) nounwind readnone
210
211 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_undef(
212 ; CHECK-NEXT: ret i32 undef
213 define i32 @test_constant_fold_frexp_exp_f32_undef() nounwind {
214   %val = call i32 @llvm.amdgcn.frexp.exp.f32(float undef)
215   ret i32 %val
216 }
217
218 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_undef(
219 ; CHECK-NEXT:  ret i32 undef
220 define i32 @test_constant_fold_frexp_exp_f64_undef() nounwind {
221   %val = call i32 @llvm.amdgcn.frexp.exp.f64(double undef)
222   ret i32 %val
223 }
224
225 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_0(
226 ; CHECK-NEXT: ret i32 0
227 define i32 @test_constant_fold_frexp_exp_f32_0() nounwind {
228   %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0.0)
229   ret i32 %val
230 }
231
232 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_0(
233 ; CHECK-NEXT:  ret i32 0
234 define i32 @test_constant_fold_frexp_exp_f64_0() nounwind {
235   %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 0.0)
236   ret i32 %val
237 }
238
239 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_n0(
240 ; CHECK-NEXT: ret i32 0
241 define i32 @test_constant_fold_frexp_exp_f32_n0() nounwind {
242   %val = call i32 @llvm.amdgcn.frexp.exp.f32(float -0.0)
243   ret i32 %val
244 }
245
246 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_n0(
247 ; CHECK-NEXT:  ret i32 0
248 define i32 @test_constant_fold_frexp_exp_f64_n0() nounwind {
249   %val = call i32 @llvm.amdgcn.frexp.exp.f64(double -0.0)
250   ret i32 %val
251 }
252
253 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_1024(
254 ; CHECK-NEXT: ret i32 11
255 define i32 @test_constant_fold_frexp_exp_f32_1024() nounwind {
256   %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 1024.0)
257   ret i32 %val
258 }
259
260 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_1024(
261 ; CHECK-NEXT:  ret i32 11
262 define i32 @test_constant_fold_frexp_exp_f64_1024() nounwind {
263   %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 1024.0)
264   ret i32 %val
265 }
266
267 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_n1024(
268 ; CHECK-NEXT: ret i32 11
269 define i32 @test_constant_fold_frexp_exp_f32_n1024() nounwind {
270   %val = call i32 @llvm.amdgcn.frexp.exp.f32(float -1024.0)
271   ret i32 %val
272 }
273
274 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_n1024(
275 ; CHECK-NEXT:  ret i32 11
276 define i32 @test_constant_fold_frexp_exp_f64_n1024() nounwind {
277   %val = call i32 @llvm.amdgcn.frexp.exp.f64(double -1024.0)
278   ret i32 %val
279 }
280
281 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_1_1024(
282 ; CHECK-NEXT: ret i32 -9
283 define i32 @test_constant_fold_frexp_exp_f32_1_1024() nounwind {
284   %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0.0009765625)
285   ret i32 %val
286 }
287
288 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_1_1024(
289 ; CHECK-NEXT:  ret i32 -9
290 define i32 @test_constant_fold_frexp_exp_f64_1_1024() nounwind {
291   %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 0.0009765625)
292   ret i32 %val
293 }
294
295 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_nan(
296 ; CHECK-NEXT: ret i32 0
297 define i32 @test_constant_fold_frexp_exp_f32_nan() nounwind {
298   %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0x7FF8000000000000)
299   ret i32 %val
300 }
301
302 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_nan(
303 ; CHECK-NEXT:  ret i32 0
304 define i32 @test_constant_fold_frexp_exp_f64_nan() nounwind {
305   %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 0x7FF8000000000000)
306   ret i32 %val
307 }
308
309 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_inf(
310 ; CHECK-NEXT: ret i32 0
311 define i32 @test_constant_fold_frexp_exp_f32_inf() nounwind {
312   %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0x7FF0000000000000)
313   ret i32 %val
314 }
315
316 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_inf(
317 ; CHECK-NEXT:  ret i32 0
318 define i32 @test_constant_fold_frexp_exp_f64_inf() nounwind {
319   %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 0x7FF0000000000000)
320   ret i32 %val
321 }
322
323 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_ninf(
324 ; CHECK-NEXT: ret i32 0
325 define i32 @test_constant_fold_frexp_exp_f32_ninf() nounwind {
326   %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0xFFF0000000000000)
327   ret i32 %val
328 }
329
330 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_ninf(
331 ; CHECK-NEXT:  ret i32 0
332 define i32 @test_constant_fold_frexp_exp_f64_ninf() nounwind {
333   %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 0xFFF0000000000000)
334   ret i32 %val
335 }
336
337 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_max_num(
338 ; CHECK-NEXT: ret i32 128
339 define i32 @test_constant_fold_frexp_exp_f32_max_num() nounwind {
340   %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0x47EFFFFFE0000000)
341   ret i32 %val
342 }
343
344 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_max_num(
345 ; CHECK-NEXT:  ret i32 1024
346 define i32 @test_constant_fold_frexp_exp_f64_max_num() nounwind {
347   %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 0x7FEFFFFFFFFFFFFF)
348   ret i32 %val
349 }
350
351 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_min_num(
352 ; CHECK-NEXT: ret i32 -148
353 define i32 @test_constant_fold_frexp_exp_f32_min_num() nounwind {
354   %val = call i32 @llvm.amdgcn.frexp.exp.f32(float 0x36A0000000000000)
355   ret i32 %val
356 }
357
358 ; CHECK-LABEL: @test_constant_fold_frexp_exp_f64_min_num(
359 ; CHECK-NEXT:  ret i32 -1073
360 define i32 @test_constant_fold_frexp_exp_f64_min_num() nounwind {
361   %val = call i32 @llvm.amdgcn.frexp.exp.f64(double 4.940656e-324)
362   ret i32 %val
363 }
364
365 ; --------------------------------------------------------------------
366 ; llvm.amdgcn.class
367 ; --------------------------------------------------------------------
368
369 declare i1 @llvm.amdgcn.class.f32(float, i32) nounwind readnone
370 declare i1 @llvm.amdgcn.class.f64(double, i32) nounwind readnone
371
372 ; CHECK-LABEL: @test_class_undef_mask_f32(
373 ; CHECK: ret i1 false
374 define i1 @test_class_undef_mask_f32(float %x) nounwind {
375   %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 undef)
376   ret i1 %val
377 }
378
379 ; CHECK-LABEL: @test_class_over_max_mask_f32(
380 ; CHECK: %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 1)
381 define i1 @test_class_over_max_mask_f32(float %x) nounwind {
382   %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 1025)
383   ret i1 %val
384 }
385
386 ; CHECK-LABEL: @test_class_no_mask_f32(
387 ; CHECK: ret i1 false
388 define i1 @test_class_no_mask_f32(float %x) nounwind {
389   %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 0)
390   ret i1 %val
391 }
392
393 ; CHECK-LABEL: @test_class_full_mask_f32(
394 ; CHECK: ret i1 true
395 define i1 @test_class_full_mask_f32(float %x) nounwind {
396   %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 1023)
397   ret i1 %val
398 }
399
400 ; CHECK-LABEL: @test_class_undef_no_mask_f32(
401 ; CHECK: ret i1 false
402 define i1 @test_class_undef_no_mask_f32() nounwind {
403   %val = call i1 @llvm.amdgcn.class.f32(float undef, i32 0)
404   ret i1 %val
405 }
406
407 ; CHECK-LABEL: @test_class_undef_full_mask_f32(
408 ; CHECK: ret i1 true
409 define i1 @test_class_undef_full_mask_f32() nounwind {
410   %val = call i1 @llvm.amdgcn.class.f32(float undef, i32 1023)
411   ret i1 %val
412 }
413
414 ; CHECK-LABEL: @test_class_undef_val_f32(
415 ; CHECK: ret i1 undef
416 define i1 @test_class_undef_val_f32() nounwind {
417   %val = call i1 @llvm.amdgcn.class.f32(float undef, i32 4)
418   ret i1 %val
419 }
420
421 ; CHECK-LABEL: @test_class_undef_undef_f32(
422 ; CHECK: ret i1 undef
423 define i1 @test_class_undef_undef_f32() nounwind {
424   %val = call i1 @llvm.amdgcn.class.f32(float undef, i32 undef)
425   ret i1 %val
426 }
427
428 ; CHECK-LABEL: @test_class_var_mask_f32(
429 ; CHECK: %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 %mask)
430 define i1 @test_class_var_mask_f32(float %x, i32 %mask) nounwind {
431   %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 %mask)
432   ret i1 %val
433 }
434
435 ; CHECK-LABEL: @test_class_isnan_f32(
436 ; CHECK: %val = fcmp uno float %x, 0.000000e+00
437 define i1 @test_class_isnan_f32(float %x) nounwind {
438   %val = call i1 @llvm.amdgcn.class.f32(float %x, i32 3)
439   ret i1 %val
440 }
441
442 ; CHECK-LABEL: @test_constant_class_snan_test_snan_f64(
443 ; CHECK: ret i1 true
444 define i1 @test_constant_class_snan_test_snan_f64() nounwind {
445   %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF0000000000001, i32 1)
446   ret i1 %val
447 }
448
449 ; CHECK-LABEL: @test_constant_class_qnan_test_qnan_f64(
450 ; CHECK: ret i1 true
451 define i1 @test_constant_class_qnan_test_qnan_f64() nounwind {
452   %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF8000000000000, i32 2)
453   ret i1 %val
454 }
455
456 ; CHECK-LABEL: @test_constant_class_qnan_test_snan_f64(
457 ; CHECK: ret i1 false
458 define i1 @test_constant_class_qnan_test_snan_f64() nounwind {
459   %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF8000000000000, i32 1)
460   ret i1 %val
461 }
462
463 ; CHECK-LABEL: @test_constant_class_ninf_test_ninf_f64(
464 ; CHECK: ret i1 true
465 define i1 @test_constant_class_ninf_test_ninf_f64() nounwind {
466   %val = call i1 @llvm.amdgcn.class.f64(double 0xFFF0000000000000, i32 4)
467   ret i1 %val
468 }
469
470 ; CHECK-LABEL: @test_constant_class_pinf_test_ninf_f64(
471 ; CHECK: ret i1 false
472 define i1 @test_constant_class_pinf_test_ninf_f64() nounwind {
473   %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF0000000000000, i32 4)
474   ret i1 %val
475 }
476
477 ; CHECK-LABEL: @test_constant_class_qnan_test_ninf_f64(
478 ; CHECK: ret i1 false
479 define i1 @test_constant_class_qnan_test_ninf_f64() nounwind {
480   %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF8000000000000, i32 4)
481   ret i1 %val
482 }
483
484 ; CHECK-LABEL: @test_constant_class_snan_test_ninf_f64(
485 ; CHECK: ret i1 false
486 define i1 @test_constant_class_snan_test_ninf_f64() nounwind {
487   %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF0000000000001, i32 4)
488   ret i1 %val
489 }
490
491 ; CHECK-LABEL: @test_constant_class_nnormal_test_nnormal_f64(
492 ; CHECK: ret i1 true
493 define i1 @test_constant_class_nnormal_test_nnormal_f64() nounwind {
494   %val = call i1 @llvm.amdgcn.class.f64(double -1.0, i32 8)
495   ret i1 %val
496 }
497
498 ; CHECK-LABEL: @test_constant_class_pnormal_test_nnormal_f64(
499 ; CHECK: ret i1 false
500 define i1 @test_constant_class_pnormal_test_nnormal_f64() nounwind {
501   %val = call i1 @llvm.amdgcn.class.f64(double 1.0, i32 8)
502   ret i1 %val
503 }
504
505 ; CHECK-LABEL: @test_constant_class_nsubnormal_test_nsubnormal_f64(
506 ; CHECK: ret i1 true
507 define i1 @test_constant_class_nsubnormal_test_nsubnormal_f64() nounwind {
508   %val = call i1 @llvm.amdgcn.class.f64(double 0x800fffffffffffff, i32 16)
509   ret i1 %val
510 }
511
512 ; CHECK-LABEL: @test_constant_class_psubnormal_test_nsubnormal_f64(
513 ; CHECK: ret i1 false
514 define i1 @test_constant_class_psubnormal_test_nsubnormal_f64() nounwind {
515   %val = call i1 @llvm.amdgcn.class.f64(double 0x000fffffffffffff, i32 16)
516   ret i1 %val
517 }
518
519 ; CHECK-LABEL: @test_constant_class_nzero_test_nzero_f64(
520 ; CHECK: ret i1 true
521 define i1 @test_constant_class_nzero_test_nzero_f64() nounwind {
522   %val = call i1 @llvm.amdgcn.class.f64(double -0.0, i32 32)
523   ret i1 %val
524 }
525
526 ; CHECK-LABEL: @test_constant_class_pzero_test_nzero_f64(
527 ; CHECK: ret i1 false
528 define i1 @test_constant_class_pzero_test_nzero_f64() nounwind {
529   %val = call i1 @llvm.amdgcn.class.f64(double 0.0, i32 32)
530   ret i1 %val
531 }
532
533 ; CHECK-LABEL: @test_constant_class_pzero_test_pzero_f64(
534 ; CHECK: ret i1 true
535 define i1 @test_constant_class_pzero_test_pzero_f64() nounwind {
536   %val = call i1 @llvm.amdgcn.class.f64(double 0.0, i32 64)
537   ret i1 %val
538 }
539
540 ; CHECK-LABEL: @test_constant_class_nzero_test_pzero_f64(
541 ; CHECK: ret i1 false
542 define i1 @test_constant_class_nzero_test_pzero_f64() nounwind {
543   %val = call i1 @llvm.amdgcn.class.f64(double -0.0, i32 64)
544   ret i1 %val
545 }
546
547 ; CHECK-LABEL: @test_constant_class_psubnormal_test_psubnormal_f64(
548 ; CHECK: ret i1 true
549 define i1 @test_constant_class_psubnormal_test_psubnormal_f64() nounwind {
550   %val = call i1 @llvm.amdgcn.class.f64(double 0x000fffffffffffff, i32 128)
551   ret i1 %val
552 }
553
554 ; CHECK-LABEL: @test_constant_class_nsubnormal_test_psubnormal_f64(
555 ; CHECK: ret i1 false
556 define i1 @test_constant_class_nsubnormal_test_psubnormal_f64() nounwind {
557   %val = call i1 @llvm.amdgcn.class.f64(double 0x800fffffffffffff, i32 128)
558   ret i1 %val
559 }
560
561 ; CHECK-LABEL: @test_constant_class_pnormal_test_pnormal_f64(
562 ; CHECK: ret i1 true
563 define i1 @test_constant_class_pnormal_test_pnormal_f64() nounwind {
564   %val = call i1 @llvm.amdgcn.class.f64(double 1.0, i32 256)
565   ret i1 %val
566 }
567
568 ; CHECK-LABEL: @test_constant_class_nnormal_test_pnormal_f64(
569 ; CHECK: ret i1 false
570 define i1 @test_constant_class_nnormal_test_pnormal_f64() nounwind {
571   %val = call i1 @llvm.amdgcn.class.f64(double -1.0, i32 256)
572   ret i1 %val
573 }
574
575 ; CHECK-LABEL: @test_constant_class_pinf_test_pinf_f64(
576 ; CHECK: ret i1 true
577 define i1 @test_constant_class_pinf_test_pinf_f64() nounwind {
578   %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF0000000000000, i32 512)
579   ret i1 %val
580 }
581
582 ; CHECK-LABEL: @test_constant_class_ninf_test_pinf_f64(
583 ; CHECK: ret i1 false
584 define i1 @test_constant_class_ninf_test_pinf_f64() nounwind {
585   %val = call i1 @llvm.amdgcn.class.f64(double 0xFFF0000000000000, i32 512)
586   ret i1 %val
587 }
588
589 ; CHECK-LABEL: @test_constant_class_qnan_test_pinf_f64(
590 ; CHECK: ret i1 false
591 define i1 @test_constant_class_qnan_test_pinf_f64() nounwind {
592   %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF8000000000000, i32 512)
593   ret i1 %val
594 }
595
596 ; CHECK-LABEL: @test_constant_class_snan_test_pinf_f64(
597 ; CHECK: ret i1 false
598 define i1 @test_constant_class_snan_test_pinf_f64() nounwind {
599   %val = call i1 @llvm.amdgcn.class.f64(double 0x7FF0000000000001, i32 512)
600   ret i1 %val
601 }
602
603 ; --------------------------------------------------------------------
604 ; llvm.amdgcn.cos
605 ; --------------------------------------------------------------------
606 declare float @llvm.amdgcn.cos.f32(float) nounwind readnone
607 declare float @llvm.fabs.f32(float) nounwind readnone
608
609 ; CHECK-LABEL: @cos_fneg_f32(
610 ; CHECK: %cos = call float @llvm.amdgcn.cos.f32(float %x)
611 ; CHECK-NEXT: ret float %cos
612 define float @cos_fneg_f32(float %x) {
613   %x.fneg = fsub float -0.0, %x
614   %cos = call float @llvm.amdgcn.cos.f32(float %x.fneg)
615   ret float %cos
616 }
617
618 ; CHECK-LABEL: @cos_fabs_f32(
619 ; CHECK-NEXT: %cos = call float @llvm.amdgcn.cos.f32(float %x)
620 ; CHECK-NEXT: ret float %cos
621 define float @cos_fabs_f32(float %x) {
622   %x.fabs = call float @llvm.fabs.f32(float %x)
623   %cos = call float @llvm.amdgcn.cos.f32(float %x.fabs)
624   ret float %cos
625 }
626
627 ; CHECK-LABEL: @cos_fabs_fneg_f32(
628 ; CHECK-NEXT: %cos = call float @llvm.amdgcn.cos.f32(float %x)
629 ; CHECK-NEXT: ret float %cos
630 define float @cos_fabs_fneg_f32(float %x) {
631   %x.fabs = call float @llvm.fabs.f32(float %x)
632   %x.fabs.fneg = fsub float -0.0, %x.fabs
633   %cos = call float @llvm.amdgcn.cos.f32(float %x.fabs.fneg)
634   ret float %cos
635 }