This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Abusive (?) promotions to int


Alexandre Courbot <Alexandre.Courbot@lifl.fr> writes:

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

Promotion to int is standard C (and C++) requirement.  
c + 4 may not be not fit into a QImode without semantics mutation.
I suggest you have a look at what the C and C++ standards have to say
on that.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]