public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/52034] New: __builtin_copysign optimization suboptimal
@ 2012-01-29  0:47 drepper.fsp at gmail dot com
  2012-01-29  2:40 ` [Bug target/52034] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: drepper.fsp at gmail dot com @ 2012-01-29  0:47 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52034
           Summary: __builtin_copysign optimization suboptimal
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: drepper.fsp@gmail.com


The most trivial __builtin_copysign optimization is not optimal:

double f(double a, double b)
{
  return __builtin_copysign(a,b);
}

With gcc 4.6.2 this gets compiled to

    movapd    %xmm1, %xmm2
    andpd    .LC0(%rip), %xmm0
    andpd    .LC1(%rip), %xmm2
    orpd    %xmm2, %xmm0
    ret

There is no reason for %xmm1 to be duplicated to %xmm2.  This is sufficient:

    andpd    .LC0(%rip), %xmm0
    andpd    .LC1(%rip), %xmm1
    orpd    %xmm1, %xmm0
    ret

The same happens with more complicated code sequences.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-04  6:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-29  0:47 [Bug tree-optimization/52034] New: __builtin_copysign optimization suboptimal drepper.fsp at gmail dot com
2012-01-29  2:40 ` [Bug target/52034] " pinskia at gcc dot gnu.org
2012-01-30  9:43 ` rguenth at gcc dot gnu.org
2021-09-04  6:21 ` pinskia at gcc dot gnu.org
2021-09-04  6:36 ` pinskia at gcc dot gnu.org
2021-09-04  6:38 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).