From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11444 invoked by alias); 4 Oct 2012 18:28:16 -0000 Received: (qmail 11377 invoked by uid 48); 4 Oct 2012 18:27:58 -0000 From: "gjl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/54816] New: [avr] shift is better than widening mul Date: Thu, 04 Oct 2012 18:28:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target 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/msg00358.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54816 Bug #: 54816 Summary: [avr] shift is better than widening mul Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: target AssignedTo: unassigned@gcc.gnu.org ReportedBy: gjl@gcc.gnu.org CC: eric.weddington@atmel.com Target: avr The following C test case int wmul (char a, char b) { return a * (char) (b << 3); } $ avr-gcc wmul.c -S -Os -mmcu=atmega8 -dp produces with current avr-gcc: wmul: ldi r25,lo8(8) ; 25 movqi_insn/2 [length = 1] muls r22,r25 ; 26 mulqihi3 [length = 3] movw r22,r0 clr __zero_reg__ muls r24,r22 ; 17 mulqihi3 [length = 3] movw r24,r0 clr __zero_reg__ ret ; 29 return [length = 1] .ident "GCC: (GNU) 4.8.0 20121004 (experimental)" avr-gcc-4.7 was smarter with its code: wmul: lsl r22 ; 10 *ashlqi3/5 [length = 3] lsl r22 lsl r22 muls r24,r22 ; 12 mulqihi3 [length = 3] movw r22,r0 clr __zero_reg__ movw r24,r22 ; 31 *movhi/1 [length = 1] ret ; 30 return [length = 1] .ident "GCC: (GNU) 4.7.2" The 4.7 code is faster, smaller and has smaller register pressure.