public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/41076]  New: [avr] pessimal code for logical OR of 8-bit fields
@ 2009-08-15  7:43 pb at gcc dot gnu dot org
  2009-08-15  9:55 ` [Bug target/41076] " rguenth at gcc dot gnu dot org
  0 siblings, 1 reply; 8+ messages in thread
From: pb at gcc dot gnu dot org @ 2009-08-15  7:43 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-02-17 16:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-41076-4@http.gcc.gnu.org/bugzilla/>
2011-05-16 14:36 ` [Bug target/41076] [avr] pessimal code for logical OR of 8-bit fields gjl at gcc dot gnu.org
2011-09-11 21:02 ` gjl at gcc dot gnu.org
2011-09-11 21:48 ` gjl at gcc dot gnu.org
2012-03-22  8:34 ` rguenth at gcc dot gnu.org
2012-07-02 13:53 ` rguenth at gcc dot gnu.org
2013-01-22 22:31 ` gjl at gcc dot gnu.org
2014-02-17 16:35 ` gjl at gcc dot gnu.org
2009-08-15  7:43 [Bug target/41076] New: " pb at gcc dot gnu dot org
2009-08-15  9:55 ` [Bug target/41076] " rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).