Bug 37990 - -Os produces redundant instructions
Summary: -Os produces redundant instructions
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-01 21:24 UTC by Reza Roboubi
Modified: 2008-11-02 11:01 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Reza Roboubi 2008-11-01 21:24:50 UTC
DESCRIPTION:
----------------------------------------
Simple test case is below.
There is redundant stack manipulation in the assembly output.
Use gcc -Wall -Os -S test.c
-----------------------------------------

VERSION INFO:
----------------------------------
gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)
-----------------------------------

SOURCE CODE:
----------------------------------
extern int ii(int i);

void 
mm()
{
    int i=99;
more:
    i = ii(i);
    goto inc;
inc:
    if(i==0)
        goto more;
    i++;
    goto more;
}
---------------------------------------
Comment 1 Richard Biener 2008-11-02 10:33:30 UTC
What exactly do you mean with redundant stack manipulation?  Note that the
ABI requires the stack to be aligned properly at function entry which makes
stack adjustment necessary before the call.  Note also that you can use
-maccumulate-outgoing-args to reduce the number of stack operations, but that
may cause bigger code in some cases.
Comment 2 Reza Roboubi 2008-11-02 11:01:58 UTC
Arrrg!  I'm very sorry.  Please ignore this bug report.

I'll change the status to INVALID if that's okay.

Thanks for your response.

Reza.