Applied.

Richard.

2014-09-11  Richard Biener  <rguent...@suse.de>

        * match-plusminus.pd: Fix typo.
        * match-conversions.pd: Add pattern for
        simplify_conversion_from_bitmask.

Index: gcc/match-conversions.pd
===================================================================
--- gcc/match-conversions.pd    (revision 215162)
+++ gcc/match-conversions.pd    (working copy)
@@ -202,3 +202,19 @@
        (unsigned) significand_size (TYPE_MODE (inter_type))
        >= inside_prec - !inside_unsignedp)
     (convert @0))))))
+
+/* From tree-ssa-forwprop.c:simplify_conversion_from_bitmask.  */
+
+/* If we have a narrowing conversion to an integral
+   type that is fed by a BIT_AND_EXPR, we might be
+   able to remove the BIT_AND_EXPR if it merely
+   masks off bits outside the final type (and nothing
+   else.  */
+(simplify
+  (convert (bit_and @0 INTEGER_CST@1))
+  (if (INTEGRAL_TYPE_P (type)
+       && INTEGRAL_TYPE_P (TREE_TYPE (@0))
+       && TYPE_PRECISION (type) <= TYPE_PRECISION (TREE_TYPE (@0))
+       && operand_equal_p (@1, build_low_bits_mask (TREE_TYPE (@1),
+                                                   TYPE_PRECISION (type)), 0))
+   (convert @0)))
Index: gcc/match-plusminus.pd
===================================================================
--- gcc/match-plusminus.pd      (revision 215169)
+++ gcc/match-plusminus.pd      (working copy)
@@ -137,8 +137,8 @@ along with GCC; see the file COPYING3.
   (pointer_plus @0 (convert?@2 (minus@3 (convert @1) (convert @0))))
   /* Conditionally look through a sign-changing conversion.  */
   (if (TYPE_PRECISION (TREE_TYPE (@2)) == TYPE_PRECISION (TREE_TYPE (@3))
-       && ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (@1))
-           || (GENERIC && type == TREE_TYPE (@1)))))
+       && ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (@1)))
+           || (GENERIC && type == TREE_TYPE (@1))))
    @1))
 
 /* From tree-ssa-forwprop.c:associate_pointerplus_align.  */

Reply via email to