This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: avoid generating casts for bools
- From: Dan Nicolaescu <dann at godzilla dot ics dot uci dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 30 Apr 2004 09:46:05 -0700
- Subject: Re: avoid generating casts for bools
- References: <200404300630.i3U6UhGK017714@scanner2.ics.uci.edu>
Dan Nicolaescu <dann@godzilla.ics.uci.edu> writes:
> As shown in the thread starting at:
> http://gcc.gnu.org/ml/gcc/2004-04/msg01027.html
> bools are unnecessarily cast to int. The tree optimizers cannot get
> rid of the extra casts.
>
> Special casing bools in convert_to_integer seems to do the trick,
> the spurious casts are avoided. The patch to do this is below, it
> might be more conservative than it needs to be.
This patch together with the one avoiding the casts for return values
in "start_function" was bootstrapped on x84_64-linux.
There is one regression for C: an extra warning for c99-bool-1.c
./cc1 -O2 c99-bool-1.c
c99-bool-1.c: In function `main':
c99-bool-1.c:231: warning: comparison is always true due to limited range of data type
The code in question is:
_Bool u;
u = 1;
if ((u ^= 3) != 1)
abort ();
I am not sure if the warning is correct.