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 rtl-optimization/16532] New: duplicate function epilogue on sparc


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


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