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: [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.




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