llvm.org GIT mirror llvm / 5cb5321
[NFC][Reassociate] Add unary fneg tests to fast-basictest.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362630 91177308-0d34-0410-b5e6-96231b3b80d8 Cameron McInally 3 months ago
1 changed file(s) with 69 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
199199 ret float %C
200200 }
201201
202 define float @test8_unary_fneg(float %X, float %Y, float %Z) {
203 ; CHECK-LABEL: @test8_unary_fneg(
204 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X:%.*]], [[Y:%.*]]
205 ; CHECK-NEXT: [[C:%.*]] = fsub fast float [[Z:%.*]], [[TMP1]]
206 ; CHECK-NEXT: ret float [[C]]
207 ;
208 %A = fneg fast float %X
209 %B = fmul fast float %A, %Y
210 %C = fadd fast float %B, %Z
211 ret float %C
212 }
213
202214 define float @test8_reassoc(float %X, float %Y, float %Z) {
203215 ; CHECK-LABEL: @test8_reassoc(
204216 ; CHECK-NEXT: [[A:%.*]] = fsub reassoc float 0.000000e+00, [[X:%.*]]
383395 ret float %D
384396 }
385397
398 define float @test13_unary_fneg(float %X1, float %X2, float %X3) {
399 ; CHECK-LABEL: @test13_unary_fneg(
400 ; CHECK-NEXT: [[TMP1:%.*]] = fsub fast float [[X3:%.*]], [[X2:%.*]]
401 ; CHECK-NEXT: [[D:%.*]] = fmul fast float [[TMP1]], [[X1:%.*]]
402 ; CHECK-NEXT: ret float [[D]]
403 ;
404 %A = fneg fast float %X1
405 %B = fmul fast float %A, %X2 ; -X1*X2
406 %C = fmul fast float %X1, %X3 ; X1*X3
407 %D = fadd fast float %B, %C ; -X1*X2 + X1*X3 -> X1*(X3-X2)
408 ret float %D
409 }
410
386411 define float @test13_reassoc(float %X1, float %X2, float %X3) {
387412 ; CHECK-LABEL: @test13_reassoc(
388413 ; CHECK-NEXT: [[A:%.*]] = fsub reassoc float 0.000000e+00, [[X1:%.*]]
471496 ret float %4
472497 }
473498
499 define float @test16_unary_fneg(float %b, float %a) {
500 ; CHECK-LABEL: @test16_unary_fneg(
501 ; CHECK-NEXT: [[TMP1:%.*]] = fadd fast float [[B:%.*]], 1.234000e+03
502 ; CHECK-NEXT: ret float [[TMP1]]
503 ;
504 %1 = fadd fast float %a, 1234.0
505 %2 = fadd fast float %b, %1
506 %3 = fneg fast float %a
507 %4 = fadd fast float %2, %3
508 ret float %4
509 }
510
474511 define float @test16_reassoc(float %b, float %a) {
475512 ; CHECK-LABEL: @test16_reassoc(
476513 ; CHECK-NEXT: [[TMP1:%.*]] = fadd reassoc float [[A:%.*]], 1.234000e+03
496533 ; CHECK-NEXT: ret float [[G]]
497534 ;
498535 %c = fsub fast float 0.000000e+00, %z
536 %d = fmul fast float %a, %b
537 %e = fmul fast float %c, %d
538 %f = fmul fast float %e, 1.234500e+04
539 %g = fsub fast float 0.000000e+00, %f
540 ret float %g
541 }
542
543 ; FIXME: This reassociation is not working.
544 define float @test17_unary_fneg(float %a, float %b, float %z) {
545 ; CHECK-LABEL: @test17_unary_fneg(
546 ; CHECK-NEXT: [[E:%.*]] = fmul fast float [[A:%.*]], -1.234500e+04
547 ; CHECK-NEXT: [[F:%.*]] = fmul fast float [[E]], [[B:%.*]]
548 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[F]], [[Z:%.*]]
549 ; CHECK-NEXT: [[G:%.*]] = fsub fast float -0.000000e+00, [[TMP1]]
550 ; CHECK-NEXT: ret float [[G]]
551 ;
552 %c = fneg fast float %z
499553 %d = fmul fast float %a, %b
500554 %e = fmul fast float %c, %d
501555 %f = fmul fast float %e, 1.234500e+04
528582 ;
529583 %d = fmul fast float %z, 4.000000e+01
530584 %c = fsub fast float 0.000000e+00, %d
585 %e = fmul fast float %a, %c
586 %f = fsub fast float 0.000000e+00, %e
587 ret float %f
588 }
589
590 ; FIXME: This reassociation is not working.
591 define float @test18_unary_fneg(float %a, float %b, float %z) {
592 ; CHECK-LABEL: @test18_unary_fneg(
593 ; CHECK-NEXT: [[C:%.*]] = fmul fast float [[Z:%.*]], -4.000000e+01
594 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[C]], [[A:%.*]]
595 ; CHECK-NEXT: [[F:%.*]] = fsub fast float -0.000000e+00, [[TMP1]]
596 ; CHECK-NEXT: ret float [[F]]
597 ;
598 %d = fmul fast float %z, 4.000000e+01
599 %c = fneg fast float %d
531600 %e = fmul fast float %a, %c
532601 %f = fsub fast float 0.000000e+00, %e
533602 ret float %f