1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 declare void @use(float)
6 define float @fneg_fneg(float %a) {
8 ; CHECK-LABEL: @fneg_fneg(
9 ; CHECK-NEXT: ret float [[A:%.*]]
16 ; -(X * C) --> X * (-C)
18 define float @fmul_fsub(float %x) {
19 ; CHECK-LABEL: @fmul_fsub(
20 ; CHECK-NEXT: [[R:%.*]] = fmul float [[X:%.*]], -4.200000e+01
21 ; CHECK-NEXT: ret float [[R]]
23 %m = fmul float %x, 42.0
24 %r = fsub float -0.0, %m
28 define float @fmul_fneg(float %x) {
29 ; CHECK-LABEL: @fmul_fneg(
30 ; CHECK-NEXT: [[R:%.*]] = fmul float [[X:%.*]], -4.200000e+01
31 ; CHECK-NEXT: ret float [[R]]
33 %m = fmul float %x, 42.0
38 ; Fast math is not required, but it should be propagated.
40 define float @fmul_fsub_fmf(float %x) {
41 ; CHECK-LABEL: @fmul_fsub_fmf(
42 ; CHECK-NEXT: [[R:%.*]] = fmul reassoc nsz float [[X:%.*]], -4.200000e+01
43 ; CHECK-NEXT: ret float [[R]]
45 %m = fmul float %x, 42.0
46 %r = fsub reassoc nsz float -0.0, %m
50 define float @fmul_fneg_fmf(float %x) {
51 ; CHECK-LABEL: @fmul_fneg_fmf(
52 ; CHECK-NEXT: [[R:%.*]] = fmul reassoc nsz float [[X:%.*]], -4.200000e+01
53 ; CHECK-NEXT: ret float [[R]]
55 %m = fmul float %x, 42.0
56 %r = fneg reassoc nsz float %m
60 ; Extra use prevents the fold. We don't want to replace the fneg with an fmul.
62 define float @fmul_fsub_extra_use(float %x) {
63 ; CHECK-LABEL: @fmul_fsub_extra_use(
64 ; CHECK-NEXT: [[M:%.*]] = fmul float [[X:%.*]], 4.200000e+01
65 ; CHECK-NEXT: [[R:%.*]] = fneg float [[M]]
66 ; CHECK-NEXT: call void @use(float [[M]])
67 ; CHECK-NEXT: ret float [[R]]
69 %m = fmul float %x, 42.0
70 %r = fsub float -0.0, %m
71 call void @use(float %m)
75 define float @fmul_fneg_extra_use(float %x) {
76 ; CHECK-LABEL: @fmul_fneg_extra_use(
77 ; CHECK-NEXT: [[M:%.*]] = fmul float [[X:%.*]], 4.200000e+01
78 ; CHECK-NEXT: [[R:%.*]] = fneg float [[M]]
79 ; CHECK-NEXT: call void @use(float [[M]])
80 ; CHECK-NEXT: ret float [[R]]
82 %m = fmul float %x, 42.0
84 call void @use(float %m)
88 ; Try a vector. Use special constants (NaN, INF, undef) because they don't change anything.
90 define <4 x double> @fmul_fsub_vec(<4 x double> %x) {
91 ; CHECK-LABEL: @fmul_fsub_vec(
92 ; CHECK-NEXT: [[R:%.*]] = fmul <4 x double> [[X:%.*]], <double -4.200000e+01, double 0xFFF8000000000000, double 0xFFF0000000000000, double undef>
93 ; CHECK-NEXT: ret <4 x double> [[R]]
95 %m = fmul <4 x double> %x, <double 42.0, double 0x7FF8000000000000, double 0x7FF0000000000000, double undef>
96 %r = fsub <4 x double> <double -0.0, double -0.0, double -0.0, double -0.0>, %m
100 define <4 x double> @fmul_fneg_vec(<4 x double> %x) {
101 ; CHECK-LABEL: @fmul_fneg_vec(
102 ; CHECK-NEXT: [[R:%.*]] = fmul <4 x double> [[X:%.*]], <double -4.200000e+01, double 0xFFF8000000000000, double 0xFFF0000000000000, double undef>
103 ; CHECK-NEXT: ret <4 x double> [[R]]
105 %m = fmul <4 x double> %x, <double 42.0, double 0x7FF8000000000000, double 0x7FF0000000000000, double undef>
106 %r = fneg <4 x double> %m
110 ; -(X / C) --> X / (-C)
112 define float @fdiv_op1_constant_fsub(float %x) {
113 ; CHECK-LABEL: @fdiv_op1_constant_fsub(
114 ; CHECK-NEXT: [[R:%.*]] = fdiv float [[X:%.*]], 4.200000e+01
115 ; CHECK-NEXT: ret float [[R]]
117 %d = fdiv float %x, -42.0
118 %r = fsub float -0.0, %d
122 define float @fdiv_op1_constant_fneg(float %x) {
123 ; CHECK-LABEL: @fdiv_op1_constant_fneg(
124 ; CHECK-NEXT: [[R:%.*]] = fdiv float [[X:%.*]], 4.200000e+01
125 ; CHECK-NEXT: ret float [[R]]
127 %d = fdiv float %x, -42.0
132 ; Fast math is not required, but it should be propagated.
134 define float @fdiv_op1_constant_fsub_fmf(float %x) {
135 ; CHECK-LABEL: @fdiv_op1_constant_fsub_fmf(
136 ; CHECK-NEXT: [[R:%.*]] = fdiv nnan float [[X:%.*]], 4.200000e+01
137 ; CHECK-NEXT: ret float [[R]]
139 %d = fdiv float %x, -42.0
140 %r = fsub nnan float -0.0, %d
144 define float @fdiv_op1_constant_fneg_fmf(float %x) {
145 ; CHECK-LABEL: @fdiv_op1_constant_fneg_fmf(
146 ; CHECK-NEXT: [[R:%.*]] = fdiv nnan float [[X:%.*]], 4.200000e+01
147 ; CHECK-NEXT: ret float [[R]]
149 %d = fdiv float %x, -42.0
150 %r = fneg nnan float %d
154 ; Extra use prevents the fold. We don't want to replace the fneg with an fdiv.
156 define float @fdiv_op1_constant_fsub_extra_use(float %x) {
157 ; CHECK-LABEL: @fdiv_op1_constant_fsub_extra_use(
158 ; CHECK-NEXT: [[D:%.*]] = fdiv float [[X:%.*]], 4.200000e+01
159 ; CHECK-NEXT: [[R:%.*]] = fneg float [[D]]
160 ; CHECK-NEXT: call void @use(float [[D]])
161 ; CHECK-NEXT: ret float [[R]]
163 %d = fdiv float %x, 42.0
164 %r = fsub float -0.0, %d
165 call void @use(float %d)
169 define float @fdiv_op1_constant_fneg_extra_use(float %x) {
170 ; CHECK-LABEL: @fdiv_op1_constant_fneg_extra_use(
171 ; CHECK-NEXT: [[D:%.*]] = fdiv float [[X:%.*]], 4.200000e+01
172 ; CHECK-NEXT: [[R:%.*]] = fneg float [[D]]
173 ; CHECK-NEXT: call void @use(float [[D]])
174 ; CHECK-NEXT: ret float [[R]]
176 %d = fdiv float %x, 42.0
178 call void @use(float %d)
182 ; Try a vector. Use special constants (NaN, INF, undef) because they don't change anything.
184 define <4 x double> @fdiv_op1_constant_fsub_vec(<4 x double> %x) {
185 ; CHECK-LABEL: @fdiv_op1_constant_fsub_vec(
186 ; CHECK-NEXT: [[R:%.*]] = fdiv <4 x double> [[X:%.*]], <double 4.200000e+01, double 0x7FF800000ABCD000, double 0x7FF0000000000000, double undef>
187 ; CHECK-NEXT: ret <4 x double> [[R]]
189 %d = fdiv <4 x double> %x, <double -42.0, double 0xFFF800000ABCD000, double 0xFFF0000000000000, double undef>
190 %r = fsub <4 x double> <double -0.0, double -0.0, double -0.0, double -0.0>, %d
194 define <4 x double> @fdiv_op1_constant_fneg_vec(<4 x double> %x) {
195 ; CHECK-LABEL: @fdiv_op1_constant_fneg_vec(
196 ; CHECK-NEXT: [[R:%.*]] = fdiv <4 x double> [[X:%.*]], <double 4.200000e+01, double 0x7FF800000ABCD000, double 0x7FF0000000000000, double undef>
197 ; CHECK-NEXT: ret <4 x double> [[R]]
199 %d = fdiv <4 x double> %x, <double -42.0, double 0xFFF800000ABCD000, double 0xFFF0000000000000, double undef>
200 %r = fneg <4 x double> %d
204 ; -(C / X) --> (-C) / X
206 define float @fdiv_op0_constant_fsub(float %x) {
207 ; CHECK-LABEL: @fdiv_op0_constant_fsub(
208 ; CHECK-NEXT: [[R:%.*]] = fdiv float -4.200000e+01, [[X:%.*]]
209 ; CHECK-NEXT: ret float [[R]]
211 %d = fdiv float 42.0, %x
212 %r = fsub float -0.0, %d
216 define float @fdiv_op0_constant_fneg(float %x) {
217 ; CHECK-LABEL: @fdiv_op0_constant_fneg(
218 ; CHECK-NEXT: [[R:%.*]] = fdiv float -4.200000e+01, [[X:%.*]]
219 ; CHECK-NEXT: ret float [[R]]
221 %d = fdiv float 42.0, %x
226 ; Fast math is not required, but it should be propagated.
228 define float @fdiv_op0_constant_fneg_fast_fast(float %x) {
229 ; CHECK-LABEL: @fdiv_op0_constant_fneg_fast_fast(
230 ; CHECK-NEXT: [[R:%.*]] = fdiv fast float -4.200000e+01, [[X:%.*]]
231 ; CHECK-NEXT: ret float [[R]]
233 %d = fdiv fast float 42.0, %x
234 %r = fneg fast float %d
238 define float @fdiv_op0_constant_fneg_fast(float %x) {
239 ; CHECK-LABEL: @fdiv_op0_constant_fneg_fast(
240 ; CHECK-NEXT: [[R:%.*]] = fdiv reassoc nnan arcp contract afn float -4.200000e+01, [[X:%.*]]
241 ; CHECK-NEXT: ret float [[R]]
243 %d = fdiv float 42.0, %x
244 %r = fneg fast float %d
248 define float @fdiv_op0_constant_fneg_nsz_nsz(float %x) {
249 ; CHECK-LABEL: @fdiv_op0_constant_fneg_nsz_nsz(
250 ; CHECK-NEXT: [[R:%.*]] = fdiv nsz float -4.200000e+01, [[X:%.*]]
251 ; CHECK-NEXT: ret float [[R]]
253 %d = fdiv nsz float 42.0, %x
254 %r = fneg nsz float %d
258 define float @fdiv_op0_constant_fneg_nsz(float %x) {
259 ; CHECK-LABEL: @fdiv_op0_constant_fneg_nsz(
260 ; CHECK-NEXT: [[R:%.*]] = fdiv float -4.200000e+01, [[X:%.*]]
261 ; CHECK-NEXT: ret float [[R]]
263 %d = fdiv float 42.0, %x
264 %r = fneg nsz float %d
268 define float @fdiv_op0_constant_fneg_ninf_ninf(float %x) {
269 ; CHECK-LABEL: @fdiv_op0_constant_fneg_ninf_ninf(
270 ; CHECK-NEXT: [[R:%.*]] = fdiv ninf float -4.200000e+01, [[X:%.*]]
271 ; CHECK-NEXT: ret float [[R]]
273 %d = fdiv ninf float 42.0, %x
274 %r = fneg ninf float %d
278 define float @fdiv_op0_constant_fneg_ninf(float %x) {
279 ; CHECK-LABEL: @fdiv_op0_constant_fneg_ninf(
280 ; CHECK-NEXT: [[R:%.*]] = fdiv float -4.200000e+01, [[X:%.*]]
281 ; CHECK-NEXT: ret float [[R]]
283 %d = fdiv float 42.0, %x
284 %r = fneg ninf float %d
288 define float @fdiv_op0_constant_fneg_nnan_nnan(float %x) {
289 ; CHECK-LABEL: @fdiv_op0_constant_fneg_nnan_nnan(
290 ; CHECK-NEXT: [[R:%.*]] = fdiv nnan float -4.200000e+01, [[X:%.*]]
291 ; CHECK-NEXT: ret float [[R]]
293 %d = fdiv nnan float 42.0, %x
294 %r = fneg nnan float %d
298 define float @fdiv_op0_constant_fneg_nnan(float %x) {
299 ; CHECK-LABEL: @fdiv_op0_constant_fneg_nnan(
300 ; CHECK-NEXT: [[R:%.*]] = fdiv nnan float -4.200000e+01, [[X:%.*]]
301 ; CHECK-NEXT: ret float [[R]]
303 %d = fdiv float 42.0, %x
304 %r = fneg nnan float %d
308 ; Extra use prevents the fold. We don't want to replace the fneg with an fdiv.
310 define float @fdiv_op0_constant_fsub_extra_use(float %x) {
311 ; CHECK-LABEL: @fdiv_op0_constant_fsub_extra_use(
312 ; CHECK-NEXT: [[D:%.*]] = fdiv float -4.200000e+01, [[X:%.*]]
313 ; CHECK-NEXT: [[R:%.*]] = fneg float [[D]]
314 ; CHECK-NEXT: call void @use(float [[D]])
315 ; CHECK-NEXT: ret float [[R]]
317 %d = fdiv float -42.0, %x
318 %r = fsub float -0.0, %d
319 call void @use(float %d)
323 define float @fdiv_op0_constant_fneg_extra_use(float %x) {
324 ; CHECK-LABEL: @fdiv_op0_constant_fneg_extra_use(
325 ; CHECK-NEXT: [[D:%.*]] = fdiv float -4.200000e+01, [[X:%.*]]
326 ; CHECK-NEXT: [[R:%.*]] = fneg float [[D]]
327 ; CHECK-NEXT: call void @use(float [[D]])
328 ; CHECK-NEXT: ret float [[R]]
330 %d = fdiv float -42.0, %x
332 call void @use(float %d)
336 ; Try a vector. Use special constants (NaN, INF, undef) because they don't change anything.
338 define <4 x double> @fdiv_op0_constant_fsub_vec(<4 x double> %x) {
339 ; CHECK-LABEL: @fdiv_op0_constant_fsub_vec(
340 ; CHECK-NEXT: [[R:%.*]] = fdiv <4 x double> <double 4.200000e+01, double 0xFFF8000000000000, double 0x7FF0000000000000, double undef>, [[X:%.*]]
341 ; CHECK-NEXT: ret <4 x double> [[R]]
343 %d = fdiv <4 x double> <double -42.0, double 0x7FF8000000000000, double 0xFFF0000000000000, double undef>, %x
344 %r = fsub <4 x double> <double -0.0, double -0.0, double -0.0, double -0.0>, %d
348 define <4 x double> @fdiv_op0_constant_fneg_vec(<4 x double> %x) {
349 ; CHECK-LABEL: @fdiv_op0_constant_fneg_vec(
350 ; CHECK-NEXT: [[R:%.*]] = fdiv <4 x double> <double 4.200000e+01, double 0xFFF8000000000000, double 0x7FF0000000000000, double undef>, [[X:%.*]]
351 ; CHECK-NEXT: ret <4 x double> [[R]]
353 %d = fdiv <4 x double> <double -42.0, double 0x7FF8000000000000, double 0xFFF0000000000000, double undef>, %x
354 %r = fneg <4 x double> %d
358 ; Sink FP negation through a select:
359 ; c ? -x : -y --> -(c ? x : y)
361 define <2 x double> @fneg_fneg_sel(<2 x double> %x, <2 x double> %y, i1 %cond) {
362 ; CHECK-LABEL: @fneg_fneg_sel(
363 ; CHECK-NEXT: [[SEL_V:%.*]] = select i1 [[COND:%.*]], <2 x double> [[X:%.*]], <2 x double> [[Y:%.*]]
364 ; CHECK-NEXT: [[SEL:%.*]] = fneg <2 x double> [[SEL_V]]
365 ; CHECK-NEXT: ret <2 x double> [[SEL]]
367 %n1 = fneg <2 x double> %x
368 %n2 = fneg <2 x double> %y
369 %sel = select i1 %cond, <2 x double> %n1, <2 x double> %n2
370 ret <2 x double> %sel
373 ; An extra use is allowed.
375 define float @fneg_fneg_sel_extra_use1(float %x, float %y, i1 %cond) {
376 ; CHECK-LABEL: @fneg_fneg_sel_extra_use1(
377 ; CHECK-NEXT: [[N1:%.*]] = fneg float [[X:%.*]]
378 ; CHECK-NEXT: call void @use(float [[N1]])
379 ; CHECK-NEXT: [[SEL_V:%.*]] = select i1 [[COND:%.*]], float [[X]], float [[Y:%.*]]
380 ; CHECK-NEXT: [[SEL:%.*]] = fneg float [[SEL_V]]
381 ; CHECK-NEXT: ret float [[SEL]]
384 call void @use(float %n1)
386 %sel = select i1 %cond, float %n1, float %n2
390 define float @fneg_fneg_sel_extra_use2(float %x, float %y, i1 %cond) {
391 ; CHECK-LABEL: @fneg_fneg_sel_extra_use2(
392 ; CHECK-NEXT: [[N2:%.*]] = fneg float [[Y:%.*]]
393 ; CHECK-NEXT: call void @use(float [[N2]])
394 ; CHECK-NEXT: [[SEL_V:%.*]] = select i1 [[COND:%.*]], float [[X:%.*]], float [[Y]]
395 ; CHECK-NEXT: [[SEL:%.*]] = fneg float [[SEL_V]]
396 ; CHECK-NEXT: ret float [[SEL]]
400 call void @use(float %n2)
401 %sel = select i1 %cond, float %n1, float %n2
405 ; Legacy form of fneg should work too.
407 define float @fsub_fsub_sel_extra_use1(float %x, float %y, i1 %cond) {
408 ; CHECK-LABEL: @fsub_fsub_sel_extra_use1(
409 ; CHECK-NEXT: [[N1:%.*]] = fneg float [[X:%.*]]
410 ; CHECK-NEXT: call void @use(float [[N1]])
411 ; CHECK-NEXT: [[SEL_V:%.*]] = select i1 [[COND:%.*]], float [[X]], float [[Y:%.*]]
412 ; CHECK-NEXT: [[SEL:%.*]] = fneg float [[SEL_V]]
413 ; CHECK-NEXT: ret float [[SEL]]
415 %n1 = fsub float -0.0, %x
416 call void @use(float %n1)
417 %n2 = fsub float -0.0, %y
418 %sel = select i1 %cond, float %n1, float %n2
422 ; Negative test: but 2 extra uses would require an extra instruction.
424 define float @fneg_fneg_sel_extra_use3(float %x, float %y, i1 %cond) {
425 ; CHECK-LABEL: @fneg_fneg_sel_extra_use3(
426 ; CHECK-NEXT: [[N1:%.*]] = fneg float [[X:%.*]]
427 ; CHECK-NEXT: call void @use(float [[N1]])
428 ; CHECK-NEXT: [[N2:%.*]] = fneg float [[Y:%.*]]
429 ; CHECK-NEXT: call void @use(float [[N2]])
430 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], float [[N1]], float [[N2]]
431 ; CHECK-NEXT: ret float [[SEL]]
434 call void @use(float %n1)
436 call void @use(float %n2)
437 %sel = select i1 %cond, float %n1, float %n2
443 define float @fneg_fadd_constant(float %x) {
444 ; CHECK-LABEL: @fneg_fadd_constant(
445 ; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
446 ; CHECK-NEXT: [[R:%.*]] = fneg float [[A]]
447 ; CHECK-NEXT: ret float [[R]]
449 %a = fadd float %x, 42.0
456 define float @fake_nsz_fadd_constant(float %x) {
457 ; CHECK-LABEL: @fake_nsz_fadd_constant(
458 ; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
459 ; CHECK-NEXT: [[R:%.*]] = fneg float [[A]]
460 ; CHECK-NEXT: ret float [[R]]
462 %a = fadd float %x, 42.0
463 %r = fsub float -0.0, %a
467 ; -(X + C) --> -C - X
469 define float @fneg_nsz_fadd_constant(float %x) {
470 ; CHECK-LABEL: @fneg_nsz_fadd_constant(
471 ; CHECK-NEXT: [[R:%.*]] = fsub nsz float -4.200000e+01, [[X:%.*]]
472 ; CHECK-NEXT: ret float [[R]]
474 %a = fadd float %x, 42.0
475 %r = fneg nsz float %a
479 ; -(X + C) --> -C - X
481 define float @fake_fneg_nsz_fadd_constant(float %x) {
482 ; CHECK-LABEL: @fake_fneg_nsz_fadd_constant(
483 ; CHECK-NEXT: [[R:%.*]] = fsub fast float -4.200000e+01, [[X:%.*]]
484 ; CHECK-NEXT: ret float [[R]]
486 %a = fadd float %x, 42.0
487 %r = fsub fast float -0.0, %a
493 define float @fneg_nsz_fadd_constant_extra_use(float %x) {
494 ; CHECK-LABEL: @fneg_nsz_fadd_constant_extra_use(
495 ; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
496 ; CHECK-NEXT: call void @use(float [[A]])
497 ; CHECK-NEXT: [[R:%.*]] = fneg nsz float [[A]]
498 ; CHECK-NEXT: ret float [[R]]
500 %a = fadd float %x, 42.0
501 call void @use(float %a)
502 %r = fneg nsz float %a
508 define float @fake_fneg_nsz_fadd_constant_extra_use(float %x) {
509 ; CHECK-LABEL: @fake_fneg_nsz_fadd_constant_extra_use(
510 ; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
511 ; CHECK-NEXT: call void @use(float [[A]])
512 ; CHECK-NEXT: [[R:%.*]] = fneg fast float [[A]]
513 ; CHECK-NEXT: ret float [[R]]
515 %a = fadd float %x, 42.0
516 call void @use(float %a)
517 %r = fsub fast float -0.0, %a
521 ; -(X + C) --> -C - X
523 define <2 x float> @fneg_nsz_fadd_constant_vec(<2 x float> %x) {
524 ; CHECK-LABEL: @fneg_nsz_fadd_constant_vec(
525 ; CHECK-NEXT: [[R:%.*]] = fsub reassoc nnan nsz <2 x float> <float -4.200000e+01, float -4.300000e+01>, [[X:%.*]]
526 ; CHECK-NEXT: ret <2 x float> [[R]]
528 %a = fadd <2 x float> %x, <float 42.0, float 43.0>
529 %r = fneg nsz nnan reassoc <2 x float> %a
533 ; -(X + C) --> -C - X
535 define <2 x float> @fake_fneg_nsz_fadd_constant_vec(<2 x float> %x) {
536 ; CHECK-LABEL: @fake_fneg_nsz_fadd_constant_vec(
537 ; CHECK-NEXT: [[R:%.*]] = fsub nsz <2 x float> <float -4.200000e+01, float undef>, [[X:%.*]]
538 ; CHECK-NEXT: ret <2 x float> [[R]]
540 %a = fadd <2 x float> %x, <float 42.0, float undef>
541 %r = fsub nsz <2 x float> <float undef, float -0.0>, %a
545 @g = external global i16, align 1
547 define float @fneg_nsz_fadd_constant_expr(float %x) {
548 ; CHECK-LABEL: @fneg_nsz_fadd_constant_expr(
549 ; CHECK-NEXT: [[R:%.*]] = fsub nsz float fneg (float bitcast (i32 ptrtoint (i16* @g to i32) to float)), [[X:%.*]]
550 ; CHECK-NEXT: ret float [[R]]
552 %a = fadd float %x, bitcast (i32 ptrtoint (i16* @g to i32) to float)
553 %r = fneg nsz float %a
557 define float @fake_fneg_nsz_fadd_constant_expr(float %x) {
558 ; CHECK-LABEL: @fake_fneg_nsz_fadd_constant_expr(
559 ; CHECK-NEXT: [[R:%.*]] = fsub nsz float fneg (float bitcast (i32 ptrtoint (i16* @g to i32) to float)), [[X:%.*]]
560 ; CHECK-NEXT: ret float [[R]]
562 %a = fadd float %x, bitcast (i32 ptrtoint (i16* @g to i32) to float)
563 %r = fsub nsz float -0.0, %a
567 define float @select_fneg_true(float %x, float %y, i1 %b) {
568 ; CHECK-LABEL: @select_fneg_true(
569 ; CHECK-NEXT: [[Y_NEG:%.*]] = fneg float [[Y:%.*]]
570 ; CHECK-NEXT: [[R:%.*]] = select i1 [[B:%.*]], float [[X:%.*]], float [[Y_NEG]]
571 ; CHECK-NEXT: ret float [[R]]
574 %s = select i1 %b, float %nx, float %y
579 define <2 x float> @select_fneg_false(<2 x float> %x, <2 x float> %y, <2 x i1> %b) {
580 ; CHECK-LABEL: @select_fneg_false(
581 ; CHECK-NEXT: [[X_NEG:%.*]] = fneg nnan nsz <2 x float> [[X:%.*]]
582 ; CHECK-NEXT: [[R:%.*]] = select nnan <2 x i1> [[B:%.*]], <2 x float> [[X_NEG]], <2 x float> [[Y:%.*]]
583 ; CHECK-NEXT: ret <2 x float> [[R]]
585 %ny = fneg nnan <2 x float> %y
586 %s = select ninf <2 x i1> %b, <2 x float> %x, <2 x float> %ny
587 %r = fneg nsz nnan <2 x float> %s
591 define float @select_fneg_false_no_nsz(float %x, float %y, i1 %b) {
592 ; CHECK-LABEL: @select_fneg_false_no_nsz(
593 ; CHECK-NEXT: [[X_NEG:%.*]] = fneg nnan ninf nsz float [[X:%.*]]
594 ; CHECK-NEXT: [[R:%.*]] = select nnan ninf i1 [[B:%.*]], float [[X_NEG]], float [[Y:%.*]]
595 ; CHECK-NEXT: ret float [[R]]
598 %s = select i1 %b, float %x, float %ny
599 %r = fneg ninf nnan nsz float %s
603 define float @select_fneg_false_nsz(float %x, float %y, i1 %b) {
604 ; CHECK-LABEL: @select_fneg_false_nsz(
605 ; CHECK-NEXT: [[X_NEG:%.*]] = fneg nnan ninf nsz float [[X:%.*]]
606 ; CHECK-NEXT: [[R:%.*]] = select nnan ninf nsz i1 [[B:%.*]], float [[X_NEG]], float [[Y:%.*]]
607 ; CHECK-NEXT: ret float [[R]]
610 %s = select nsz i1 %b, float %x, float %ny
611 %r = fneg ninf nnan nsz float %s
615 define float @select_fneg_both(float %x, float %y, i1 %b) {
616 ; CHECK-LABEL: @select_fneg_both(
617 ; CHECK-NEXT: [[S_V:%.*]] = select i1 [[B:%.*]], float [[X:%.*]], float [[Y:%.*]]
618 ; CHECK-NEXT: ret float [[S_V]]
622 %s = select i1 %b, float %nx, float %ny
627 define float @select_fneg_use1(float %x, float %y, i1 %b) {
628 ; CHECK-LABEL: @select_fneg_use1(
629 ; CHECK-NEXT: [[NX:%.*]] = fneg ninf float [[X:%.*]]
630 ; CHECK-NEXT: call void @use(float [[NX]])
631 ; CHECK-NEXT: [[Y_NEG:%.*]] = fneg float [[Y:%.*]]
632 ; CHECK-NEXT: [[R:%.*]] = select i1 [[B:%.*]], float [[X]], float [[Y_NEG]]
633 ; CHECK-NEXT: ret float [[R]]
635 %nx = fneg ninf float %x
636 call void @use(float %nx)
637 %s = select fast i1 %b, float %nx, float %y
642 define float @select_fneg_use2(float %x, float %y, i1 %b) {
643 ; CHECK-LABEL: @select_fneg_use2(
644 ; CHECK-NEXT: call void @use(float [[Y:%.*]])
645 ; CHECK-NEXT: [[Y_NEG:%.*]] = fneg fast float [[Y]]
646 ; CHECK-NEXT: [[R:%.*]] = select reassoc nnan ninf arcp contract afn i1 [[B:%.*]], float [[X:%.*]], float [[Y_NEG]]
647 ; CHECK-NEXT: ret float [[R]]
649 call void @use(float %y)
650 %nx = fneg nsz float %x
651 %s = select ninf i1 %b, float %nx, float %y
652 %r = fneg fast float %s
658 define float @select_fneg_use3(float %x, float %y, i1 %b) {
659 ; CHECK-LABEL: @select_fneg_use3(
660 ; CHECK-NEXT: [[NX:%.*]] = fneg float [[X:%.*]]
661 ; CHECK-NEXT: [[S:%.*]] = select i1 [[B:%.*]], float [[NX]], float [[Y:%.*]]
662 ; CHECK-NEXT: call void @use(float [[S]])
663 ; CHECK-NEXT: [[R:%.*]] = fneg float [[S]]
664 ; CHECK-NEXT: ret float [[R]]
667 %s = select i1 %b, float %nx, float %y
668 call void @use(float %s)