2016-05-17 Marc Glisse <marc.glisse@inria.fr>
gcc/
* match.pd (~X & Y): New transformation.
gcc/testsuite/
* gcc.dg/tree-ssa/pr69270.c: Adjust.
* gcc.dg/tree-ssa/andnot-1.c: New testcase.
From-SVN: r236337
+2016-05-17 Marc Glisse <marc.glisse@inria.fr>
+
+ * match.pd (~X & Y): New transformation.
+
2016-05-17 Marc Glisse <marc.glisse@inria.fr>
* tree-vrp.c (simplify_truth_ops_using_ranges): Set range
(bit_ior:c (bit_and @0 INTEGER_CST@2) (bit_and (bit_not @0) INTEGER_CST@1))
(if (wi::bit_not (@2) == @1)
(bit_xor @0 @1)))
+/* Simplify (~X & Y) to X ^ Y if we know that (X & ~Y) is 0. */
+#if GIMPLE
+(simplify
+ (bit_and (bit_not SSA_NAME@0) INTEGER_CST@1)
+ (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
+ && (get_nonzero_bits (@0) & wi::bit_not (@1)) == 0)
+ (bit_xor @0 @1)))
+#endif
/* X % Y is smaller than Y. */
(for cmp (lt ge)
+2016-05-17 Marc Glisse <marc.glisse@inria.fr>
+
+ * gcc.dg/tree-ssa/pr69270.c: Adjust.
+ * gcc.dg/tree-ssa/andnot-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" } */
+
+unsigned f(unsigned i){
+ i >>= __SIZEOF_INT__ * __CHAR_BIT__ - 3;
+ i = ~i;
+ return i & 7;
+}
+
+/* { dg-final { scan-tree-dump "bit_xor_expr" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "bit_not_expr" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "bit_and_expr" "optimized" } } */