From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4109 invoked by alias); 1 Nov 2007 13:44:52 -0000 Received: (qmail 4050 invoked by uid 48); 1 Nov 2007 13:44:39 -0000 Date: Thu, 01 Nov 2007 13:44:00 -0000 Subject: [Bug c/33970] New: Missed optimization using unsigned char loop variable X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "henning dot m at insightbb dot com" 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: 2007-11/txt/msg00025.txt.bz2 When using an unsigned char in a loop with limited range the variable is promoted to a 16 bit integer if the variable is passed to another function within the loop by value. Tested using -Os on ATMEGA162: #include int sub2(uint8_t); int main(void) { static uint8_t x; volatile uint8_t y; while(1) { for(x=0;x<128; x++) { y+=sub2(x); } } return 0; } int sub2(uint8_t xyz) { volatile uint8_t abc; while(xyz < 64) { xyz++; abc+=xyz; } return abc; } -- Summary: Missed optimization using unsigned char loop variable Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: henning dot m at insightbb dot com GCC build triplet: WinAVR 20070525 GCC target triplet: avr http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33970