@@ -378,6 +378,8 @@ define float @fneg_fneg_sel_extra_use3(float %x, float %y, i1 %cond) {
378
378
ret float %sel
379
379
}
380
380
381
+ ; Negative test
382
+
381
383
define float @fneg_fadd_constant (float %x ) {
382
384
; CHECK-LABEL: @fneg_fadd_constant(
383
385
; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
@@ -389,6 +391,8 @@ define float @fneg_fadd_constant(float %x) {
389
391
ret float %r
390
392
}
391
393
394
+ ; Negative test
395
+
392
396
define float @fake_nsz_fadd_constant (float %x ) {
393
397
; CHECK-LABEL: @fake_nsz_fadd_constant(
394
398
; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
@@ -400,32 +404,32 @@ define float @fake_nsz_fadd_constant(float %x) {
400
404
ret float %r
401
405
}
402
406
403
- ; TODO: -(X + C) --> -C - X
407
+ ; -(X + C) --> -C - X
404
408
405
409
define float @fneg_nsz_fadd_constant (float %x ) {
406
410
; CHECK-LABEL: @fneg_nsz_fadd_constant(
407
- ; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
408
- ; CHECK-NEXT: [[R:%.*]] = fneg nsz float [[A]]
411
+ ; CHECK-NEXT: [[R:%.*]] = fsub nsz float -4.200000e+01, [[X:%.*]]
409
412
; CHECK-NEXT: ret float [[R]]
410
413
;
411
414
%a = fadd float %x , 42 .0
412
415
%r = fneg nsz float %a
413
416
ret float %r
414
417
}
415
418
416
- ; TODO: -(X + C) --> -C - X
419
+ ; -(X + C) --> -C - X
417
420
418
421
define float @fake_fneg_nsz_fadd_constant (float %x ) {
419
422
; CHECK-LABEL: @fake_fneg_nsz_fadd_constant(
420
- ; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
421
- ; CHECK-NEXT: [[R:%.*]] = fsub fast float -0.000000e+00, [[A]]
423
+ ; CHECK-NEXT: [[R:%.*]] = fsub fast float -4.200000e+01, [[X:%.*]]
422
424
; CHECK-NEXT: ret float [[R]]
423
425
;
424
426
%a = fadd float %x , 42 .0
425
427
%r = fsub fast float -0 .0 , %a
426
428
ret float %r
427
429
}
428
430
431
+ ; Negative test
432
+
429
433
define float @fneg_nsz_fadd_constant_extra_use (float %x ) {
430
434
; CHECK-LABEL: @fneg_nsz_fadd_constant_extra_use(
431
435
; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
@@ -439,6 +443,8 @@ define float @fneg_nsz_fadd_constant_extra_use(float %x) {
439
443
ret float %r
440
444
}
441
445
446
+ ; Negative test
447
+
442
448
define float @fake_fneg_nsz_fadd_constant_extra_use (float %x ) {
443
449
; CHECK-LABEL: @fake_fneg_nsz_fadd_constant_extra_use(
444
450
; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
@@ -452,28 +458,48 @@ define float @fake_fneg_nsz_fadd_constant_extra_use(float %x) {
452
458
ret float %r
453
459
}
454
460
455
- ; TODO: -(X + C) --> -C - X
461
+ ; -(X + C) --> -C - X
456
462
457
463
define <2 x float > @fneg_nsz_fadd_constant_vec (<2 x float > %x ) {
458
464
; CHECK-LABEL: @fneg_nsz_fadd_constant_vec(
459
- ; CHECK-NEXT: [[A:%.*]] = fadd <2 x float> [[X:%.*]], <float 4.200000e+01, float 4.300000e+01>
460
- ; CHECK-NEXT: [[R:%.*]] = fneg reassoc nnan nsz <2 x float> [[A]]
465
+ ; CHECK-NEXT: [[R:%.*]] = fsub reassoc nnan nsz <2 x float> <float -4.200000e+01, float -4.300000e+01>, [[X:%.*]]
461
466
; CHECK-NEXT: ret <2 x float> [[R]]
462
467
;
463
468
%a = fadd <2 x float > %x , <float 42 .0 , float 43 .0 >
464
469
%r = fneg nsz nnan reassoc <2 x float > %a
465
470
ret <2 x float > %r
466
471
}
467
472
468
- ; TODO: -(X + C) --> -C - X
473
+ ; -(X + C) --> -C - X
469
474
470
475
define <2 x float > @fake_fneg_nsz_fadd_constant_vec (<2 x float > %x ) {
471
476
; CHECK-LABEL: @fake_fneg_nsz_fadd_constant_vec(
472
- ; CHECK-NEXT: [[A:%.*]] = fadd <2 x float> [[X:%.*]], <float 4.200000e+01, float undef>
473
- ; CHECK-NEXT: [[R:%.*]] = fsub nsz <2 x float> <float undef, float -0.000000e+00>, [[A]]
477
+ ; CHECK-NEXT: [[R:%.*]] = fsub nsz <2 x float> <float -4.200000e+01, float undef>, [[X:%.*]]
474
478
; CHECK-NEXT: ret <2 x float> [[R]]
475
479
;
476
480
%a = fadd <2 x float > %x , <float 42 .0 , float undef >
477
481
%r = fsub nsz <2 x float > <float undef , float -0 .0 >, %a
478
482
ret <2 x float > %r
479
483
}
484
+
485
+ @g = external global i16 , align 1
486
+
487
+ define float @fneg_nsz_fadd_constant_expr (float %x ) {
488
+ ; CHECK-LABEL: @fneg_nsz_fadd_constant_expr(
489
+ ; CHECK-NEXT: [[R:%.*]] = fsub nsz float fneg (float bitcast (i32 ptrtoint (i16* @g to i32) to float)), [[X:%.*]]
490
+ ; CHECK-NEXT: ret float [[R]]
491
+ ;
492
+ %a = fadd float %x , bitcast (i32 ptrtoint (i16* @g to i32 ) to float )
493
+ %r = fneg nsz float %a
494
+ ret float %r
495
+ }
496
+
497
+ define float @fake_fneg_nsz_fadd_constant_expr (float %x ) {
498
+ ; CHECK-LABEL: @fake_fneg_nsz_fadd_constant_expr(
499
+ ; CHECK-NEXT: [[R:%.*]] = fsub nsz float fneg (float bitcast (i32 ptrtoint (i16* @g to i32) to float)), [[X:%.*]]
500
+ ; CHECK-NEXT: ret float [[R]]
501
+ ;
502
+ %a = fadd float %x , bitcast (i32 ptrtoint (i16* @g to i32 ) to float )
503
+ %r = fsub nsz float -0 .0 , %a
504
+ ret float %r
505
+ }
0 commit comments