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]

[PATCH] Fix middle-end/15618, bool_var != 0 (== 1) -> bool_var


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".

OK? Bootstrapped and tested on powerpc-darwin7.8 without any regressions.

Thanks,
Andrew Pinski

ChangeLog:

	* fold-const.c (fold_widened_comparison): Treat BOOLEAN_TYPE
	the same as INTEGER_TYPE.
	(fold_binary): Fold "bool_var != 0" to bool_var.
	Fold "bool_var == 1" to bool_var.

testsuite/ChangeLog:

* gcc.dg/tree-ssa/bool-[1-9].c: New tests.


Attachment: temp.diff.txt
Description: Text document


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