This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Abusive (?) promotions to int
- From: "Rakesh Kumar - Software, Noida" <rakeshku at noida dot hcltech dot com>
- To: Alexandre Courbot <Alexandre dot Courbot at lifl dot fr>, gcc at gcc dot gnu dot org
- Date: Wed, 24 Sep 2003 17:30:47 +0530
- Subject: RE: Abusive (?) promotions to int
> -----Original Message-----
> From: Alexandre Courbot [mailto:Alexandre.Courbot@lifl.fr]
> Sent: Wednesday, September 24, 2003 3:31 PM
> To: gcc@gcc.gnu.org
> Subject: Abusive (?) promotions to int
>
>
> Hello everybody,
>
> I've been looking for macros to control integer promotions,
> especially for
> temporary statements. Consider for instance the following code:
>
> char c;
> ...
> if (c + 4 > 10) ...
>
> On my target, c gets zero_extended to int, then the addition
> and comparison
> are performed in SImode, while it is not really necessary
> (could be done in
> QImode as well and would save the zero_extend). This results
> in sub-optimal
> code and additional memory requirements (which is important
> since I'm porting
> to a smartcard target).
>
> Is it possible to get rid of this? Is there a macro that can
> control that?
> I've been looking at PROMOTE_MODE and SLOW_BYTE_ACCESS but it
> looks like they
> can't do much for this.
>
> Thanks in advance,
> Alex.
C promotes chars to int in such cases automatically. You can't expect
compilers to behave different when standards state unambiguously.