From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18975 invoked by alias); 20 Jul 2011 17:48:16 -0000 Received: (qmail 18966 invoked by uid 22791); 20 Jul 2011 17:48:15 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_GJ X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 20 Jul 2011 17:48:02 +0000 From: "gjl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/33970] Missed optimization using unsigned char loop variable X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: gjl at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.0 X-Bugzilla-Changed-Fields: Status CC Resolution Target Milestone Known to fail 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 Date: Wed, 20 Jul 2011 17:48:00 -0000 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: 2011-07/txt/msg01695.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33970 Georg-Johann Lay changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |gjl at gcc dot gnu.org Resolution| |WORKSFORME Target Milestone|--- |4.7.0 Known to fail| | --- Comment #13 from Georg-Johann Lay 2011-07-20 17:47:44 UTC --- Cloased as WORKS FOR ME. Using the following test case: volatile unsigned char bar; void foo(void) { unsigned char x; for(x=0;x<128; x++) { bar = x; } } int sub2 (unsigned char); void foo2 (void) { unsigned char x; for(x=0;x<128; x++) { sub2 (x); } } void foo21 (void) { unsigned char x; for(x=0;x<128; x++) { sub2 (x+1); } } And with avr-gcc 4.7 r176517 I get the following result (-Os -mmcu=atmega8). In no case there is a 16-bit loop variable used. foo: ldi r24,lo8(0) .L5: sts bar,r24 subi r24,lo8(-(1)) cpi r24,lo8(-128) brne .L5 ret foo2: push r28 ldi r28,lo8(0) .L8: mov r24,r28 rcall sub2 subi r28,lo8(-(1)) cpi r28,lo8(-128) brne .L8 pop r28 ret foo21: push r28 ldi r28,lo8(0) .L11: subi r28,lo8(-(1)) mov r24,r28 rcall sub2 cpi r28,lo8(-128) brne .L11 pop r28 ret .ident "GCC: (GNU) 4.7.0 20110720 (experimental)"