public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/25972]  New: pack and unpack of long doubles via union generates poor code
@ 2006-01-26 12:24 amodra at bigpond dot net dot au
  2006-01-26 12:28 ` [Bug rtl-optimization/25972] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: amodra at bigpond dot net dot au @ 2006-01-26 12:24 UTC (permalink / raw)
  To: gcc-bugs

Compile the following with -m64 -mlong-double-128 -O2 -S

long double
pack (double a, double aa)
{
  union { long double ld; double d[2]; } u;
  u.d[0] = a;
  u.d[1] = aa;
  return u.ld;
}

void
unpack (long double x, double *a, double *aa)
{
  union { long double ld; double d[2]; } u;
  u.ld = x;
  *a = u.d[0];
  *aa = u.d[1];
}

Results in
[snip]
.L.pack:
        stfd 1,-176(1)
        stfd 14,-144(1)
        nop
        nop
        ld 9,-176(1)
        stfd 2,-176(1)
        std 9,-160(1)
        nop
        ld 10,-176(1)
        std 10,-152(1)
        lfd 13,-160(1)
        fmr 1,13
        lfd 14,-152(1)
        fmr 2,14
        lfd 14,-144(1)
        blr
[snip]
.L.unpack:
        stfd 1,-16(1)
        stfd 2,-8(1)
        nop
        nop
        ld 11,-16(1)
        ld 12,-8(1)
        std 11,0(5)
        std 12,0(6)
        blr

This ought to be
.L.pack:
        blr

.L.unpack:
        stfd 1,0(5)
        stfd 2,0(6)
        blr

ie. packing and unpacking long doubles ought to be nops.  Instead we see
needless moving between fprs and gprs via memory.  This problem affects
functions like __gcc_qadd from rs6000/darwin-ldouble.c


-- 
           Summary: pack and unpack of long doubles via union generates poor
                    code
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: amodra at bigpond dot net dot au
GCC target triplet: powerpc64-linux


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


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

end of thread, other threads:[~2010-04-12 17:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-26 12:24 [Bug rtl-optimization/25972] New: pack and unpack of long doubles via union generates poor code amodra at bigpond dot net dot au
2006-01-26 12:28 ` [Bug rtl-optimization/25972] " pinskia at gcc dot gnu dot org
2007-11-03 17:55 ` pinskia at gcc dot gnu dot org
2007-11-03 18:05 ` pinskia at gcc dot gnu dot org
2009-06-11  1:07 ` bje at gcc dot gnu dot org
2010-04-12 17:45 ` bergner at gcc dot gnu dot 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).