diff options
author | Marek Polacek <polacek@redhat.com> | 2015-06-11 12:37:37 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2015-06-11 12:37:37 +0000 |
commit | f13c4673a54c76a1c92018d630f48126349732b0 (patch) | |
tree | e15f3019d96fd6027462f91b4cf4b7d6283cd925 | |
parent | 6e28e5162a44473169a5a55ce24b9eebdfcdd3e0 (diff) | |
download | gcc-f13c4673a54c76a1c92018d630f48126349732b0.zip gcc-f13c4673a54c76a1c92018d630f48126349732b0.tar.gz gcc-f13c4673a54c76a1c92018d630f48126349732b0.tar.bz2 |
match.pd ((x & y) ^ (x | y) -> x ^ y): New pattern.
* match.pd ((x & y) ^ (x | y) -> x ^ y): New pattern.
* gcc.dg/fold-xor-3.c: New test.
From-SVN: r224370
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/match.pd | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/fold-xor-3.c | 37 |
4 files changed, 51 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cfa86f6..6327ef5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2015-06-11 Marek Polacek <polacek@redhat.com> + * match.pd ((x & y) ^ (x | y) -> x ^ y): New pattern. + +2015-06-11 Marek Polacek <polacek@redhat.com> + * match.pd: Use single_use throughout. 2015-06-11 Kyrylo Tkachov <kyrylo.tkachov@arm.com> diff --git a/gcc/match.pd b/gcc/match.pd index 33fa717..9a1317e 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -320,6 +320,12 @@ along with GCC; see the file COPYING3. If not see (bitop:c (rbitop:c @0 @1) (bit_not@2 @0)) (bitop @1 @2))) +/* (x & y) ^ (x | y) -> x ^ y */ +(simplify + (bit_xor:c (bit_and@2 @0 @1) (bit_ior@3 @0 @1)) + (if (single_use (@2) && single_use (@3)) + (bit_xor @0 @1))) + (simplify (abs (negate @0)) (abs @0)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cf2c0d6..f5abd3d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-06-11 Marek Polacek <polacek@redhat.com> + + * gcc.dg/fold-xor-3.c: New test. + 2015-06-11 Kyrylo Tkachov <kyrylo.tkachov@arm.com> * gcc.target/arm/short-it-ifcvt-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/fold-xor-3.c b/gcc/testsuite/gcc.dg/fold-xor-3.c new file mode 100644 index 0000000..c2c0af6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-xor-3.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (signed int x, signed int y) +{ + signed int tem1 = x & y; + signed int tem2 = x | y; + return tem1 ^ tem2; +} + +unsigned int +fn2 (unsigned int x, unsigned int y) +{ + unsigned int tem1 = x & y; + unsigned int tem2 = x | y; + return tem1 ^ tem2; +} + +int +fn3 (signed int x, signed int y) +{ + signed int tem1 = x & y; + signed int tem2 = x | y; + return tem2 ^ tem1; +} + +unsigned int +fn4 (unsigned int x, unsigned int y) +{ + unsigned int tem1 = x & y; + unsigned int tem2 = x | y; + return tem2 ^ tem1; +} + +/* { dg-final { scan-tree-dump-not " & " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */ |