This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/37783] New: double (a+a)-(b+b) fetches constant 2.0, rather than using subtract


the following code
double aaminusbb (const double a, const double b) { return (a+a)-(b+b); }
yields:
        addsd   %xmm0, %xmm0
        mulsd   .LC0(%rip), %xmm1
        addsd   %xmm1, %xmm0
        ret
Where LC0 holds -2.0.

There's a perfectly good subtract instruction.  Using it will avoid the memory
load to fetch the constant -2.0.  Perhaps something like:
        addsd   %xmm0, %xmm0
        addsd   %xmm1, %xmm1
        subsd   %xmm1, %xmm0
        ret


-- 
           Summary: double (a+a)-(b+b) fetches constant 2.0, rather than
                    using subtract
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rrh at google dot com
 GCC build triplet: i686-host_pc-linux-gnu
  GCC host triplet: i686-host_pc-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37783


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]