[patch] Fix PHI optimization issue with boolean types

Eric Botcazou ebotcazou@adacore.com
Mon Oct 24 11:40:00 GMT 2016

> > But integer_truep is just integer_onep for BOOLEAN_TYPEs.
> Yes, but it's more descriptive IMHO.

At the cost of consistency with fits_to_tree_p though.

> fits_to_tree_p avoids creating an INTEGER_CST in ggc memory and thus is the
> prefered way to test if you have a wide-int but not yet an INTEGER_CST.

OK, I was confused by int_fits_type_p, which calls it on an INTEGER_CST (which 
now breaks with the additional test in the function).

The attached fix seems to work and passes regression testing (all languages).

	* tree.h (wi::fits_to_tree_p): Accept only 0 and 1 for boolean types.
	* tree.c (int_fits_type_p): Likewise.  Pass the integer constant as a
	widest_int to above.

Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-patch
Size: 1765 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20161024/6ce3fe34/attachment.bin>

More information about the Gcc-patches mailing list