From af563d4bb754b06f828d29aa74b5b663353cec97 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 22 May 2015 22:37:04 +0200 Subject: [PATCH] match.pd ((x | y) & ~x -> y & ~x, (x & y) | ~x -> y | ~x): New simplifications. 2015-05-22 Marc Glisse gcc/ * match.pd ((x | y) & ~x -> y & ~x, (x & y) | ~x -> y | ~x): New simplifications. gcc/testsuite/ * gcc.dg/nand.c: New testcase. From-SVN: r223587 --- gcc/ChangeLog | 5 +++++ gcc/match.pd | 16 ++++++++++++---- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/nand.c | 12 ++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/nand.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 769c7b5e58f..ceb9444765f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-05-22 Marc Glisse + + * match.pd ((x | y) & ~x -> y & ~x, (x & y) | ~x -> y | ~x): New + simplifications. + 2015-05-22 Jeff Law * config/pa/pa.md (integer_indexed_store splitters): Use diff --git a/gcc/match.pd b/gcc/match.pd index 73ccfbd4b00..33419ebdcb6 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -280,10 +280,18 @@ along with GCC; see the file COPYING3. If not see /* 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)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0b0de20c7df..8d480a3a21f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-05-22 Marc Glisse + + * gcc.dg/nand.c: New testcase. + 2015-05-22 Sandra Loosemore * gcc.target/aarch64/advsimd-intrinsics/advsimd-intrinsics.exp: diff --git a/gcc/testsuite/gcc.dg/nand.c b/gcc/testsuite/gcc.dg/nand.c new file mode 100644 index 00000000000..28df5819ee0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/nand.c @@ -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" } } */ -- 2.11.4.GIT