Bug 6405

Summary: Loop-unrolling related performance regressions
Product: gcc Reporter: roger
Component: rtl-optimizationAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, sayle
Priority: P3 Keywords: missed-optimization
Version: 3.1   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:
Attachments: loop.c

Description roger 2002-04-22 07:56:00 UTC
See http://gcc.gnu.org/ml/gcc/2002-02/msg00307.html

With the command line options "-O3 -funroll-loops", GCC 2.96
generates better code for the attached loop than GCC 3.1
(prerelease) or mainline.  A correctness fix had the side
effect that the compiler can no longer determine that this
loop iterates a fix number of times.

Release:
gcc-3.1 branch and mainline 20020422

Environment:
All platforms, but first observed on i686-pc-linux-gnu.

How-To-Repeat:
Compile the attached loop.c with "-O2 -funroll-all-loops"
and inspect the assembly code generated.
Comment 1 Roger Sayle 2002-09-08 11:47:35 UTC
State-Changed-From-To: open->closed
State-Changed-Why: This has now been fixed on mainline by the following patch:
    
    2002-09-08  Roger Sayle  <roger@eyesopen.com>
    
            PR optimization/6405
            * unroll.c (loop_iterations): last_loop_insn should be the previous
            non-note instruction before loop->end.
            * loop.c (strength_reduce): The conditional jump is the last
            non-note instruction before loop->end (as above).
Comment 2 Roger Sayle 2002-09-08 18:32:32 UTC
From: sayle@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: optimization/6405
Date: 8 Sep 2002 18:32:32 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	sayle@gcc.gnu.org	2002-09-08 11:32:32
 
 Modified files:
 	gcc            : ChangeLog unroll.c loop.c 
 
 Log message:
 	PR optimization/6405
 	* unroll.c (loop_iterations): last_loop_insn should be the previous
 	non-note instruction before loop->end.
 	* loop.c (strength_reduce): The conditional jump is the last
 	non-note instruction before loop->end (as above).
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.15362&r2=1.15363
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/unroll.c.diff?cvsroot=gcc&r1=1.175&r2=1.176
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/loop.c.diff?cvsroot=gcc&r1=1.420&r2=1.421