public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/16532] New: duplicate function epilogue on sparc
@ 2004-07-13 21:54 dann at godzilla dot ics dot uci dot edu
  2004-07-13 22:31 ` [Bug target/16532] " pinskia at gcc dot gnu dot org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: dann at godzilla dot ics dot uci dot edu @ 2004-07-13 21:54 UTC (permalink / raw)
  To: gcc-bugs

On sparc-sun-solaris2.7 using 
gcc-3.4.0 -O2 -mcpu=ultrasparc -m32

This function:

extern unsigned char first_one[65536];

int FirstOne(unsigned long long arg1)
{
  if (arg1 >> 48)
    return (first_one[arg1 >> 48]);
  if ((arg1 >> 32) & 65535)
    return (first_one[(arg1 >> 32) & 65535] + 16);
  if ((arg1 >> 16) & 65535)
    return (first_one[(arg1 >> 16) & 65535] + 32);
  return (first_one[arg1 & 65535] + 48);
}

is compiled to: 
FirstOne:
        !#PROLOGUE# 0
        save    %sp, -112, %sp
        !#PROLOGUE# 1
        sethi   %hi(64512), %o3
        mov     0, %o2
        sllx    %i0, 32, %g1
        srl     %i1, 0, %i1
        or      %i1, %g1, %g1
        srlx    %g1, 32, %g1
        srlx    %g1, 32, %i4
        mov     %g1, %i5
        or      %o3, 1023, %o3
        and     %i4, %o2, %o4
        sllx    %i0, 32, %g1
        srl     %i1, 0, %i1
        or      %i1, %g1, %g1
        srlx    %g1, 48, %g1
        srlx    %g1, 32, %i2
        mov     %g1, %i3
        orcc    %i2, %i3, %g0
        be,pt   %icc, .LL2
        and     %i5, %o3, %o5
        sethi   %hi(first_one), %g1
        or      %g1, %lo(first_one), %g1
        ba,pt   %xcc, .LL1
        ldub    [%g1+%i3], %i0
.LL2:
        sethi   %hi(64512), %g1
        orcc    %o4, %o5, %g0
        or      %g1, 1023, %g1
        be,pt   %icc, .LL3
        and     %i5, %g1, %i5
        sethi   %hi(first_one), %g1
        or      %g1, %lo(first_one), %g1
        ldub    [%g1+%i5], %i5
        ba,pt   %xcc, .LL1
        add     %i5, 16, %i0
.LL3:
        sethi   %hi(64512), %g1
        or      %g1, 1023, %g1
        and     %i1, %g1, %i2
        sllx    %i0, 32, %g1
        srl     %i1, 0, %i1
        or      %i1, %g1, %g1
        srlx    %g1, 16, %g1
        srlx    %g1, 32, %i4
        mov     %g1, %i5
        sethi   %hi(64512), %g1
        and     %i4, %o2, %i4
        or      %g1, 1023, %g1
        and     %i5, %g1, %i3
        and     %i5, %o3, %i5
        orcc    %i4, %i5, %g0
        be,pt   %icc, .LL4
        sethi   %hi(first_one), %g1
        or      %g1, %lo(first_one), %g1
        ldub    [%g1+%i3], %i5
        ba,pt   %xcc, .LL1
        add     %i5, 32, %i0
.LL4:
        or      %g1, %lo(first_one), %g1
        ldub    [%g1+%i2], %i5
        add     %i5, 48, %i0
.LL1:
        return  %i7+8
        nop


It is probably better to just duplicate the epilogue instead of using 
"ba,pt   %xcc, .LL1", this is what Forte-7 does (and gcc on x86). 
I don't have mainline gcc built on sparc to see if this is still the case.

The function is from crafty, a different version of this function appears in
186.crafty from SPEC2000, the same problem can be seen in that code. (The code
in SPEC2K, which is functionally equivalent is optimized much better than the
function above).

-- 
           Summary: duplicate function epilogue on sparc
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dann at godzilla dot ics dot uci dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


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

end of thread, other threads:[~2004-09-28  7:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-13 21:54 [Bug rtl-optimization/16532] New: duplicate function epilogue on sparc dann at godzilla dot ics dot uci dot edu
2004-07-13 22:31 ` [Bug target/16532] " pinskia at gcc dot gnu dot org
2004-07-14  7:29 ` [Bug target/16532] Inefficient jump to epilogue ebotcazou at gcc dot gnu dot org
2004-07-14  7:43 ` ebotcazou at gcc dot gnu dot org
2004-07-14 16:19 ` dann at godzilla dot ics dot uci dot edu
2004-08-18 18:30 ` dann at godzilla dot ics dot uci dot edu
2004-08-19 10:13 ` ebotcazou at gcc dot gnu dot org
2004-08-19 16:58 ` dann at godzilla dot ics dot uci dot edu
2004-09-27 20:35 ` pinskia at gcc dot gnu dot org
2004-09-28  6:26 ` cvs-commit at gcc dot gnu dot org
2004-09-28  6:34 ` ebotcazou at gcc dot gnu dot org
2004-09-28  6:57 ` ebotcazou at gcc dot gnu dot org
2004-09-28  7:00 ` ebotcazou at gcc dot gnu dot org
2004-09-28  7:14 ` ebotcazou at gcc dot gnu dot org
2004-09-28  7:17 ` ebotcazou at gcc dot gnu dot org
2004-09-28  7:18 ` ebotcazou 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).