Consider the following two functions: int foo() { return 1; } void bar() {} Disassembly when compiled with gcc 2.95.2: (-Os) 00000000 <foo(void)>: 0: 38 60 00 01 li r3,1 4: 4e 80 00 20 blr 00000008 <bar(void)>: 8: 4e 80 00 20 blr Disassembly when compiled with gcc 4.1.1: (-Os) 00000000 <foo()>: 0: 94 21 ff f0 stwu r1,-16(r1) 4: 38 60 00 01 li r3,1 8: 38 21 00 10 addi r1,r1,16 c: 4e 80 00 20 blr 00000010 <bar()>: 10: 94 21 ff f0 stwu r1,-16(r1) 14: 38 21 00 10 addi r1,r1,16 18: 4e 80 00 20 blr
How did you configure 4.1.1? I bet this is really a dup of bug 28966.
This works for me on the mainline: [pinskia@celery gcc]$ ./cc1 -m32 -Os t.c -o - -quiet .file "t.c" .section ".text" .align 2 .globl foo .type foo, @function foo: li 3,1 blr .size foo,.-foo .align 2 .globl bar .type bar, @function bar: blr .size bar,.-bar .ident "GCC: (GNU) 4.2.0 20060909 (experimental)" .section .note.GNU-stack,"",@progbits Are you sure you did not add -maltivec somewhere or --with-cpu=970 ?
Ack! Sorry--I had indicated the wrong target on that one. The target is vxworks, not linux. My 4.1.1 powerpc-linux compiler *does* get this optimization right. So something in the vxworks-specific code is causing this: /opt/vxppc/libexec/gcc/powerpc-wrs-vxworks/4.1.1> ./cc1 -m32 -Os ~/foo.c -o - -quiet .file "foo.c" .section ".text" .align 2 .globl foo .type foo, @function foo: stwu 1,-16(1) li 3,1 addi 1,1,16 blr .size foo, .-foo .align 2 .globl bar .type bar, @function bar: stwu 1,-16(1) addi 1,1,16 blr .size bar, .-bar .ident "GCC: (GNU) 4.1.1" In my opinion, this is a very low priority problem, despite that this is one of my primary development environments. Sorry for wasting your time with the wrong target.
Can you give the output of gcc -v for powerpc-wrs-vxworks? I bet vxworks enables altivec by default which means it is a dup still.
#define STACK_BOUNDARY (16*BITS_PER_UNIT) This is a target issue.
this is really a duplicate of 28966. Like vxworks has an unconditional 128 bit stack alignment, unlike other targets where it is only 128bit when altivec comes into play. *** This bug has been marked as a duplicate of 28966 ***
Subject: Bug 29248 Author: pthaugen Date: Wed Oct 31 19:48:19 2007 New Revision: 129806 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129806 Log: 2007-10-01 Pat Haugen <pthaugen@us.ibm.com> Backport the following patches: 2007-09-04 Daniel Jacobowitz <dan@codesourcery.com> * config/rs6000/rs6000.c (rs6000_stack_info): Allocate space for the GOT pointer only if there is a constant pool. Use the allocated space for SPE also. 2006-12-21 Nathan Sidwell <nathan@codesourcery.com> PR target/28966 PR target/29248 * reload1.c (reload): Realign stack after it changes size. Modified: branches/ibm/gcc-4_1-branch/gcc/ChangeLog branches/ibm/gcc-4_1-branch/gcc/config/rs6000/rs6000.c branches/ibm/gcc-4_1-branch/gcc/reload1.c