This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/54815] New: [avr] missed optimization with operations with constant operands
- From: "gjl at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 04 Oct 2012 18:19:42 +0000
- Subject: [Bug other/54815] New: [avr] missed optimization with operations with constant operands
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54815
Bug #: 54815
Summary: [avr] missed optimization with operations with
constant operands
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: other
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: gjl@gcc.gnu.org
CC: eric.weddington@atmel.com
Target: avr
Created attachment 28359
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28359
mov.c: C test case
== C code ==
void f (int, int);
void f_and (int x)
{
f (x, x & 0xff23);
}
void f_or (int x)
{
f (x, x | 42);
}
void f_xor (int x)
{
f (x, x ^ 0x80);
}
== Compile with ==
$ avr-gcc mov.c -S -Os -mmcu=atmega8 -dp
The result is
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 the code could MOVW first to the destination and the IOR instead of loading
the target with the const and then IOR against the source:
f_or:
movw r22,r24 ; *movhi [length = 1]
ori r22,lo8(42) ; iorhi3 [length = 1]
rjmp f
Similar for the other test functions.