From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22359 invoked by alias); 22 Jan 2013 22:31:26 -0000 Received: (qmail 22279 invoked by uid 48); 22 Jan 2013 22:31:13 -0000 From: "gjl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/41076] [avr] pessimal code for logical OR of 8-bit fields Date: Tue, 22 Jan 2013 22:31:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed 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: REOPENED X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: gjl at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status Resolution Target Milestone Severity Message-ID: In-Reply-To: References: 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: 2013-01/txt/msg02113.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41076 Georg-Johann Lay changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED | Target Milestone|4.7.1 |--- Severity|enhancement |normal --- Comment #6 from Georg-Johann Lay 2013-01-22 22:31:11 UTC --- (In reply to comment #5) > Fixed I suppose. Unfortunately, not extern unsigned char read8 (void); unsigned short read16 (void) { unsigned char lo, hi; hi = read8(); lo = read8(); return lo | hi << 8; } with 4.8.0 -S -Os the compiler needs 5 instructions (29, 37, 30, 38) for an operation that is basically a no-op: read16: push r28 ; 31 pushqi1/1 [length = 1] /* prologue: function */ /* frame size = 0 */ /* stack size = 1 */ .L__stack_usage = 1 call read8 ; 5 call_value_insn/2 [length = 2] mov r28,r24 ; 6 movqi_insn/1 [length = 1] call read8 ; 7 call_value_insn/2 [length = 2] mov r18,r28 ; 28 movqi_insn/1 [length = 1] ldi r19,0 ; 29 movqi_insn/1 [length = 1] mov r19,r18 ; 37 *ashlhi3_const/3 [length = 2] clr r18 or r18,r24 ; 30 iorqi3/1 [length = 1] movw r24,r18 ; 38 *movhi/1 [length = 1] /* epilogue start */ pop r28 ; 34 popqi [length = 1] ret ; 35 return_from_epilogue [length = 1]