User account creation filtered due to spam.

Bug 41175

Summary: -Os generates significantly larger code
Product: gcc Reporter: Kumar Gala <galak>
Component: targetAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs
Priority: P3    
Version: 4.4.1   
Target Milestone: 4.5.0   
Host: ppc64-redhat-linux Target: ppc64-redhat-linux
Build: ppc64-redhat-linux Known to work:
Known to fail: Last reconfirmed:
Attachments: size of all object files using gcc 4.3
size of all object files using gcc 4.4
gcc45-pr41175.patch

Description Kumar Gala 2009-08-26 14:17:38 UTC
Using -Os with gcc4.4 vs gcc4.3 we see a ~15% increase in code size.  This is due to the fact that load/store multiple instructions are not being used for function prologue/epilogues.  The other option would be to use out of line save/restore calls in the prologue/epilogues (which are also not being used).

We are no longer able to build the u-boot open source loader because the code size increase expands beyond the allowable size (to meet flash constraints).
Comment 1 Kumar Gala 2009-08-26 14:18:19 UTC
Created attachment 18428 [details]
size of all object files using gcc 4.3
Comment 2 Kumar Gala 2009-08-26 14:18:37 UTC
Created attachment 18429 [details]
size of all object files using gcc 4.4
Comment 3 Kumar Gala 2009-08-26 14:20:00 UTC
I've attached comparisions of building the same u-boot source tree with gcc-4.3 from Fedora 10 on a PPC 64 host:

[galak@blarg u-boot-85xx]$ gcc -v
Using built-in specs.
Target: ppc64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --enable-secureplt --with-long-double-128 --build=ppc64-redhat-linux --target=ppc64-redhat-linux --with-cpu=default32
Thread model: posix
gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC) 

vs gcc 4.4 on a FC11 PPC64 host:

[root@ducky u-boot]# gcc -v
Using built-in specs.
Target: ppc64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --enable-secureplt --with-long-double-128 --build=ppc64-redhat-linux --target=ppc64-redhat-linux --with-cpu=default32
Thread model: posix
gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC)
Comment 4 Jakub Jelinek 2009-09-10 23:11:19 UTC
Created attachment 18564 [details]
gcc45-pr41175.patch

Incremental fix on top of Nathan's patch.
Comment 5 Jakub Jelinek 2009-09-15 20:12:37 UTC
Subject: Bug 41175

Author: jakub
Date: Tue Sep 15 20:12:18 2009
New Revision: 151729

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151729
Log:
	PR target/41175
	PR target/40677
	* config/rs6000/rs6000.c (no_global_regs_above): Fix precedence
	problem.
	(SAVRES_NOINLINE_GPRS_SAVES_LR, SAVRES_NOINLINE_FPRS_SAVES_LR,
	SAVRES_NOINLINE_FPRS_DOESNT_RESTORE_LR): New strategy bits.
	(rs6000_savres_strategy): Always save FP registers inline if the
	target doesn't support hardware double-precision.  Set the above
	bits in return value when needed.
	(rs6000_savres_routine_sym): Fix computation for cache selector.
	Mark the generated symbol as a function.  Rename exitp argument to
	lr.  Move code for determining the name of the symbol...
	(rs6000_savres_routine_name): ...here.  New function.  Add cases for
	getting the names right on AIX and 64-bit Linux.
	(savres_routine_name): New variable.
	(rs6000_make_savres_rtx): Rename exitp argument to lr.  Don't assert
	lr isn't set when savep.  Use r12 resp. r1 instead of r11 depending
	on what the target routine uses as a base register.  If savep && lr
	describe saving of r0 into memory slot.
	(rs6000_emit_prologue): Correct use of call_used_regs.  Fix out of
	line calls for AIX ABI.
	(rs6000_output_function_prologue): Use rs6000_savres_routine_name to
	determine FP save/restore functions.
	(rs6000_emit_stack_reset): Handle savres if sp_offset != 0 and
	frame_reg_rtx != sp_reg_rtx.  Use gen_add3_insn instead of
	gen_addsi3.
	(rs6000_emit_epilogue): Adjust computation of restore_lr.
	Duplicate restoration of LR and execute the appropriate one
	depending on whether GPRs are being restored inline.  Set r11 from
	offsetted frame_reg_rtx instead of sp_reg_rtx; if frame_reg_rtx is
	r11, adjust sp_offset.  Use gen_add3_insn instead of gen_addsi3.
	Fix out of line calls for AIX ABI.
	* config/rs6000/rs6000.md (*return_and_restore_fpregs_aix_<mode>):
	New insn.
	* config/rs6000/spe.md (*save_gpregs_spe): Use explicit match for
	register 11.
	(*restore_gpregs_spe): Likewise.
	(*return_and_restore_gpregs_spe): Likewise.
	* config/rs6000/linux64.h (SAVE_FP_SUFFIX, RESTORE_FP_SUFFIX):
	Define to empty string unconditionally.
	* config/rs6000/sysv4.h (SAVE_FP_SUFFIX, RESTORE_FP_SUFFIX):
	Define to empty string unconditionally.
	(GP_SAVE_INLINE, FP_SAVE_INLINE): Handle TARGET_64BIT the same as
	!TARGET_64BIT.

	* gcc.target/powerpc/pr41175.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/powerpc/pr41175.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/linux64.h
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/config/rs6000/rs6000.md
    trunk/gcc/config/rs6000/spe.md
    trunk/gcc/config/rs6000/sysv4.h
    trunk/gcc/testsuite/ChangeLog

Comment 6 Andrew Pinski 2009-10-05 22:22:57 UTC
Fixed.