public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: michaels@stochastik.rwth-aachen.de
To: gcc-gnats@gcc.gnu.org
Subject: target/5728: GCC generated non-optimal code for Hitachi SH-4
Date: Tue, 19 Feb 2002 07:46:00 -0000	[thread overview]
Message-ID: <20020219153819.25152.qmail@sources.redhat.com> (raw)


>Number:         5728
>Category:       target
>Synopsis:       GCC generated non-optimal code for Hitachi SH-4
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 19 07:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     michaels@stochastik.rwth-aachen.de
>Release:        gcc version 3.0.4 20020215 (prerelease)
>Organization:
>Environment:
Debian Linux i686 host
Hitachi SH-4 embedded target
compiler built for sh-elf
>Description:
it seems gcc misses some quite obvious optimizations for Hitachi SH-4, and
it even got worse since V3.0.1. The behaviour described here was verified
with 3.0.3 and 3.0.4 20020215 (prerelease).

Without -frename-registers, an additional unnecessary move is generated.

The superfluous instructions are marked in the included assembly output.
>How-To-Repeat:
sh-elf-gcc -m4 -fomit-frame-pointer -Os -S -frename-registers test1.c
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="sh-gcc.txt"
Content-Disposition: inline; filename="sh-gcc.txt"

typedef unsigned long tU32;
typedef unsigned long long tU64;

tU32 test3(tU32 nus, tU32 mult)
{
  tU32 tmp = ((tU64) nus * (tU64) mult)>>32;
  return tmp + 1;
}


/opt/cgcc2/bin/sh-elf-gcc -m4 -fomit-frame-pointer -Os -S -frename-registers test1.c

        .file   "test1.c"
        .text
        .align 1
        .global _test3
        .type   _test3,@function
_test3:
        mov     r4,r2    ! this move can be eliminated
        nop              ! why is this NOP necessary?
        dmulu.l r5,r2
        sts.l   pr,@-r15 ! this can be eliminated - V3.0.1 does this!
        lds.l   @r15+,pr ! this can be eliminated - V3.0.1 does this!
        sts     mach,r0
        mov     r0,r3    ! this move can be eliminated
        rts     
        add     #1,r0
.Lfe1:
        .size   _test3,.Lfe1-_test3
        .ident  "GCC: (GNU) 3.0.4 20020215 (prerelease)"


             reply	other threads:[~2002-02-19 15:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-19  7:46 michaels [this message]
2002-03-29 18:41 rth

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=20020219153819.25152.qmail@sources.redhat.com \
    --to=michaels@stochastik.rwth-aachen.de \
    --cc=gcc-gnats@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).