public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/54815] New: [avr] missed optimization with operations with constant operands
@ 2012-10-04 18:20 gjl at gcc dot gnu.org
  2012-10-08  8:33 ` [Bug other/54815] " gjl at gcc dot gnu.org
  2012-10-13  6:38 ` [Bug target/54815] " gjl at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: gjl at gcc dot gnu.org @ 2012-10-04 18:20 UTC (permalink / raw)
  To: gcc-bugs


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.


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

end of thread, other threads:[~2012-10-13  6:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-04 18:20 [Bug other/54815] New: [avr] missed optimization with operations with constant operands gjl at gcc dot gnu.org
2012-10-08  8:33 ` [Bug other/54815] " gjl at gcc dot gnu.org
2012-10-13  6:38 ` [Bug target/54815] " gjl at gcc dot gnu.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).