Abusive (?) promotions to int

Rakesh Kumar - Software, Noida rakeshku@noida.hcltech.com
Wed Sep 24 12:11:00 GMT 2003


> -----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. 



More information about the Gcc mailing list