public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dann at godzilla dot ics dot uci dot edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/16532] New: duplicate function epilogue on sparc
Date: Tue, 13 Jul 2004 21:54:00 -0000	[thread overview]
Message-ID: <20040713215437.16532.dann@godzilla.ics.uci.edu> (raw)

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


             reply	other threads:[~2004-07-13 21:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-13 21:54 dann at godzilla dot ics dot uci dot edu [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040713215437.16532.dann@godzilla.ics.uci.edu \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).