This is the mail archive of the
mailing list for the GCC project.
Re: Abusive (?) promotions to int
- From: Mike Stump <mrs at apple dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: Alexandre Courbot <Alexandre dot Courbot at lifl dot fr>, gcc at gcc dot gnu dot org
- Date: Wed, 24 Sep 2003 11:34:39 -0700
- Subject: Re: Abusive (?) promotions to int
On Wednesday, September 24, 2003, at 03:15 AM, Andreas Schwab wrote:
I've been looking for macros to control integer promotions,
temporary statements. Consider for instance the following code:
if (c + 4 > 10) ...
On my target, c gets zero_extended to int, then the addition and
are performed in SImode, while it is not really necessary (could be
QImode as well and would save the zero_extend).
No, it cannot. You would get wrong behaviour if c >= 252 (assuming
is unsigned 8 bit), because (char)(c + 4) < 10, but c + 4 > 10.
? But, while we can envision bad code gen, can't we also envision good
sequences as well:
cond = c + 4 > 10;
cond = ((int)c + 4) > 10;
cond = ((int)c) > 6);
cond = ((char)c) > (char)6);
or is there something I'm missing? When the compiler is used on small
machines, this type of optimization, if possible, is useful.