This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/41076] New: [avr] pessimal code for logical OR of 8-bit fields
- From: "pb at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Aug 2009 07:42:55 -0000
- Subject: [Bug target/41076] New: [avr] pessimal code for logical OR of 8-bit fields
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This trivial function:
unsigned short f(unsigned char a, unsigned char b)
{
return a | (b << 8);
}
generates the code:
f:
/* prologue: function */
/* frame size = 0 */
mov r21,r22
ldi r20,lo8(0)
mov r18,r24
ldi r19,lo8(0)
or r18,r20
or r19,r21
mov r24,r18
mov r25,r19
/* epilogue start */
ret
In other words, GCC is first zero-extending the two 8-bit quantities to 16
bits, then performing a 16-bit logical OR operation on the result. For each
half of the OR operation, though, one side is a constant zero and hence these
operations are redundant.
In this particular trivial case, the function could be implemented as:
mov r25, r21
ret
with all the other operations omitted.
--
Summary: [avr] pessimal code for logical OR of 8-bit fields
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pb at gcc dot gnu dot org
GCC target triplet: avr-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41076