1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
4 declare <2 x double> @llvm.minnum.v2f64(<2 x double>, <2 x double>)
5 declare <2 x double> @llvm.maxnum.v2f64(<2 x double>, <2 x double>)
6 declare <2 x double> @llvm.minimum.v2f64(<2 x double>, <2 x double>)
7 declare <2 x double> @llvm.maximum.v2f64(<2 x double>, <2 x double>)
9 ; Constant folding - undef undef.
11 define double @fadd_undef_undef(double %x) {
12 ; CHECK-LABEL: @fadd_undef_undef(
13 ; CHECK-NEXT: ret double undef
15 %r = fadd double undef, undef
19 define double @fsub_undef_undef(double %x) {
20 ; CHECK-LABEL: @fsub_undef_undef(
21 ; CHECK-NEXT: ret double undef
23 %r = fsub double undef, undef
27 define double @fmul_undef_undef(double %x) {
28 ; CHECK-LABEL: @fmul_undef_undef(
29 ; CHECK-NEXT: ret double undef
31 %r = fmul double undef, undef
35 define double @fdiv_undef_undef(double %x) {
36 ; CHECK-LABEL: @fdiv_undef_undef(
37 ; CHECK-NEXT: ret double undef
39 %r = fdiv double undef, undef
43 define double @frem_undef_undef(double %x) {
44 ; CHECK-LABEL: @frem_undef_undef(
45 ; CHECK-NEXT: ret double undef
47 %r = frem double undef, undef
53 define float @fadd_undef_op0_nnan_constant(float %x) {
54 ; CHECK-LABEL: @fadd_undef_op0_nnan_constant(
55 ; CHECK-NEXT: ret float 0x7FF8000000000000
57 %r = fadd nnan float undef, 1.0
61 define float @fadd_undef_op1_constant(float %x) {
62 ; CHECK-LABEL: @fadd_undef_op1_constant(
63 ; CHECK-NEXT: ret float 0x7FF8000000000000
65 %r = fadd float 2.0, undef
69 define float @fsub_undef_op0_fast_constant(float %x) {
70 ; CHECK-LABEL: @fsub_undef_op0_fast_constant(
71 ; CHECK-NEXT: ret float 0x7FF8000000000000
73 %r = fsub fast float undef, 3.0
77 define float @fsub_undef_op1_constant(float %x) {
78 ; CHECK-LABEL: @fsub_undef_op1_constant(
79 ; CHECK-NEXT: ret float 0x7FF8000000000000
81 %r = fsub float 4.0, undef
85 define float @fmul_undef_op0_nnan_constant(float %x) {
86 ; CHECK-LABEL: @fmul_undef_op0_nnan_constant(
87 ; CHECK-NEXT: ret float 0x7FF8000000000000
89 %r = fmul nnan float undef, 5.0
93 define float @fmul_undef_op1_constant(float %x) {
94 ; CHECK-LABEL: @fmul_undef_op1_constant(
95 ; CHECK-NEXT: ret float 0x7FF8000000000000
97 %r = fmul float 6.0, undef
101 define float @fdiv_undef_op0_fast_constant(float %x) {
102 ; CHECK-LABEL: @fdiv_undef_op0_fast_constant(
103 ; CHECK-NEXT: ret float 0x7FF8000000000000
105 %r = fdiv fast float undef, 7.0
109 define float @fdiv_undef_op1_constant(float %x) {
110 ; CHECK-LABEL: @fdiv_undef_op1_constant(
111 ; CHECK-NEXT: ret float 0x7FF8000000000000
113 %r = fdiv float 8.0, undef
117 define float @frem_undef_op0_nnan_constant(float %x) {
118 ; CHECK-LABEL: @frem_undef_op0_nnan_constant(
119 ; CHECK-NEXT: ret float 0x7FF8000000000000
121 %r = frem nnan float undef, 9.0
125 define float @frem_undef_op1_constant(float %x) {
126 ; CHECK-LABEL: @frem_undef_op1_constant(
127 ; CHECK-NEXT: ret float 0x7FF8000000000000
129 %r = frem float 10.0, undef
133 ; Constant folding - special constants: 0.0.
135 define double @fadd_undef_op0_constant_0(double %x) {
136 ; CHECK-LABEL: @fadd_undef_op0_constant_0(
137 ; CHECK-NEXT: ret double 0x7FF8000000000000
139 %r = fadd double undef, 0x0000000000000000
143 define double @fadd_undef_op1_constant_0(double %x) {
144 ; CHECK-LABEL: @fadd_undef_op1_constant_0(
145 ; CHECK-NEXT: ret double 0x7FF8000000000000
147 %r = fadd double 0x0000000000000000, undef
151 define double @fsub_undef_op0_constant_0(double %x) {
152 ; CHECK-LABEL: @fsub_undef_op0_constant_0(
153 ; CHECK-NEXT: ret double undef
155 %r = fsub double undef, 0x0000000000000000
159 define double @fsub_undef_op1_constant_0(double %x) {
160 ; CHECK-LABEL: @fsub_undef_op1_constant_0(
161 ; CHECK-NEXT: ret double 0x7FF8000000000000
163 %r = fsub double 0x0000000000000000, undef
167 define double @fmul_undef_op0_constant_0(double %x) {
168 ; CHECK-LABEL: @fmul_undef_op0_constant_0(
169 ; CHECK-NEXT: ret double 0x7FF8000000000000
171 %r = fmul double undef, 0x0000000000000000
175 define double @fmul_undef_op1_constant_0(double %x) {
176 ; CHECK-LABEL: @fmul_undef_op1_constant_0(
177 ; CHECK-NEXT: ret double 0x7FF8000000000000
179 %r = fmul double 0x0000000000000000, undef
183 define double @fdiv_undef_op0_constant_0(double %x) {
184 ; CHECK-LABEL: @fdiv_undef_op0_constant_0(
185 ; CHECK-NEXT: ret double 0x7FF8000000000000
187 %r = fdiv double undef, 0x0000000000000000
191 define double @fdiv_undef_op1_constant_0(double %x) {
192 ; CHECK-LABEL: @fdiv_undef_op1_constant_0(
193 ; CHECK-NEXT: ret double 0x7FF8000000000000
195 %r = fdiv double 0x0000000000000000, undef
199 define double @frem_undef_op0_constant_0(double %x) {
200 ; CHECK-LABEL: @frem_undef_op0_constant_0(
201 ; CHECK-NEXT: ret double 0x7FF8000000000000
203 %r = frem double undef, 0x0000000000000000
207 define double @frem_undef_op1_constant_0(double %x) {
208 ; CHECK-LABEL: @frem_undef_op1_constant_0(
209 ; CHECK-NEXT: ret double 0x7FF8000000000000
211 %r = frem double 0x0000000000000000, undef
215 ; Constant folding - special constants: -0.0.
217 define double @fadd_undef_op0_constant_neg0(double %x) {
218 ; CHECK-LABEL: @fadd_undef_op0_constant_neg0(
219 ; CHECK-NEXT: ret double undef
221 %r = fadd double undef, 0x8000000000000000
225 define double @fadd_undef_op1_constant_neg0(double %x) {
226 ; CHECK-LABEL: @fadd_undef_op1_constant_neg0(
227 ; CHECK-NEXT: ret double undef
229 %r = fadd double 0x8000000000000000, undef
233 define double @fsub_undef_op0_constant_neg0(double %x) {
234 ; CHECK-LABEL: @fsub_undef_op0_constant_neg0(
235 ; CHECK-NEXT: ret double 0x7FF8000000000000
237 %r = fsub double undef, 0x8000000000000000
241 define double @fsub_undef_op1_constant_neg0(double %x) {
242 ; CHECK-LABEL: @fsub_undef_op1_constant_neg0(
243 ; CHECK-NEXT: ret double undef
245 %r = fsub double 0x8000000000000000, undef
249 define double @fmul_undef_op0_constant_neg0(double %x) {
250 ; CHECK-LABEL: @fmul_undef_op0_constant_neg0(
251 ; CHECK-NEXT: ret double 0x7FF8000000000000
253 %r = fmul double undef, 0x8000000000000000
257 define double @fmul_undef_op1_constant_neg0(double %x) {
258 ; CHECK-LABEL: @fmul_undef_op1_constant_neg0(
259 ; CHECK-NEXT: ret double 0x7FF8000000000000
261 %r = fmul double 0x8000000000000000, undef
265 define double @fdiv_undef_op0_constant_neg0(double %x) {
266 ; CHECK-LABEL: @fdiv_undef_op0_constant_neg0(
267 ; CHECK-NEXT: ret double 0x7FF8000000000000
269 %r = fdiv double undef, 0x8000000000000000
273 define double @fdiv_undef_op1_constant_neg0(double %x) {
274 ; CHECK-LABEL: @fdiv_undef_op1_constant_neg0(
275 ; CHECK-NEXT: ret double 0x7FF8000000000000
277 %r = fdiv double 0x8000000000000000, undef
281 define double @frem_undef_op0_constant_neg0(double %x) {
282 ; CHECK-LABEL: @frem_undef_op0_constant_neg0(
283 ; CHECK-NEXT: ret double 0x7FF8000000000000
285 %r = frem double undef, 0x8000000000000000
289 define double @frem_undef_op1_constant_neg0(double %x) {
290 ; CHECK-LABEL: @frem_undef_op1_constant_neg0(
291 ; CHECK-NEXT: ret double 0x7FF8000000000000
293 %r = frem double 0x8000000000000000, undef
297 ; Constant folding - special constants: NaN.
299 define double @fadd_undef_op0_constant_nan(double %x) {
300 ; CHECK-LABEL: @fadd_undef_op0_constant_nan(
301 ; CHECK-NEXT: ret double 0x7FF8000000000000
303 %r = fadd double undef, 0x7FF8000000000000
307 define double @fadd_undef_op1_fast_constant_nan(double %x) {
308 ; CHECK-LABEL: @fadd_undef_op1_fast_constant_nan(
309 ; CHECK-NEXT: ret double 0x7FF8000000000000
311 %r = fadd fast double 0xFFF0000000000001, undef
315 define double @fsub_undef_op0_constant_nan(double %x) {
316 ; CHECK-LABEL: @fsub_undef_op0_constant_nan(
317 ; CHECK-NEXT: ret double 0x7FF8000000000000
319 %r = fsub double undef, 0xFFF8000000000010
323 define double @fsub_undef_op1_nnan_constant_nan(double %x) {
324 ; CHECK-LABEL: @fsub_undef_op1_nnan_constant_nan(
325 ; CHECK-NEXT: ret double 0x7FF8000000000000
327 %r = fsub nnan double 0x7FF0000000000011, undef
331 define double @fmul_undef_op0_constant_nan(double %x) {
332 ; CHECK-LABEL: @fmul_undef_op0_constant_nan(
333 ; CHECK-NEXT: ret double 0x7FF8000000000000
335 %r = fmul double undef, 0x7FF8000000000100
339 define double @fmul_undef_op1_fast_constant_nan(double %x) {
340 ; CHECK-LABEL: @fmul_undef_op1_fast_constant_nan(
341 ; CHECK-NEXT: ret double 0x7FF8000000000000
343 %r = fmul fast double 0xFFF0000000000101, undef
347 define double @fdiv_undef_op0_constant_nan(double %x) {
348 ; CHECK-LABEL: @fdiv_undef_op0_constant_nan(
349 ; CHECK-NEXT: ret double 0x7FF8000000000000
351 %r = fdiv double undef, 0xFFF8000000000110
355 define double @fdiv_undef_op1_nnan_constant_nan(double %x) {
356 ; CHECK-LABEL: @fdiv_undef_op1_nnan_constant_nan(
357 ; CHECK-NEXT: ret double 0x7FF8000000000000
359 %r = fdiv nnan double 0x7FF0000000000111, undef
363 define double @frem_undef_op0_constant_nan(double %x) {
364 ; CHECK-LABEL: @frem_undef_op0_constant_nan(
365 ; CHECK-NEXT: ret double 0x7FF8000000000000
367 %r = frem double undef, 0x7FF8000000001000
371 define double @frem_undef_op1_fast_constant_nan(double %x) {
372 ; CHECK-LABEL: @frem_undef_op1_fast_constant_nan(
373 ; CHECK-NEXT: ret double 0x7FF8000000000000
375 %r = frem fast double 0xFFF0000000001001, undef
379 ; Constant folding - special constants: Inf.
381 define double @fadd_undef_op0_constant_inf(double %x) {
382 ; CHECK-LABEL: @fadd_undef_op0_constant_inf(
383 ; CHECK-NEXT: ret double 0x7FF8000000000000
385 %r = fadd double undef, 0x7FF0000000000000
389 define double @fadd_undef_op1_fast_constant_inf(double %x) {
390 ; CHECK-LABEL: @fadd_undef_op1_fast_constant_inf(
391 ; CHECK-NEXT: ret double 0x7FF8000000000000
393 %r = fadd fast double 0xFFF0000000000000, undef
397 define double @fsub_undef_op0_constant_inf(double %x) {
398 ; CHECK-LABEL: @fsub_undef_op0_constant_inf(
399 ; CHECK-NEXT: ret double 0x7FF8000000000000
401 %r = fsub double undef, 0xFFF0000000000000
405 define double @fsub_undef_op1_ninf_constant_inf(double %x) {
406 ; CHECK-LABEL: @fsub_undef_op1_ninf_constant_inf(
407 ; CHECK-NEXT: ret double 0x7FF8000000000000
409 %r = fsub ninf double 0x7FF0000000000000, undef
413 define double @fmul_undef_op0_constant_inf(double %x) {
414 ; CHECK-LABEL: @fmul_undef_op0_constant_inf(
415 ; CHECK-NEXT: ret double 0x7FF8000000000000
417 %r = fmul double undef, 0x7FF0000000000000
421 define double @fmul_undef_op1_fast_constant_inf(double %x) {
422 ; CHECK-LABEL: @fmul_undef_op1_fast_constant_inf(
423 ; CHECK-NEXT: ret double 0x7FF8000000000000
425 %r = fmul fast double 0xFFF0000000000000, undef
429 define double @fdiv_undef_op0_constant_inf(double %x) {
430 ; CHECK-LABEL: @fdiv_undef_op0_constant_inf(
431 ; CHECK-NEXT: ret double 0x7FF8000000000000
433 %r = fdiv double undef, 0xFFF0000000000000
437 define double @fdiv_undef_op1_ninf_constant_inf(double %x) {
438 ; CHECK-LABEL: @fdiv_undef_op1_ninf_constant_inf(
439 ; CHECK-NEXT: ret double 0x7FF8000000000000
441 %r = fdiv ninf double 0x7FF0000000000000, undef
445 define double @frem_undef_op0_constant_inf(double %x) {
446 ; CHECK-LABEL: @frem_undef_op0_constant_inf(
447 ; CHECK-NEXT: ret double 0x7FF8000000000000
449 %r = frem double undef, 0x7FF0000000000000
453 define double @frem_undef_op1_fast_constant_inf(double %x) {
454 ; CHECK-LABEL: @frem_undef_op1_fast_constant_inf(
455 ; CHECK-NEXT: ret double 0x7FF8000000000000
457 %r = frem fast double 0xFFF0000000000000, undef
461 define <2 x double> @fadd_undef_op1_constant_vec(<2 x double> %x) {
462 ; CHECK-LABEL: @fadd_undef_op1_constant_vec(
463 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
465 %r = fadd <2 x double> <double 42.0, double undef>, undef
469 define <2 x double> @fadd_undef_op0_constant_vec(<2 x double> %x) {
470 ; CHECK-LABEL: @fadd_undef_op0_constant_vec(
471 ; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000>
473 %r = fadd <2 x double> undef, <double undef, double 42.0>
477 define <2 x double> @fsub_undef_op1_constant_vec(<2 x double> %x) {
478 ; CHECK-LABEL: @fsub_undef_op1_constant_vec(
479 ; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000>
481 %r = fsub <2 x double> <double undef, double 42.0>, undef
485 define <2 x double> @fsub_undef_op0_constant_vec(<2 x double> %x) {
486 ; CHECK-LABEL: @fsub_undef_op0_constant_vec(
487 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
489 %r = fsub <2 x double> undef, <double 42.0, double undef>
493 define <2 x double> @fmul_undef_op1_constant_vec(<2 x double> %x) {
494 ; CHECK-LABEL: @fmul_undef_op1_constant_vec(
495 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
497 %r = fmul <2 x double> <double 42.0, double undef>, undef
501 define <2 x double> @fmul_undef_op0_constant_vec(<2 x double> %x) {
502 ; CHECK-LABEL: @fmul_undef_op0_constant_vec(
503 ; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000>
505 %r = fmul <2 x double> undef, <double undef, double 42.0>
509 define <2 x double> @fdiv_undef_op1_constant_vec(<2 x double> %x) {
510 ; CHECK-LABEL: @fdiv_undef_op1_constant_vec(
511 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
513 %r = fdiv <2 x double> <double 42.0, double undef>, undef
517 define <2 x double> @fdiv_undef_op0_constant_vec(<2 x double> %x) {
518 ; CHECK-LABEL: @fdiv_undef_op0_constant_vec(
519 ; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000>
521 %r = fdiv <2 x double> undef, <double undef, double 42.0>
525 define <2 x double> @frem_undef_op1_constant_vec(<2 x double> %x) {
526 ; CHECK-LABEL: @frem_undef_op1_constant_vec(
527 ; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000>
529 %r = frem <2 x double> <double undef, double 42.0>, undef
533 define <2 x double> @frem_undef_op0_constant_vec(<2 x double> %x) {
534 ; CHECK-LABEL: @frem_undef_op0_constant_vec(
535 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
537 %r = frem <2 x double> undef, <double 42.0, double undef>
541 define <2 x double> @maximum_nan_op0_vec_partial_undef_op1_undef(<2 x double> %x) {
542 ; CHECK-LABEL: @maximum_nan_op0_vec_partial_undef_op1_undef(
543 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
545 %r = call <2 x double> @llvm.maximum.v2f64(<2 x double> <double 0x7ff8000000000000, double undef>, <2 x double> undef)
549 define <2 x double> @maximum_nan_op1_vec_partial_undef_op0_undef(<2 x double> %x) {
550 ; CHECK-LABEL: @maximum_nan_op1_vec_partial_undef_op0_undef(
551 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
553 %r = call <2 x double> @llvm.maximum.v2f64(<2 x double> undef, <2 x double> <double 0x7ff8000000000000, double undef>)
557 define <2 x double> @minimum_nan_op0_vec_partial_undef_op1_undef(<2 x double> %x) {
558 ; CHECK-LABEL: @minimum_nan_op0_vec_partial_undef_op1_undef(
559 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
561 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> <double 0x7ff8000000000000, double undef>, <2 x double> undef)
565 define <2 x double> @minimum_nan_op1_vec_partial_undef_op0_undef(<2 x double> %x) {
566 ; CHECK-LABEL: @minimum_nan_op1_vec_partial_undef_op0_undef(
567 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
569 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> undef, <2 x double> <double 0x7ff8000000000000, double undef>)
573 define <2 x double> @maxnum_nan_op0_vec_partial_undef_op1_undef(<2 x double> %x) {
574 ; CHECK-LABEL: @maxnum_nan_op0_vec_partial_undef_op1_undef(
575 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
577 %r = call <2 x double> @llvm.maxnum.v2f64(<2 x double> <double 0x7ff8000000000000, double undef>, <2 x double> undef)
581 define <2 x double> @maxnum_nan_op1_vec_partial_undef_op0_undef(<2 x double> %x) {
582 ; CHECK-LABEL: @maxnum_nan_op1_vec_partial_undef_op0_undef(
583 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
585 %r = call <2 x double> @llvm.maxnum.v2f64(<2 x double> undef, <2 x double> <double 0x7ff8000000000000, double undef>)
589 define <2 x double> @minnum_nan_op0_vec_partial_undef_op1_undef(<2 x double> %x) {
590 ; CHECK-LABEL: @minnum_nan_op0_vec_partial_undef_op1_undef(
591 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
593 %r = call <2 x double> @llvm.minnum.v2f64(<2 x double> <double 0x7ff8000000000000, double undef>, <2 x double> undef)
597 define <2 x double> @minnum_nan_op1_vec_partial_undef_op0_undef(<2 x double> %x) {
598 ; CHECK-LABEL: @minnum_nan_op1_vec_partial_undef_op0_undef(
599 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef>
601 %r = call <2 x double> @llvm.minnum.v2f64(<2 x double> undef, <2 x double> <double 0x7ff8000000000000, double undef>)