This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Abusive (?) promotions to int
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: "Rakesh Kumar - Software, Noida" <rakeshku at noida dot hcltech dot com>
- Cc: Alexandre Courbot <Alexandre dot Courbot at lifl dot fr>, gcc at gcc dot gnu dot org
- Date: 24 Sep 2003 15:59:54 -0700
- Subject: Re: Abusive (?) promotions to int
- References: <E04CF3F88ACBD5119EFE00508BBB21210C4BE0CC@exch-01.noida.hcltech.com>
"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