public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/33970]  New: Missed optimization using unsigned char loop variable
@ 2007-11-01 13:44 henning dot m at insightbb dot com
  2007-11-01 17:09 ` [Bug middle-end/33970] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: henning dot m at insightbb dot com @ 2007-11-01 13:44 UTC (permalink / raw)
  To: gcc-bugs

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 <avr/io.h>


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-07-20 17:48 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-33970-4@http.gcc.gnu.org/bugzilla/>
2011-07-20 17:48 ` [Bug middle-end/33970] Missed optimization using unsigned char loop variable gjl at gcc dot gnu.org
2007-11-01 13:44 [Bug c/33970] New: " henning dot m at insightbb dot com
2007-11-01 17:09 ` [Bug middle-end/33970] " pinskia at gcc dot gnu dot org
2007-11-01 17:28 ` eweddington at cso dot atmel dot com
2007-11-01 17:45 ` eweddington at cso dot atmel dot com
2007-11-01 17:47 ` eweddington at cso dot atmel dot com
2007-11-01 21:26 ` henning dot m at insightbb dot com
2007-11-04 23:28 ` eweddington at cso dot atmel dot com
2007-11-04 23:28 ` eweddington at cso dot atmel dot com
2007-11-05 22:48 ` wvangulik at xs4all dot nl
2007-11-06 12:37 ` henning dot m at insightbb dot com
2007-11-06 19:35 ` wvangulik at xs4all dot nl
2007-11-06 21:01 ` wvangulik at xs4all dot nl
2010-09-13 12:09 ` abnikant dot singh at atmel dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).