llvm.org GIT mirror llvm / a9445e1
Floating-point add, sub, and mul are now spelled fadd, fsub, and fmul, respectively. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97531 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 9 years ago
17 changed file(s) with 100 addition(s) and 100 deletion(s). Raw diff Collapse all Expand all
10401040
10411041
10421042

                  
                
1043 %t1 = add float %W, %X
1044 %t2 = mul float %t1, %Y
1045 %t3 = add float %t2, %Z
1043 %t1 = fadd float %W, %X
1044 %t2 = fmul float %t1, %Y
1045 %t3 = fadd float %t2, %Z
10461046
10471047
10481048
553553 Read function definition:
554554 define double @foo(double %a, double %b) {
555555 entry:
556 %multmp = mul double %a, %a
557 %multmp1 = mul double 2.000000e+00, %a
558 %multmp2 = mul double %multmp1, %b
559 %addtmp = add double %multmp, %multmp2
560 %multmp3 = mul double %b, %b
561 %addtmp4 = add double %addtmp, %multmp3
556 %multmp = fmul double %a, %a
557 %multmp1 = fmul double 2.000000e+00, %a
558 %multmp2 = fmul double %multmp1, %b
559 %addtmp = fadd double %multmp, %multmp2
560 %multmp3 = fmul double %b, %b
561 %addtmp4 = fadd double %addtmp, %multmp3
562562 ret double %addtmp4
563563 }
564564
575575 entry:
576576 %calltmp = call double @foo( double %a, double 4.000000e+00 )
577577 %calltmp1 = call double @bar( double 3.133700e+04 )
578 %addtmp = add double %calltmp, %calltmp1
578 %addtmp = fadd double %calltmp, %calltmp1
579579 ret double %addtmp
580580 }
581581
611611
612612 define double @""() {
613613 entry:
614 %addtmp = add double 4.000000e+00, 5.000000e+00
614 %addtmp = fadd double 4.000000e+00, 5.000000e+00
615615 ret double %addtmp
616616 }
617617
618618 define double @foo(double %a, double %b) {
619619 entry:
620 %multmp = mul double %a, %a
621 %multmp1 = mul double 2.000000e+00, %a
622 %multmp2 = mul double %multmp1, %b
623 %addtmp = add double %multmp, %multmp2
624 %multmp3 = mul double %b, %b
625 %addtmp4 = add double %addtmp, %multmp3
620 %multmp = fmul double %a, %a
621 %multmp1 = fmul double 2.000000e+00, %a
622 %multmp2 = fmul double %multmp1, %b
623 %addtmp = fadd double %multmp, %multmp2
624 %multmp3 = fmul double %b, %b
625 %addtmp4 = fadd double %addtmp, %multmp3
626626 ret double %addtmp4
627627 }
628628
630630 entry:
631631 %calltmp = call double @foo( double %a, double 4.000000e+00 )
632632 %calltmp1 = call double @bar( double 3.133700e+04 )
633 %addtmp = add double %calltmp, %calltmp1
633 %addtmp = fadd double %calltmp, %calltmp1
634634 ret double %addtmp
635635 }
636636
6464 Read function definition:
6565 define double @test(double %x) {
6666 entry:
67 %addtmp = add double 3.000000e+00, %x
67 %addtmp = fadd double 3.000000e+00, %x
6868 ret double %addtmp
6969 }
7070
7979 Read function definition:
8080 define double @test(double %x) {
8181 entry:
82 %addtmp = add double 2.000000e+00, 1.000000e+00
83 %addtmp1 = add double %addtmp, %x
82 %addtmp = fadd double 2.000000e+00, 1.000000e+00
83 %addtmp1 = fadd double %addtmp, %x
8484 ret double %addtmp1
8585 }
8686
112112 ready> Read function definition:
113113 define double @test(double %x) {
114114 entry:
115 %addtmp = add double 3.000000e+00, %x
116 %addtmp1 = add double %x, 3.000000e+00
117 %multmp = mul double %addtmp, %addtmp1
115 %addtmp = fadd double 3.000000e+00, %x
116 %addtmp1 = fadd double %x, 3.000000e+00
117 %multmp = fmul double %addtmp, %addtmp1
118118 ret double %multmp
119119 }
120120
239239 ready> Read function definition:
240240 define double @test(double %x) {
241241 entry:
242 %addtmp = add double %x, 3.000000e+00
243 %multmp = mul double %addtmp, %addtmp
242 %addtmp = fadd double %x, 3.000000e+00
243 %multmp = fmul double %addtmp, %addtmp
244244 ret double %multmp
245245 }
246246
362362 Read function definition:
363363 define double @testfunc(double %x, double %y) {
364364 entry:
365 %multmp = mul double %y, 2.000000e+00
366 %addtmp = add double %multmp, %x
365 %multmp = fmul double %y, 2.000000e+00
366 %addtmp = fadd double %multmp, %x
367367 ret double %addtmp
368368 }
369369
410410 define double @foo(double %x) {
411411 entry:
412412 %calltmp = call double @sin( double %x )
413 %multmp = mul double %calltmp, %calltmp
413 %multmp = fmul double %calltmp, %calltmp
414414 %calltmp2 = call double @cos( double %x )
415 %multmp4 = mul double %calltmp2, %calltmp2
416 %addtmp = add double %multmp, %multmp4
415 %multmp4 = fmul double %calltmp2, %calltmp2
416 %addtmp = fadd double %multmp, %multmp4
417417 ret double %addtmp
418418 }
419419
677677 ; body
678678 %calltmp = call double @putchard( double 4.200000e+01 )
679679 ; increment
680 %nextvar = add double %i, 1.000000e+00
680 %nextvar = fadd double %i, 1.000000e+00
681681
682682 ; termination test
683683 %cmptmp = fcmp ult double %i, %n
556556
557557 else: ; preds = %entry
558558 %x3 = load double* %x1
559 %subtmp = sub double %x3, 1.000000e+00
559 %subtmp = fsub double %x3, 1.000000e+00
560560 %calltmp = call double @fib( double %subtmp )
561561 %x4 = load double* %x1
562 %subtmp5 = sub double %x4, 2.000000e+00
562 %subtmp5 = fsub double %x4, 2.000000e+00
563563 %calltmp6 = call double @fib( double %subtmp5 )
564 %addtmp = add double %calltmp, %calltmp6
564 %addtmp = fadd double %calltmp, %calltmp6
565565 br label %ifcont
566566
567567 ifcont: ; preds = %else, %then
594594 br label %ifcont
595595
596596 else:
597 %subtmp = sub double %x, 1.000000e+00
597 %subtmp = fsub double %x, 1.000000e+00
598598 %calltmp = call double @fib( double %subtmp )
599 %subtmp5 = sub double %x, 2.000000e+00
599 %subtmp5 = fsub double %x, 2.000000e+00
600600 %calltmp6 = call double @fib( double %subtmp5 )
601 %addtmp = add double %calltmp, %calltmp6
601 %addtmp = fadd double %calltmp, %calltmp6
602602 br label %ifcont
603603
604604 ifcont: ; preds = %else, %then
624624 br i1 %ifcond, label %else, label %ifcont
625625
626626 else:
627 %subtmp = sub double %x, 1.000000e+00
627 %subtmp = fsub double %x, 1.000000e+00
628628 %calltmp = call double @fib( double %subtmp )
629 %subtmp5 = sub double %x, 2.000000e+00
629 %subtmp5 = fsub double %x, 2.000000e+00
630630 %calltmp6 = call double @fib( double %subtmp5 )
631 %addtmp = add double %calltmp, %calltmp6
631 %addtmp = fadd double %calltmp, %calltmp6
632632 ret double %addtmp
633633
634634 ifcont:
483483 Read top-level expression:
484484 define double @""() {
485485 entry:
486 %addtmp = add double 4.000000e+00, 5.000000e+00
486 %addtmp = fadd double 4.000000e+00, 5.000000e+00
487487 ret double %addtmp
488488 }
489489
502502 Read function definition:
503503 define double @foo(double %a, double %b) {
504504 entry:
505 %multmp = mul double %a, %a
506 %multmp1 = mul double 2.000000e+00, %a
507 %multmp2 = mul double %multmp1, %b
508 %addtmp = add double %multmp, %multmp2
509 %multmp3 = mul double %b, %b
510 %addtmp4 = add double %addtmp, %multmp3
505 %multmp = fmul double %a, %a
506 %multmp1 = fmul double 2.000000e+00, %a
507 %multmp2 = fmul double %multmp1, %b
508 %addtmp = fadd double %multmp, %multmp2
509 %multmp3 = fmul double %b, %b
510 %addtmp4 = fadd double %addtmp, %multmp3
511511 ret double %addtmp4
512512 }
513513
524524 entry:
525525 %calltmp = call double @foo( double %a, double 4.000000e+00 )
526526 %calltmp1 = call double @bar( double 3.133700e+04 )
527 %addtmp = add double %calltmp, %calltmp1
527 %addtmp = fadd double %calltmp, %calltmp1
528528 ret double %addtmp
529529 }
530530
560560
561561 define double @""() {
562562 entry:
563 %addtmp = add double 4.000000e+00, 5.000000e+00
563 %addtmp = fadd double 4.000000e+00, 5.000000e+00
564564 ret double %addtmp
565565 }
566566
567567 define double @foo(double %a, double %b) {
568568 entry:
569 %multmp = mul double %a, %a
570 %multmp1 = mul double 2.000000e+00, %a
571 %multmp2 = mul double %multmp1, %b
572 %addtmp = add double %multmp, %multmp2
573 %multmp3 = mul double %b, %b
574 %addtmp4 = add double %addtmp, %multmp3
569 %multmp = fmul double %a, %a
570 %multmp1 = fmul double 2.000000e+00, %a
571 %multmp2 = fmul double %multmp1, %b
572 %addtmp = fadd double %multmp, %multmp2
573 %multmp3 = fmul double %b, %b
574 %addtmp4 = fadd double %addtmp, %multmp3
575575 ret double %addtmp4
576576 }
577577
579579 entry:
580580 %calltmp = call double @foo( double %a, double 4.000000e+00 )
581581 %calltmp1 = call double @bar( double 3.133700e+04 )
582 %addtmp = add double %calltmp, %calltmp1
582 %addtmp = fadd double %calltmp, %calltmp1
583583 ret double %addtmp
584584 }
585585
7171 Read function definition:
7272 define double @test(double %x) {
7373 entry:
74 %addtmp = add double 1.000000e+00, 2.000000e+00
75 %addtmp1 = add double %addtmp, %x
74 %addtmp = fadd double 1.000000e+00, 2.000000e+00
75 %addtmp1 = fadd double %addtmp, %x
7676 ret double %addtmp1
7777 }
7878
103103 Read function definition:
104104 define double @test(double %x) {
105105 entry:
106 %addtmp = add double 3.000000e+00, %x
106 %addtmp = fadd double 3.000000e+00, %x
107107 ret double %addtmp
108108 }
109109
126126 ready> Read function definition:
127127 define double @test(double %x) {
128128 entry:
129 %addtmp = add double 3.000000e+00, %x
130 %addtmp1 = add double %x, 3.000000e+00
131 %multmp = mul double %addtmp, %addtmp1
129 %addtmp = fadd double 3.000000e+00, %x
130 %addtmp1 = fadd double %x, 3.000000e+00
131 %multmp = fmul double %addtmp, %addtmp1
132132 ret double %multmp
133133 }
134134
266266 ready> Read function definition:
267267 define double @test(double %x) {
268268 entry:
269 %addtmp = add double %x, 3.000000e+00
270 %multmp = mul double %addtmp, %addtmp
269 %addtmp = fadd double %x, 3.000000e+00
270 %multmp = fmul double %addtmp, %addtmp
271271 ret double %multmp
272272 }
273273
387387 Read function definition:
388388 define double @testfunc(double %x, double %y) {
389389 entry:
390 %multmp = mul double %y, 2.000000e+00
391 %addtmp = add double %multmp, %x
390 %multmp = fmul double %y, 2.000000e+00
391 %addtmp = fadd double %multmp, %x
392392 ret double %addtmp
393393 }
394394
435435 define double @foo(double %x) {
436436 entry:
437437 %calltmp = call double @sin( double %x )
438 %multmp = mul double %calltmp, %calltmp
438 %multmp = fmul double %calltmp, %calltmp
439439 %calltmp2 = call double @cos( double %x )
440 %multmp4 = mul double %calltmp2, %calltmp2
441 %addtmp = add double %multmp, %multmp4
440 %multmp4 = fmul double %calltmp2, %calltmp2
441 %addtmp = fadd double %multmp, %multmp4
442442 ret double %addtmp
443443 }
444444
652652 ; body
653653 %calltmp = call double @putchard( double 4.200000e+01 )
654654 ; increment
655 %nextvar = add double %i, 1.000000e+00
655 %nextvar = fadd double %i, 1.000000e+00
656656
657657 ; termination test
658658 %cmptmp = fcmp ult double %i, %n
580580
581581 else: ; preds = %entry
582582 %x3 = load double* %x1
583 %subtmp = sub double %x3, 1.000000e+00
583 %subtmp = fsub double %x3, 1.000000e+00
584584 %calltmp = call double @fib( double %subtmp )
585585 %x4 = load double* %x1
586 %subtmp5 = sub double %x4, 2.000000e+00
586 %subtmp5 = fsub double %x4, 2.000000e+00
587587 %calltmp6 = call double @fib( double %subtmp5 )
588 %addtmp = add double %calltmp, %calltmp6
588 %addtmp = fadd double %calltmp, %calltmp6
589589 br label %ifcont
590590
591591 ifcont: ; preds = %else, %then
618618 br label %ifcont
619619
620620 else:
621 %subtmp = sub double %x, 1.000000e+00
621 %subtmp = fsub double %x, 1.000000e+00
622622 %calltmp = call double @fib( double %subtmp )
623 %subtmp5 = sub double %x, 2.000000e+00
623 %subtmp5 = fsub double %x, 2.000000e+00
624624 %calltmp6 = call double @fib( double %subtmp5 )
625 %addtmp = add double %calltmp, %calltmp6
625 %addtmp = fadd double %calltmp, %calltmp6
626626 br label %ifcont
627627
628628 ifcont: ; preds = %else, %then
648648 br i1 %ifcond, label %else, label %ifcont
649649
650650 else:
651 %subtmp = sub double %x, 1.000000e+00
651 %subtmp = fsub double %x, 1.000000e+00
652652 %calltmp = call double @fib( double %subtmp )
653 %subtmp5 = sub double %x, 2.000000e+00
653 %subtmp5 = fsub double %x, 2.000000e+00
654654 %calltmp6 = call double @fib( double %subtmp5 )
655 %addtmp = add double %calltmp, %calltmp6
655 %addtmp = fadd double %calltmp, %calltmp6
656656 ret double %addtmp
657657
658658 ifcont:
888888 ; recognize a more elaborate tree than a simple SETxx.
889889
890890 define double @test_FNEG_sel(double %A, double %B, double %C) {
891 %D = sub double -0.000000e+00, %A ; [#uses=1]
891 %D = fsub double -0.000000e+00, %A ; [#uses=1]
892892 %Cond = fcmp ugt double %D, -0.000000e+00 ; [#uses=1]
893893 %E = select i1 %Cond, double %B, double %C ; [#uses=1]
894894 ret double %E
6666 [ %tmp.34.i18, %no_exit.i7 ]
6767 %tmp.0.0.0.i10 = phi double [ 0.000000e+00, %build_tree.exit ],
6868 [ %tmp.28.i16, %no_exit.i7 ]
69 %tmp.28.i16 = add double %tmp.0.0.0.i10, 0.000000e+00
70 %tmp.34.i18 = add double %tmp.0.1.0.i9, 0.000000e+00
69 %tmp.28.i16 = fadd double %tmp.0.0.0.i10, 0.000000e+00
70 %tmp.34.i18 = fadd double %tmp.0.1.0.i9, 0.000000e+00
7171 br i1 false, label %Compute_Tree.exit23, label %no_exit.i7
7272
7373 Compute_Tree.exit23: ; preds = %no_exit.i7
9696
9797 double %X(double %Y, double %Z, double %A, double %B) {
9898 %C = setlt double %A, %B
99 %z = add double %Z, 0.0 ;; select operand is not a load
99 %z = fadd double %Z, 0.0 ;; select operand is not a load
100100 %D = select bool %C, double %Y, double %z
101101 ret double %D
102102 }
544544
545545 define i64 @ccosf(float %z.0, float %z.1) nounwind readonly {
546546 entry:
547 %tmp6 = sub float -0.000000e+00, %z.1 ; [#uses=1]
547 %tmp6 = fsub float -0.000000e+00, %z.1 ; [#uses=1]
548548 %tmp20 = tail call i64 @ccoshf( float %tmp6, float %z.0 ) nounwind readonly
549549 ret i64 %tmp20
550550 }
372372 if (CFP->getValueAPF().isPosZero() && CannotBeNegativeZero(LHS))
373373 return ReplaceInstUsesWith(I, LHS);
374374
375 // Check for (add double (sitofp x), y), see if we can merge this into an
375 // Check for (fadd double (sitofp x), y), see if we can merge this into an
376376 // integer add followed by a promotion.
377377 if (SIToFPInst *LHSConv = dyn_cast(LHS)) {
378 // (add double (sitofp x), fpcst) --> (sitofp (add int x, intcst))
378 // (fadd double (sitofp x), fpcst) --> (sitofp (add int x, intcst))
379379 // ... if the constant fits in the integer value. This is useful for things
380380 // like (double)(x & 1234) + 4.0 -> (double)((X & 1234)+4) which no longer
381381 // requires a constant pool load, and generally allows the add to be better
393393 }
394394 }
395395
396 // (add double (sitofp x), (sitofp y)) --> (sitofp (add int x, y))
396 // (fadd double (sitofp x), (sitofp y)) --> (sitofp (add int x, y))
397397 if (SIToFPInst *RHSConv = dyn_cast(RHS)) {
398398 // Only do this if x/y have the same type, if at last one of them has a
399399 // single use (so we don't increase the number of int->fp conversions),
202202 // "In IEEE floating point, x*1 is not equivalent to x for nans. However,
203203 // ANSI says we can drop signals, so we can do this anyway." (from GCC)
204204 if (Op1F->isExactlyValue(1.0))
205 return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0'
205 return ReplaceInstUsesWith(I, Op0); // Eliminate 'fmul double %X, 1.0'
206206 } else if (Op1C->getType()->isVectorTy()) {
207207 if (ConstantVector *Op1V = dyn_cast(Op1C)) {
208208 // As above, vector X*splat(1.0) -> X in all defined cases.
22
33 define i32 @main() {
44 %a = add i32 0, undef
5 %b = add float 0.0, undef
6 %c = add double 0.0, undef
5 %b = fadd float 0.0, undef
6 %c = fadd double 0.0, undef
77 ret i32 0
88 }
None ; RUN: opt < %s -instcombine -S | grep {add double .sx, .sy}
0 ; RUN: opt < %s -instcombine -S | grep {fadd double .sx, .sy}
11 ; The 'or' has multiple uses, make sure that this doesn't prevent instcombine
22 ; from propagating the extends to the truncs.
33
0 ; RUN: opt < %s -instcombine -S | \
1 ; RUN: grep {add float}
1 ; RUN: grep {fadd float}
22
33 %V = type <4 x float>
44
143143 store double %tmp64, double* %tmp62
144144 %tmp65 = call double* @_ZN6QSizeF6rwidthEv( %struct.QPointF* %scaledPageSize ) ; [#uses=2]
145145 %tmp67 = load double* %tmp65 ; [#uses=1]
146 %tmp69 = mul double %tmp67, %tmp48 ; [#uses=1]
146 %tmp69 = fmul double %tmp67, %tmp48 ; [#uses=1]
147147 store double %tmp69, double* %tmp65
148148 %tmp71 = call double* @_ZN6QSizeF7rheightEv( %struct.QPointF* %scaledPageSize ) ; [#uses=2]
149149 %tmp73 = load double* %tmp71 ; [#uses=1]
150 %tmp75 = mul double %tmp73, %tmp54 ; [#uses=1]
150 %tmp75 = fmul double %tmp73, %tmp54 ; [#uses=1]
151151 store double %tmp75, double* %tmp71
152152 %tmp78 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1]
153153 %tmp80 = invoke i32 @_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp78 )
189189 to label %invcont106 unwind label %cleanup329 ; [#uses=1]
190190 invcont106: ; preds = %invcont104
191191 %tmp108 = sitofp i32 %tmp107 to double ; [#uses=1]
192 %tmp109 = mul double %tmp108, 0x3FE93264C993264C ; [#uses=1]
192 %tmp109 = fmul double %tmp108, 0x3FE93264C993264C ; [#uses=1]
193193 %tmp109.upgrd.17 = fptosi double %tmp109 to i32 ; [#uses=3]
194194 %tmp.upgrd.18 = call %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) ; <%struct.QTextBlockGroup*> [#uses=1]
195195 invoke void @_ZNK10QTextFrame11frameFormatEv( %struct.QTextBlockFormat* sret %fmt, %struct.QTextBlockGroup* %tmp.upgrd.18 )
236236 store double %tmp137, double* %tmp135
237237 %tmp138 = call double @_ZNK6QRectF6heightEv( %struct.QRectF* %body ) ; [#uses=1]
238238 %tmp139 = sitofp i32 %tmp109.upgrd.17 to double ; [#uses=1]
239 %tmp140 = sub double %tmp138, %tmp139 ; [#uses=1]
239 %tmp140 = fsub double %tmp138, %tmp139 ; [#uses=1]
240240 %tmp142 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p )
241241 to label %invcont141 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1]
242242 invcont141: ; preds = %invcont124
250250 to label %invcont148 unwind label %cleanup168 ; [#uses=1]
251251 invcont148: ; preds = %invcont146
252252 %tmp149.upgrd.21 = sitofp i32 %tmp149 to double ; [#uses=1]
253 %tmp150 = add double %tmp140, %tmp149.upgrd.21 ; [#uses=1]
253 %tmp150 = fadd double %tmp140, %tmp149.upgrd.21 ; [#uses=1]
254254 %tmp152 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p )
255255 to label %invcont151 unwind label %cleanup168 ; <%struct.QPaintDevice*> [#uses=1]
256256 invcont151: ; preds = %invcont148
260260 %tmp155 = mul i32 %tmp154, 5 ; [#uses=1]
261261 %tmp156 = sdiv i32 %tmp155, 72 ; [#uses=1]
262262 %tmp156.upgrd.22 = sitofp i32 %tmp156 to double ; [#uses=1]
263 %tmp157 = add double %tmp150, %tmp156.upgrd.22 ; [#uses=1]
263 %tmp157 = fadd double %tmp150, %tmp156.upgrd.22 ; [#uses=1]
264264 %tmp158 = call double @_ZNK6QRectF5widthEv( %struct.QRectF* %body ) ; [#uses=1]
265265 %tmp159 = sitofp i32 %tmp109.upgrd.17 to double ; [#uses=1]
266 %tmp160 = sub double %tmp158, %tmp159 ; [#uses=1]
266 %tmp160 = fsub double %tmp158, %tmp159 ; [#uses=1]
267267 call void @_ZN7QPointFC1Edd( %struct.QPointF* %tmp2, double %tmp160, double %tmp157 )
268268 %tmp161 = getelementptr %struct.QPointF* %pageNumberPos, i32 0, i32 0 ; [#uses=1]
269269 %tmp162 = getelementptr %struct.QPointF* %tmp2, i32 0, i32 0 ; [#uses=1]