match.pd: Relax some tree_nop_conversion_p

Marc Glisse marc.glisse@inria.fr
Sun May 22 17:42:00 GMT 2016


Hello,

this patch replaces some tree_nop_conversion_p tests with less restrictive 
conditions. In some cases I checked the transformation automatically (of 
course I could have messed up the checker, or the translation). I didn't 
always put the laxest possible check. For instance the transformation for 
(~x & ~y) is valid with sign extension, but the gain is less obvious in 
that case. ~(~X >> Y) also seems valid in some odd cases involving boolean 
types, not worth the complication. The bad case for a * (1 << b) is when 
1<<b turns into INT_MIN (and then we sign-extend), which I think is valid 
even with the strictest overflow rules :-(

I only did a few transforms because it isn't clear to me that this is 
worth it. It makes the validity of the transformation less obvious to the 
reader and probably seldom fires in regular code. True conversions also 
have a cost that can change if the transformation actually gains anything 
(may require extra :s). It could also interfere with a narrowing/promotion 
pass.

Bootstrap+regtest on powerpc64le-unknown-linux-gnu.

2016-05-23  Marc Glisse  <marc.glisse@inria.fr>

gcc/
 	* match.pd (a * (1 << b), ~x & ~y, ~X ^ ~Y, (X ^ Y) ^ Y, ~ (-A),
 	~ (A - 1), ~(~X >> Y), ~(~X >>r Y)): Relax constraints.

gcc/testsuite/
 	* gcc.dg/fold-notshift-2.c: Adjust.

-- 
Marc Glisse
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nop.diff
Type: text/x-diff
Size: 7816 bytes
Desc: 
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160522/28497754/attachment.bin>


More information about the Gcc-patches mailing list