summaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-10 11:47:53 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-10 11:47:53 +0000
commite407654009147ad3a1637818b62deb2e5026ef94 (patch)
tree9621814c43521e40189c352f06dcc0e2f29e1311 /gcc/match.pd
parentc8f6378fad7663b3af501ffbafabec417e368b92 (diff)
downloadgcc-e407654009147ad3a1637818b62deb2e5026ef94.tar.gz
2014-11-10 Richard Biener <rguenther@suse.de>
* match.pd: Implement pattern from simplify_conversion_from_bitmask. * tree-ssa-forwprop.c (simplify_conversion_from_bitmask): Remove. (pass_forwprop::execute): Do not call simplify_conversion_from_bitmask. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@217284 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index 04c657608bb..c88beb94b75 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -431,3 +431,15 @@ along with GCC; see the file COPYING3. If not see
(unsigned) significand_size (TYPE_MODE (inter_type))
>= inside_prec - !inside_unsignedp)
(convert @0))))))
+
+/* 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)))