From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31620 invoked by alias); 28 Mar 2002 10:56:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 31591 invoked by uid 71); 28 Mar 2002 10:56:02 -0000 Resent-Date: 28 Mar 2002 10:56:02 -0000 Resent-Message-ID: <20020328105602.31590.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, anders.blomdell@control.lth.se Received:(qmail 27436 invoked by uid 61); 28 Mar 2002 10:46:59 -0000 Message-Id:<20020328104659.27435.qmail@sources.redhat.com> Date: Thu, 28 Mar 2002 02:56:00 -0000 From: anders.blomdell@control.lth.se Reply-To: anders.blomdell@control.lth.se To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: optimization/6080: incorrect loop optimizations X-SW-Source: 2002-03/txt/msg01076.txt.bz2 List-Id: >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 >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 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 : 80000128: 4e56 0000 linkw %fp,#0 8000012c: 42a7 clrl %sp@- 8000012e: 6120 bsrs 80000150 80000130: 61ff ffff ffda bsrl 8000010c 80000136: 588f addql #4,%sp 80000138: 60f2 bras 8000012c 8000013a: 4e71 nop 8000013c : 8000013c: 4e56 0000 linkw %fp,#0 80000140: 42a7 clrl %sp@- 80000142: 6130 bsrs 80000174 80000144: 61ff ffff ffc6 bsrl 8000010c 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: