1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
4 define float @fadd_undef_op0(float %x) {
5 ; CHECK-LABEL: @fadd_undef_op0(
6 ; CHECK-NEXT: ret float 0x7FF8000000000000
8 %r = fadd float undef, %x
12 define float @fadd_undef_op1(float %x) {
13 ; CHECK-LABEL: @fadd_undef_op1(
14 ; CHECK-NEXT: ret float 0x7FF8000000000000
16 %r = fadd float %x, undef
20 define float @fsub_undef_op0(float %x) {
21 ; CHECK-LABEL: @fsub_undef_op0(
22 ; CHECK-NEXT: ret float 0x7FF8000000000000
24 %r = fsub float undef, %x
28 define float @fsub_undef_op1(float %x) {
29 ; CHECK-LABEL: @fsub_undef_op1(
30 ; CHECK-NEXT: ret float 0x7FF8000000000000
32 %r = fsub float %x, undef
36 define float @fmul_undef_op0(float %x) {
37 ; CHECK-LABEL: @fmul_undef_op0(
38 ; CHECK-NEXT: ret float 0x7FF8000000000000
40 %r = fmul float undef, %x
44 define float @fmul_undef_op1(float %x) {
45 ; CHECK-LABEL: @fmul_undef_op1(
46 ; CHECK-NEXT: ret float 0x7FF8000000000000
48 %r = fmul float %x, undef
52 define float @fdiv_undef_op0(float %x) {
53 ; CHECK-LABEL: @fdiv_undef_op0(
54 ; CHECK-NEXT: ret float 0x7FF8000000000000
56 %r = fdiv float undef, %x
60 define float @fdiv_undef_op1(float %x) {
61 ; CHECK-LABEL: @fdiv_undef_op1(
62 ; CHECK-NEXT: ret float 0x7FF8000000000000
64 %r = fdiv float %x, undef
68 define float @frem_undef_op0(float %x) {
69 ; CHECK-LABEL: @frem_undef_op0(
70 ; CHECK-NEXT: ret float 0x7FF8000000000000
72 %r = frem float undef, %x
76 define float @frem_undef_op1(float %x) {
77 ; CHECK-LABEL: @frem_undef_op1(
78 ; CHECK-NEXT: ret float 0x7FF8000000000000
80 %r = frem float %x, undef
84 ; Repeat all tests with fast-math-flags. Alternate 'nnan' and 'fast' for more coverage.
86 define float @fadd_undef_op0_nnan(float %x) {
87 ; CHECK-LABEL: @fadd_undef_op0_nnan(
88 ; CHECK-NEXT: ret float 0x7FF8000000000000
90 %r = fadd nnan float undef, %x
94 define float @fadd_undef_op1_fast(float %x) {
95 ; CHECK-LABEL: @fadd_undef_op1_fast(
96 ; CHECK-NEXT: ret float 0x7FF8000000000000
98 %r = fadd fast float %x, undef
102 define float @fsub_undef_op0_fast(float %x) {
103 ; CHECK-LABEL: @fsub_undef_op0_fast(
104 ; CHECK-NEXT: ret float 0x7FF8000000000000
106 %r = fsub fast float undef, %x
110 define float @fsub_undef_op1_nnan(float %x) {
111 ; CHECK-LABEL: @fsub_undef_op1_nnan(
112 ; CHECK-NEXT: ret float 0x7FF8000000000000
114 %r = fsub nnan float %x, undef
118 define float @fmul_undef_op0_nnan(float %x) {
119 ; CHECK-LABEL: @fmul_undef_op0_nnan(
120 ; CHECK-NEXT: ret float 0x7FF8000000000000
122 %r = fmul nnan float undef, %x
126 define float @fmul_undef_op1_fast(float %x) {
127 ; CHECK-LABEL: @fmul_undef_op1_fast(
128 ; CHECK-NEXT: ret float 0x7FF8000000000000
130 %r = fmul fast float %x, undef
134 define float @fdiv_undef_op0_fast(float %x) {
135 ; CHECK-LABEL: @fdiv_undef_op0_fast(
136 ; CHECK-NEXT: ret float 0x7FF8000000000000
138 %r = fdiv fast float undef, %x
142 define float @fdiv_undef_op1_nnan(float %x) {
143 ; CHECK-LABEL: @fdiv_undef_op1_nnan(
144 ; CHECK-NEXT: ret float 0x7FF8000000000000
146 %r = fdiv nnan float %x, undef
150 define float @frem_undef_op0_nnan(float %x) {
151 ; CHECK-LABEL: @frem_undef_op0_nnan(
152 ; CHECK-NEXT: ret float 0x7FF8000000000000
154 %r = frem nnan float undef, %x
158 define float @frem_undef_op1_fast(float %x) {
159 ; CHECK-LABEL: @frem_undef_op1_fast(
160 ; CHECK-NEXT: ret float 0x7FF8000000000000
162 %r = frem fast float %x, undef
166 ; Constant folding - undef undef.
168 define double @fadd_undef_undef(double %x) {
169 ; CHECK-LABEL: @fadd_undef_undef(
170 ; CHECK-NEXT: ret double undef
172 %r = fadd double undef, undef
176 define double @fsub_undef_undef(double %x) {
177 ; CHECK-LABEL: @fsub_undef_undef(
178 ; CHECK-NEXT: ret double undef
180 %r = fsub double undef, undef
184 define double @fmul_undef_undef(double %x) {
185 ; CHECK-LABEL: @fmul_undef_undef(
186 ; CHECK-NEXT: ret double undef
188 %r = fmul double undef, undef
192 define double @fdiv_undef_undef(double %x) {
193 ; CHECK-LABEL: @fdiv_undef_undef(
194 ; CHECK-NEXT: ret double undef
196 %r = fdiv double undef, undef
200 define double @frem_undef_undef(double %x) {
201 ; CHECK-LABEL: @frem_undef_undef(
202 ; CHECK-NEXT: ret double undef
204 %r = frem double undef, undef
210 define float @fadd_undef_op0_nnan_constant(float %x) {
211 ; CHECK-LABEL: @fadd_undef_op0_nnan_constant(
212 ; CHECK-NEXT: ret float 0x7FF8000000000000
214 %r = fadd nnan float undef, 1.0
218 define float @fadd_undef_op1_constant(float %x) {
219 ; CHECK-LABEL: @fadd_undef_op1_constant(
220 ; CHECK-NEXT: ret float 0x7FF8000000000000
222 %r = fadd float 2.0, undef
226 define float @fsub_undef_op0_fast_constant(float %x) {
227 ; CHECK-LABEL: @fsub_undef_op0_fast_constant(
228 ; CHECK-NEXT: ret float 0x7FF8000000000000
230 %r = fsub fast float undef, 3.0
234 define float @fsub_undef_op1_constant(float %x) {
235 ; CHECK-LABEL: @fsub_undef_op1_constant(
236 ; CHECK-NEXT: ret float 0x7FF8000000000000
238 %r = fsub float 4.0, undef
242 define float @fmul_undef_op0_nnan_constant(float %x) {
243 ; CHECK-LABEL: @fmul_undef_op0_nnan_constant(
244 ; CHECK-NEXT: ret float 0x7FF8000000000000
246 %r = fmul nnan float undef, 5.0
250 define float @fmul_undef_op1_constant(float %x) {
251 ; CHECK-LABEL: @fmul_undef_op1_constant(
252 ; CHECK-NEXT: ret float 0x7FF8000000000000
254 %r = fmul float 6.0, undef
258 define float @fdiv_undef_op0_fast_constant(float %x) {
259 ; CHECK-LABEL: @fdiv_undef_op0_fast_constant(
260 ; CHECK-NEXT: ret float 0x7FF8000000000000
262 %r = fdiv fast float undef, 7.0
266 define float @fdiv_undef_op1_constant(float %x) {
267 ; CHECK-LABEL: @fdiv_undef_op1_constant(
268 ; CHECK-NEXT: ret float 0x7FF8000000000000
270 %r = fdiv float 8.0, undef
274 define float @frem_undef_op0_nnan_constant(float %x) {
275 ; CHECK-LABEL: @frem_undef_op0_nnan_constant(
276 ; CHECK-NEXT: ret float 0x7FF8000000000000
278 %r = frem nnan float undef, 9.0
282 define float @frem_undef_op1_constant(float %x) {
283 ; CHECK-LABEL: @frem_undef_op1_constant(
284 ; CHECK-NEXT: ret float 0x7FF8000000000000
286 %r = frem float 10.0, undef
290 ; Constant folding - special constants: NaN.
292 define double @fadd_undef_op0_constant_nan(double %x) {
293 ; CHECK-LABEL: @fadd_undef_op0_constant_nan(
294 ; CHECK-NEXT: ret double 0x7FF8000000000000
296 %r = fadd double undef, 0x7FF8000000000000
300 define double @fadd_undef_op1_fast_constant_nan(double %x) {
301 ; CHECK-LABEL: @fadd_undef_op1_fast_constant_nan(
302 ; CHECK-NEXT: ret double 0x7FF8000000000000
304 %r = fadd fast double 0xFFF0000000000001, undef
308 define double @fsub_undef_op0_constant_nan(double %x) {
309 ; CHECK-LABEL: @fsub_undef_op0_constant_nan(
310 ; CHECK-NEXT: ret double 0x7FF8000000000000
312 %r = fsub double undef, 0xFFF8000000000010
316 define double @fsub_undef_op1_nnan_constant_nan(double %x) {
317 ; CHECK-LABEL: @fsub_undef_op1_nnan_constant_nan(
318 ; CHECK-NEXT: ret double 0x7FF8000000000000
320 %r = fsub nnan double 0x7FF0000000000011, undef
324 define double @fmul_undef_op0_constant_nan(double %x) {
325 ; CHECK-LABEL: @fmul_undef_op0_constant_nan(
326 ; CHECK-NEXT: ret double 0x7FF8000000000000
328 %r = fmul double undef, 0x7FF8000000000100
332 define double @fmul_undef_op1_fast_constant_nan(double %x) {
333 ; CHECK-LABEL: @fmul_undef_op1_fast_constant_nan(
334 ; CHECK-NEXT: ret double 0x7FF8000000000000
336 %r = fmul fast double 0xFFF0000000000101, undef
340 define double @fdiv_undef_op0_constant_nan(double %x) {
341 ; CHECK-LABEL: @fdiv_undef_op0_constant_nan(
342 ; CHECK-NEXT: ret double 0x7FF8000000000000
344 %r = fdiv double undef, 0xFFF8000000000110
348 define double @fdiv_undef_op1_nnan_constant_nan(double %x) {
349 ; CHECK-LABEL: @fdiv_undef_op1_nnan_constant_nan(
350 ; CHECK-NEXT: ret double 0x7FF8000000000000
352 %r = fdiv nnan double 0x7FF0000000000111, undef
356 define double @frem_undef_op0_constant_nan(double %x) {
357 ; CHECK-LABEL: @frem_undef_op0_constant_nan(
358 ; CHECK-NEXT: ret double 0x7FF8000000000000
360 %r = frem double undef, 0x7FF8000000001000
364 define double @frem_undef_op1_fast_constant_nan(double %x) {
365 ; CHECK-LABEL: @frem_undef_op1_fast_constant_nan(
366 ; CHECK-NEXT: ret double 0x7FF8000000000000
368 %r = frem fast double 0xFFF0000000001001, undef
372 ; Constant folding - special constants: Inf.
374 define double @fadd_undef_op0_constant_inf(double %x) {
375 ; CHECK-LABEL: @fadd_undef_op0_constant_inf(
376 ; CHECK-NEXT: ret double 0x7FF8000000000000
378 %r = fadd double undef, 0x7FF0000000000000
382 define double @fadd_undef_op1_fast_constant_inf(double %x) {
383 ; CHECK-LABEL: @fadd_undef_op1_fast_constant_inf(
384 ; CHECK-NEXT: ret double 0x7FF8000000000000
386 %r = fadd fast double 0xFFF0000000000000, undef
390 define double @fsub_undef_op0_constant_inf(double %x) {
391 ; CHECK-LABEL: @fsub_undef_op0_constant_inf(
392 ; CHECK-NEXT: ret double 0x7FF8000000000000
394 %r = fsub double undef, 0xFFF0000000000000
398 define double @fsub_undef_op1_ninf_constant_inf(double %x) {
399 ; CHECK-LABEL: @fsub_undef_op1_ninf_constant_inf(
400 ; CHECK-NEXT: ret double 0x7FF8000000000000
402 %r = fsub ninf double 0x7FF0000000000000, undef
406 define double @fmul_undef_op0_constant_inf(double %x) {
407 ; CHECK-LABEL: @fmul_undef_op0_constant_inf(
408 ; CHECK-NEXT: ret double 0x7FF8000000000000
410 %r = fmul double undef, 0x7FF0000000000000
414 define double @fmul_undef_op1_fast_constant_inf(double %x) {
415 ; CHECK-LABEL: @fmul_undef_op1_fast_constant_inf(
416 ; CHECK-NEXT: ret double 0x7FF8000000000000
418 %r = fmul fast double 0xFFF0000000000000, undef
422 define double @fdiv_undef_op0_constant_inf(double %x) {
423 ; CHECK-LABEL: @fdiv_undef_op0_constant_inf(
424 ; CHECK-NEXT: ret double 0x7FF8000000000000
426 %r = fdiv double undef, 0xFFF0000000000000
430 define double @fdiv_undef_op1_ninf_constant_inf(double %x) {
431 ; CHECK-LABEL: @fdiv_undef_op1_ninf_constant_inf(
432 ; CHECK-NEXT: ret double 0x7FF8000000000000
434 %r = fdiv ninf double 0x7FF0000000000000, undef
438 define double @frem_undef_op0_constant_inf(double %x) {
439 ; CHECK-LABEL: @frem_undef_op0_constant_inf(
440 ; CHECK-NEXT: ret double 0x7FF8000000000000
442 %r = frem double undef, 0x7FF0000000000000
446 define double @frem_undef_op1_fast_constant_inf(double %x) {
447 ; CHECK-LABEL: @frem_undef_op1_fast_constant_inf(
448 ; CHECK-NEXT: ret double 0x7FF8000000000000
450 %r = frem fast double 0xFFF0000000000000, undef
454 define <2 x double> @fadd_undef_op1_constant_vec(<2 x double> %x) {
455 ; CHECK-LABEL: @fadd_undef_op1_constant_vec(
456 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
458 %r = fadd <2 x double> <double 42.0, double undef>, undef
462 define <2 x double> @fadd_undef_op0_constant_vec(<2 x double> %x) {
463 ; CHECK-LABEL: @fadd_undef_op0_constant_vec(
464 ; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000>
466 %r = fadd <2 x double> undef, <double undef, double 42.0>
470 define <2 x double> @fsub_undef_op1_constant_vec(<2 x double> %x) {
471 ; CHECK-LABEL: @fsub_undef_op1_constant_vec(
472 ; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000>
474 %r = fsub <2 x double> <double undef, double 42.0>, undef
478 define <2 x double> @fsub_undef_op0_constant_vec(<2 x double> %x) {
479 ; CHECK-LABEL: @fsub_undef_op0_constant_vec(
480 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
482 %r = fsub <2 x double> undef, <double 42.0, double undef>
486 define <2 x double> @fmul_undef_op1_constant_vec(<2 x double> %x) {
487 ; CHECK-LABEL: @fmul_undef_op1_constant_vec(
488 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
490 %r = fmul <2 x double> <double 42.0, double undef>, undef
494 define <2 x double> @fmul_undef_op0_constant_vec(<2 x double> %x) {
495 ; CHECK-LABEL: @fmul_undef_op0_constant_vec(
496 ; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000>
498 %r = fmul <2 x double> undef, <double undef, double 42.0>
502 define <2 x double> @fdiv_undef_op1_constant_vec(<2 x double> %x) {
503 ; CHECK-LABEL: @fdiv_undef_op1_constant_vec(
504 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
506 %r = fdiv <2 x double> <double 42.0, double undef>, undef
510 define <2 x double> @fdiv_undef_op0_constant_vec(<2 x double> %x) {
511 ; CHECK-LABEL: @fdiv_undef_op0_constant_vec(
512 ; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000>
514 %r = fdiv <2 x double> undef, <double undef, double 42.0>
518 define <2 x double> @frem_undef_op1_constant_vec(<2 x double> %x) {
519 ; CHECK-LABEL: @frem_undef_op1_constant_vec(
520 ; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000>
522 %r = frem <2 x double> <double undef, double 42.0>, undef
526 define <2 x double> @frem_undef_op0_constant_vec(<2 x double> %x) {
527 ; CHECK-LABEL: @frem_undef_op0_constant_vec(
528 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
530 %r = frem <2 x double> undef, <double 42.0, double undef>