public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: anders.blomdell@control.lth.se
To: gcc-gnats@gcc.gnu.org
Subject: optimization/6080: incorrect loop optimizations
Date: Thu, 28 Mar 2002 02:56:00 -0000	[thread overview]
Message-ID: <20020328104659.27435.qmail@sources.redhat.com> (raw)


>Number:         6080
>Category:       optimization
>Synopsis:       incorrect loop optimizations
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 28 02:56:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Anders Blomdell <anders.blomdell@control.lth.se>
>Release:        3.0.4
>Organization:
>Environment:
System: Linux aljazari 2.4.13-KURT #2 Thu Nov 8 10:49:33 CET 2001 i686 unknown
Architecture: i686

        <machine, os, target, libraries (multiple lines)>
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: m68k-unknown-elf
configured with: ../../../gcc-3.0.4/configure --prefix=/usr/local/packages/cross
/m68k-elf --target=m68k-elf --with-newlib : (reconfigured) ../../../gcc-3.0.4/co
nfigure --prefix=/usr/local/packages/cross/m68k-elf --target=m68k-elf --with-new
lib : (reconfigured) ../../../gcc-3.0.4/configure --with-gcc-version-trigger=/wo
rk/aljazari2/andersb/gnu/gcc-3.0.4/gcc/version.c --host=i686-pc-linux-gnu --pref
ix=/usr/local/packages/cross/m68k-elf --target=m68k-elf --with-newlib --enable-c
hecking=misc,tree,rtl,gc,gcac
>Description:
gcc -O5 makes incorrect loop optimizations on the following code:

// case A: h get called infinite times
static void ug0(unsigned int count)
{
  while (count > 0) { ug0(0); h(); count--; }
}
void uf0() { ug0(1000); }

// case B: h gets called only once
static void sg0(int count)
{
  while (count > 0) { sg0(0); h(); count--; }
}

void sf0() { sg0(1000); }

This is the m68k code that gets produced (ppc code exhibits same problem...)

80000128 <uf0>:
80000128:       4e56 0000       linkw %fp,#0
8000012c:       42a7            clrl %sp@-
8000012e:       6120            bsrs 80000150 <ug0>
80000130:       61ff ffff ffda  bsrl 8000010c <h>
80000136:       588f            addql #4,%sp
80000138:       60f2            bras 8000012c <uf0+0x4>
8000013a:       4e71            nop

8000013c <sf0>:
8000013c:       4e56 0000       linkw %fp,#0
80000140:       42a7            clrl %sp@-
80000142:       6130            bsrs 80000174 <sg0>
80000144:       61ff ffff ffc6  bsrl 8000010c <h>
8000014a:       588f            addql #4,%sp
8000014c:       4e5e            unlk %fp
8000014e:       4e75            rts


>How-To-Repeat:
Compile the testprogram with -O5
>Fix:
Turn off optimization
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-03-28 10:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-28  2:56 anders.blomdell [this message]
2002-12-11 13:56 bangerth

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=20020328104659.27435.qmail@sources.redhat.com \
    --to=anders.blomdell@control.lth.se \
    --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).