+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
(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
--- /dev/null
+/* 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" } } */