2016-05-17 Marc Glisse <marc.glisse@inria.fr>
gcc/
* match.pd (X & C): New transformation.
gcc/testsuite/
* gcc.dg/tree-ssa/and-1.c: New testcase.
From-SVN: r236338
+2016-05-17 Marc Glisse <marc.glisse@inria.fr>
+
+ * match.pd (X & C): New transformation.
+
2016-05-17 Marc Glisse <marc.glisse@inria.fr>
* match.pd (~X & Y): New transformation.
(bitop @0 @0)
(non_lvalue @0)))
+/* x & C -> x if we know that x & ~C == 0. */
+#if GIMPLE
+(simplify
+ (bit_and SSA_NAME@0 INTEGER_CST@1)
+ (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
+ && (get_nonzero_bits (@0) & wi::bit_not (@1)) == 0)
+ @0))
+#endif
+
/* x + (x & 1) -> (x + 1) & ~1 */
(simplify
(plus:c @0 (bit_and:s @0 integer_onep@1))
+2016-05-17 Marc Glisse <marc.glisse@inria.fr>
+
+ * gcc.dg/tree-ssa/and-1.c: New testcase.
+
2016-05-17 Marc Glisse <marc.glisse@inria.fr>
* gcc.dg/tree-ssa/pr69270.c: Adjust.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized-raw" } */
+
+int f(int in) {
+ in = in | 3;
+ in = in ^ 1;
+ in = (in & ~(unsigned long)1);
+ return in;
+}
+
+/* { dg-final { scan-tree-dump-not "bit_and_expr" "optimized" } } */