[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?

From: Dave Hansen
Subject: RE: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?
Date: Tue, 23 Dec 2003 08:55:16 -0500

From: "J.C. Wren" <address@hidden>
OK, part of that was my fault, I had "i << 1" instead of "1 << i".  But
nonetheless, we still see some extra code at 0x94, 0x9c, 0xa0, and 0xa4. The
compiler should be able to foresee the type of 'data', and not promote the
intermediate results, right?

As others have mentioned, this is a case where the generated code is correct, though the compiler might be able to optimize better. You and I are both aware of a compiler that, given

  unsigned char shift = 12;
  unsigned int i;
  unsigned int j;

  i = 1 << shift;
  j = 1U << shift;

will (depending on the options set) set i to 0 and j to 4096. Gcc won't make that mistake.


Check your PC for viruses with the FREE McAfee online computer scan. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

reply via email to

[Prev in Thread] Current Thread [Next in Thread]