summaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-12-17 11:48:33 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-12-17 11:48:33 +0000
commitf52baa7b6e1c62c273a2f1ffe045640ec90d6e6a (patch)
tree2e29b1533f3226e100e504279cc9c7425fa26b14 /gcc/match.pd
parent4c57980f9d30e6947025424536eeed42bf6e1239 (diff)
downloadgcc-f52baa7b6e1c62c273a2f1ffe045640ec90d6e6a.tar.gz
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
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index dbca99efb01..4d4bc9fac8e 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