[Bug c/37990] New: -Os produces redundant instructions
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; } --- -- Summary: -Os produces redundant instructions Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: reza at parvan dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37990
[Bug c/37990] -Os produces redundant instructions
--- Comment #2 from reza at parvan dot net 2008-11-02 11:01 --- 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. -- reza at parvan dot net changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37990
[Bug c/45410] New: constant not optimized / propagated
gcc -Wall -O3 -S test.c doesn't seem to propagate constants correctly. Notice that ss is declared static, therefor everything is known at compile time. Code: #include struct s {int i;int j;}; struct s static ss={77,2}; int main() { ss.j += 88; printf("%d\n",sizeof(ss)); return ss.i+ss.j; }; -- Summary: constant not optimized / propagated Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: reza at parvan dot net GCC host triplet: x86 Ubuntu Linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45410
[Bug middle-end/45410] constant not optimized / propagated
--- Comment #5 from reza at parvan dot net 2010-08-27 17:59 --- (In reply to comment #2) > That's not the main problem here. The problem is that this is an aggregate > and > we SRA only automatic vars, not global vars. And it isn't constant either Jakub, Thanks for that insight. Of course, gcc does a pretty good job (and flow analysis) if we move 'struct s ss' into function scope. That seems like a reasonable workaround for many situations. Reza. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45410