Multiply Optimization in match and Simplify

Hurugalawadi, Naveen Naveen.Hurugalawadi@caviumnetworks.com
Thu Oct 29 08:21:00 GMT 2015


Hi,

Please find attached the patch that moves some multiply optimizations
from fold-const using simplify and match.

Please review the patch and let me know if any modifications are required.

Tested the patch on X86.

Observing following failures:-

>> FAIL: gcc.dg/fold-plusmult.c scan-tree-dump-times original "<a> \\* 4" 2

Should the testcase be changed to suit current pattern?

>> FAIL: gcc.dg/tree-ssa/vrp47.c scan-tree-dump-times vrp2 " & 1;" 0
>> FAIL: gcc.dg/tree-ssa/vrp59.c scan-tree-dump-not vrp1 " & 3;"

Its due to the following pattern. Pattern seems to be right.
Fold X & (X ^ Y) as X & ~Y
The test PASSes when we have the result as ~X & Y in some
of the following combinations which is wrong.
(bit_and (convert? (bit_xor:c @0 @1) (convert? @0) ))

Thanks,
Naveen

ChangeLog

2015-10-29  Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>

        * fold-const.c (fold_binary_loc) : Remove A - B -> A + (-B) if B
	is easily negatable as its already present.
	Move x * -C into -x * C if x is easily negatable to match.pd.
	Move (A + A) * C -> A * 2 * C to match.pd.
	Move Fold (X ^ Y) & Y as ~X & Y to match.pd.
	Move Fold (X ^ Y) & X as ~Y & X to match.pd.
	Move Fold X & (X ^ Y) as X & ~Y to match.pd.
	Move Fold X & (Y ^ X) as ~Y & X to match.pd.

        * match.pd (bit_and:c (convert? @0) (convert? (bit_xor:c @0 @1))):
	New simplifier.
	(mult:c (convert? negate_expr_p@0) INTEGER_CST@1): New simplifier.
	(mult:c (convert? (plus @0 @0)) (convert? @1)): New simplifier.
	(mult:c (convert? (plus @0 @0)) INTEGER_CST@1): New simplifier.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mult-opt.patch
Type: text/x-patch
Size: 5421 bytes
Desc: mult-opt.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20151029/ebac7ddb/attachment.bin>


More information about the Gcc-patches mailing list