Re: match.pd: (x | y) ~x - y ~x
On May 22, 2015 10:54:02 PM GMT+02:00, Marc Glisse marc.gli...@inria.fr wrote: On Mon, 18 May 2015, Richard Biener wrote: On Fri, May 15, 2015 at 7:22 PM, Marc Glisse marc.gli...@inria.fr wrote: we already have the more complicated: x ~(x y) - x ~y (which I am reindenting by the way) and the simpler: (~x | y) x - x y, so I am proposing this one for completeness. Regtested on ppc64le-redhat-linux. Ok (doesn't seem to be in fold-const.c). Btw, there are quite some (simple) ones only in fold-const.c which are eligible for moving to match.pd (thus remove them from fold-const.c and implement in match.pd). Mostly canonicalization ones though. Haven't you already done a lot of those in the branch though? Yeah, maybe. I'd have to check. Reminds me to come back to all this. After sorting out all the vectorizer stuff I am working on at the moment. Richard.
Re: match.pd: (x | y) ~x - y ~x
On Mon, 18 May 2015, Richard Biener wrote: On Fri, May 15, 2015 at 7:22 PM, Marc Glisse marc.gli...@inria.fr wrote: we already have the more complicated: x ~(x y) - x ~y (which I am reindenting by the way) and the simpler: (~x | y) x - x y, so I am proposing this one for completeness. Regtested on ppc64le-redhat-linux. Ok (doesn't seem to be in fold-const.c). Btw, there are quite some (simple) ones only in fold-const.c which are eligible for moving to match.pd (thus remove them from fold-const.c and implement in match.pd). Mostly canonicalization ones though. Haven't you already done a lot of those in the branch though? -- Marc Glisse
Re: match.pd: (x | y) ~x - y ~x
On Fri, May 15, 2015 at 7:22 PM, Marc Glisse marc.gli...@inria.fr wrote: Hello, we already have the more complicated: x ~(x y) - x ~y (which I am reindenting by the way) and the simpler: (~x | y) x - x y, so I am proposing this one for completeness. Regtested on ppc64le-redhat-linux. Ok (doesn't seem to be in fold-const.c). Btw, there are quite some (simple) ones only in fold-const.c which are eligible for moving to match.pd (thus remove them from fold-const.c and implement in match.pd). Mostly canonicalization ones though. Richard. 2015-05-15 Marc Glisse marc.gli...@inria.fr gcc/ * match.pd ((x | y) ~x - y ~x, (x y) | ~x - y | ~x): New simplifications. gcc/testsuite/ * gcc.dg/nand.c: New testcase. -- Marc Glisse Index: match.pd === --- match.pd(revision 223217) +++ match.pd(working copy) @@ -257,24 +257,32 @@ along with GCC; see the file COPYING3. /* x + (x 1) - (x + 1) ~1 */ (simplify (plus:c @0 (bit_and@2 @0 integer_onep@1)) (if (TREE_CODE (@2) != SSA_NAME || has_single_use (@2)) (bit_and (plus @0 @1) (bit_not @1 /* x ~(x y) - x ~y */ /* x | ~(x | y) - x | ~y */ (for bitop (bit_and bit_ior) - (simplify -(bitop:c @0 (bit_not (bitop:c@2 @0 @1))) - (if (TREE_CODE (@2) != SSA_NAME || has_single_use (@2)) - (bitop @0 (bit_not @1) + (simplify + (bitop:c @0 (bit_not (bitop:c@2 @0 @1))) + (if (TREE_CODE (@2) != SSA_NAME || has_single_use (@2)) +(bitop @0 (bit_not @1) + +/* (x | y) ~x - y ~x */ +/* (x y) | ~x - y | ~x */ +(for bitop (bit_and bit_ior) + rbitop (bit_ior bit_and) + (simplify + (bitop:c (rbitop:c @0 @1) (bit_not@2 @0)) + (bitop @1 @2))) (simplify (abs (negate @0)) (abs @0)) (simplify (abs tree_expr_nonnegative_p@0) @0) /* Try to fold (type) X op CST - (type) (X op ((type-x) CST)) Index: testsuite/gcc.dg/nand.c === --- testsuite/gcc.dg/nand.c (revision 0) +++ testsuite/gcc.dg/nand.c (working copy) @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options -O -fdump-tree-original } */ + +unsigned f(unsigned x, unsigned y){ + return (x | y) ~x; +} +unsigned g(unsigned x, unsigned y){ + return ~x (y | x); +} + +/* { dg-final { scan-tree-dump-times return ~x y; 2 original } } */ +/* { dg-final { cleanup-tree-dump original } } */
match.pd: (x | y) ~x - y ~x
Hello, we already have the more complicated: x ~(x y) - x ~y (which I am reindenting by the way) and the simpler: (~x | y) x - x y, so I am proposing this one for completeness. Regtested on ppc64le-redhat-linux. 2015-05-15 Marc Glisse marc.gli...@inria.fr gcc/ * match.pd ((x | y) ~x - y ~x, (x y) | ~x - y | ~x): New simplifications. gcc/testsuite/ * gcc.dg/nand.c: New testcase. -- Marc GlisseIndex: match.pd === --- match.pd(revision 223217) +++ match.pd(working copy) @@ -257,24 +257,32 @@ along with GCC; see the file COPYING3. /* x + (x 1) - (x + 1) ~1 */ (simplify (plus:c @0 (bit_and@2 @0 integer_onep@1)) (if (TREE_CODE (@2) != SSA_NAME || has_single_use (@2)) (bit_and (plus @0 @1) (bit_not @1 /* x ~(x y) - x ~y */ /* x | ~(x | y) - x | ~y */ (for bitop (bit_and bit_ior) - (simplify -(bitop:c @0 (bit_not (bitop:c@2 @0 @1))) - (if (TREE_CODE (@2) != SSA_NAME || has_single_use (@2)) - (bitop @0 (bit_not @1) + (simplify + (bitop:c @0 (bit_not (bitop:c@2 @0 @1))) + (if (TREE_CODE (@2) != SSA_NAME || has_single_use (@2)) +(bitop @0 (bit_not @1) + +/* (x | y) ~x - y ~x */ +/* (x y) | ~x - y | ~x */ +(for bitop (bit_and bit_ior) + rbitop (bit_ior bit_and) + (simplify + (bitop:c (rbitop:c @0 @1) (bit_not@2 @0)) + (bitop @1 @2))) (simplify (abs (negate @0)) (abs @0)) (simplify (abs tree_expr_nonnegative_p@0) @0) /* Try to fold (type) X op CST - (type) (X op ((type-x) CST)) Index: testsuite/gcc.dg/nand.c === --- testsuite/gcc.dg/nand.c (revision 0) +++ testsuite/gcc.dg/nand.c (working copy) @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options -O -fdump-tree-original } */ + +unsigned f(unsigned x, unsigned y){ + return (x | y) ~x; +} +unsigned g(unsigned x, unsigned y){ + return ~x (y | x); +} + +/* { dg-final { scan-tree-dump-times return ~x y; 2 original } } */ +/* { dg-final { cleanup-tree-dump original } } */