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


"Rakesh Kumar - Software, Noida" <rakeshku@noida.hcltech.com> writes:

> C promotes chars to int in such cases automatically. You can't expect
> compilers to behave different when standards state unambiguously. 

True, but compilers are also permitted to follow the as-if rule: if
you can't detect a difference, then there is no difference.  You can
compute

    char c;
    ...
    if (c + 4 > 10) ...

without actually going to the trouble of zero extending c to int.

Obviously this sort of optimization will only be useful on processors
which actually have QImode operations, unlike most RISC processors.

To address the original question, there isn't any macro to control
this, as C does after all require promoting the value to int.  In
principle the combine pass could detect the use of a zero-extended
value in a context in which the zero-extension is not required.  In
practice this would probably be difficult.

Ian


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