From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5437 invoked by alias); 4 Oct 2012 18:20:01 -0000 Received: (qmail 5335 invoked by uid 48); 4 Oct 2012 18:19:43 -0000 From: "gjl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/54815] New: [avr] missed optimization with operations with constant operands Date: Thu, 04 Oct 2012 18:20:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: gjl at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-10/txt/msg00357.txt.bz2 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.