powercp-linux cross GCC 4.2 vs GCC 4.0.0: -Os code size regression? [Emcraft #11717]
Andrew Haley
aph@redhat.com
Sat Jan 19 16:26:00 GMT 2008
Gabriel Paubert wrote:
> On Thu, Jan 17, 2008 at 05:48:10PM +0300, Sergei Poselenov wrote:
>> Hello Andrew,
>> Preprocessed and assembler code generated by the GCC 4.2.2 ppc-linux
>> cross-compiler:
>> http://www.emcraft.com/codesize/gcc-4.2.2/interrupts.i
>> http://www.emcraft.com/codesize/gcc-4.2.2/interrupts.s
>>
>> The same code built with gcc-4.0.0 cross-compiler:
>> http://www.emcraft.com/codesize/gcc-4.0.0/interrupts.i
>> http://www.emcraft.com/codesize/gcc-4.0.0/interrupts.s
>>
>
> The functions do not appear in the same order in both files, it's a
> bit surprising! Anyway look for example at irq_install_handler:
>
> - gcc-4.0 saves all registers using stmw r24,xx(r1) and restores them
> with lmw r24,xx(r1) however this means that r29 is overwritten in
> the epilogue.
>
> - gcc-4.2.2 saves and restores registers individually which
> means that it takes 12 more instructions. There go 48 bytes.
>
> This is especially visible in the epilogue (in the prologue
> the saves are interspersed with other instructions).
>
> In this case -ffixed-r29 hurts, but gcc4.2.2 looks more correct.
OK, so the code here is bigger, partly because a bug has been fixed.
Not a bad thing, in general.
I suspect that the real reason for the change in save/restore is because
not using lmw/stmw is faster. That's just a guess though. gcc could probably
be fixed to use ldmw/stmw if -Os is used.
Anyway, now we've found something specific this is for the ppc maintainer to comment.
Andrew.
More information about the Gcc
mailing list