diff options
author | Marek Polacek <polacek@redhat.com> | 2014-12-17 11:48:33 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-12-17 11:48:33 +0000 |
commit | f52baa7b6e1c62c273a2f1ffe045640ec90d6e6a (patch) | |
tree | 2e29b1533f3226e100e504279cc9c7425fa26b14 | |
parent | 4c57980f9d30e6947025424536eeed42bf6e1239 (diff) | |
download | gcc-f52baa7b6e1c62c273a2f1ffe045640ec90d6e6a.zip gcc-f52baa7b6e1c62c273a2f1ffe045640ec90d6e6a.tar.gz gcc-f52baa7b6e1c62c273a2f1ffe045640ec90d6e6a.tar.bz2 |
re PR middle-end/63568 (Missed optimization (a & ~mask) | (b & mask) = a ^ ((a ^ b) & mask))
PR middle-end/63568
* match.pd: Add (x & ~m) | (y & m) -> ((x ^ y) & m) ^ x pattern.
* gcc.dg/pr63568.c: New test.
From-SVN: r218816
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/match.pd | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr63568.c | 54 |
4 files changed, 71 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 631d726..7b3c4aa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-12-17 Marek Polacek <polacek@redhat.com> + + PR middle-end/63568 + * match.pd: Add (x & ~m) | (y & m) -> ((x ^ y) & m) ^ x pattern. + 2014-12-17 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/64322 diff --git a/gcc/match.pd b/gcc/match.pd index dbca99e..4d4bc9f 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -382,6 +382,13 @@ along with GCC; see the file COPYING3. If not see (bit_not (bit_not @0)) @0) +/* (x & ~m) | (y & m) -> ((x ^ y) & m) ^ x */ +(simplify + (bit_ior:c (bit_and:c@3 @0 (bit_not @2)) (bit_and:c@4 @1 @2)) + (if ((TREE_CODE (@3) != SSA_NAME || has_single_use (@3)) + && (TREE_CODE (@4) != SSA_NAME || has_single_use (@4))) + (bit_xor (bit_and (bit_xor @0 @1) @2) @0))) + /* Associate (p +p off1) +p off2 as (p +p (off1 + off2)). */ (simplify diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fbafb56..7049260 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-12-17 Marek Polacek <polacek@redhat.com> + + PR middle-end/63568 + * gcc.dg/pr63568.c: New test. + 2014-12-17 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/64322 diff --git a/gcc/testsuite/gcc.dg/pr63568.c b/gcc/testsuite/gcc.dg/pr63568.c new file mode 100644 index 0000000..fb42bea --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr63568.c @@ -0,0 +1,54 @@ +/* PR middle-end/63568 */ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +int +fn1 (int a, int b, int m) +{ + return (a & ~m) | (b & m); +} + +int +fn2 (int a, int b, int m) +{ + return (a & ~m) | (m & b); +} + +int +fn3 (int a, int b, int m) +{ + return (~m & a) | (m & b); +} + +int +fn4 (int a, int b, int m) +{ + return (~m & a) | (b & m); +} + +int +fn5 (int a, int b, int m) +{ + return (b & m) | (a & ~m); +} + +int +fn6 (int a, int b, int m) +{ + return (m & b) | (a & ~m); +} + +int +fn7 (int a, int b, int m) +{ + return (m & b) | (~m & a); +} + +int +fn8 (int a, int b, int m) +{ + return (b & m) | (~m & a); +} + +/* { dg-final { scan-tree-dump-not " \\| " "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ |