This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [Patch,avr]: Fix PR54815
- From: "Weddington, Eric" <Eric dot Weddington at atmel dot com>
- To: Georg-Johann Lay <avr at gjlay dot de>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: Denis Chertykov <chertykov at gmail dot com>
- Date: Sat, 6 Oct 2012 00:15:19 +0000
- Subject: RE: [Patch,avr]: Fix PR54815
- References: <506EEECD.3040605@gjlay.de>
> -----Original Message-----
> From: Georg-Johann Lay
> Sent: Friday, October 05, 2012 8:30 AM
> To: gcc-patches@gcc.gnu.org
> Cc: Denis Chertykov; Weddington, Eric
> Subject: [Patch,avr]: Fix PR54815
>
> avr-gcc compiles code like
>
> void f (int, int);
>
> void f_or (int x)
> {
> f (x, x | 42);
> }
>
> to
>
> f_or:
> ldi r22,lo8(42) ; 15 *movhi/5 [length = 2]
> ldi r23,0
> or r22,r24 ; 6 iorhi3/1 [length = 2]
> or r23,r25
> rjmp f
>
> but this is more efficient:
>
> f_or:
> movw r22,r24 ; 15 *movhi/1 [length = 1]
> ori r22,42 ; 6 iorhi3/3 [length = 1]
> rjmp f ; 9 call_insn/4 [length = 1]
>
> The second variant is generated with the attached patch which makes
> alternatives where the 3rd operand is a register slightly more expensive.
>
> The saturated additions and subtractions in avr-fixed.md already contain
> such
> constraint costs, so they need not to be fixed.
>
> Ok for trunk?
>
Approved, please apply. Thanks for your work! :-)
Eric