[Path,AVR]: Improve loading of 32-bit constants

Georg-Johann Lay avr@gjlay.de
Wed Jul 6 16:08:00 GMT 2011


Denis Chertykov wrote:
> 2011/7/6 Georg-Johann Lay <avr@gjlay.de>:
>> For loading a 32-bit constant in a register, there is room for
>> improvement:
>>
>> * SF can be handled the same way as SI and therefore the patch
>>  adds a peep2 to produce a *reload_insf analogon to *reload_insi.
>>
>> * If the destination register overlaps NO_LD_REGS, values already
>>  loaded into some other byte can be reused by a simple MOV.
>>  This is helpful then moving values like, e.g. -2, -100 etc. because
>>  all high bytes are 0xff.
>>
>> * 0.0f can be directly moved to memory.
>>
>> * The mov insns contain "!d" constraint. I see no reason to make "d"
>>  expensive and discourage use of d-regs.  A "*d" to hide is better
>>  because it does it neither puts additional pressure on "d" nor
>>  discourages "d".
>>
> 
> I would like to have a real code examples.
> 
> Denis.

Hi Denis.

Attached you find a small C file and the asm that is generated by new
and old versions (-Os -mmcu=atmega88 -S -dp).

I took away some regs as potential clobbers (or -fno-peephole2) to
show the effect of high register pressure.  Bit even if a clobber was
available you can see that the new version is smarter in reusing
values, e.g. note the loading of -1L to r22-r25.

Johann
-------------- next part --------------
A non-text attachment was scrubbed...
Name: oint.c
Type: text/x-csrc
Size: 333 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110706/b6f85518/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: oint-old.s
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110706/b6f85518/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: oint-new.s
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110706/b6f85518/attachment-0001.ksh>


More information about the Gcc-patches mailing list