This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix middle-end/15618, bool_var != 0 (== 1) -> bool_var
- From: Paul Schlie <schlie at comcast dot net>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>,<gcc-patches at gcc dot gnu dot org>
- Date: Mon, 02 May 2005 21:49:20 -0400
- Subject: Re: [PATCH] Fix middle-end/15618, bool_var != 0 (== 1) -> bool_var
> Andrew Pinski writes:
> Right now we don't optimize if a bool variable is compared not equal
> to zero or equal to one. This implements that folding of those two
> and treats BOOLEAN_TYPE like INTEGER_TYPE in fold_widened_comparison
> so we get the folding of "(int)bool_var != 0" into "bool_var != 0".
Might these also be worth while? (or are they handled elsewhere):
bool_var == 0 => ! bool_var // as a logical ! (not) it's likely more
bool_var != 1 => ! bool_var // easily folded with other logical ops.
bool_var == (N other than 0 or 1) => false // as constant results are
bool_var != (N other than 0 or 1) => true // always likely a good thing.