This is the mail archive of the gcc-patches@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: avoid generating casts for bools


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.


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