summaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2019-06-06 09:55:51 +0200
committerMartin Liska <marxin@gcc.gnu.org>2019-06-06 07:55:51 +0000
commitea8a6038b0b86ccc037d80a9b600e51b1558ad14 (patch)
tree0df38b73b39e84424d2945135bc584dc7b237e41 /gcc/match.pd
parent8ce6fb5fec60f0ce6363d2a41f30e5fc620a4beb (diff)
Simplify mult where both arguments are 0 or 1 (PR tree-optimization/87954).
2019-06-06 Martin Liska <mliska@suse.cz> PR tree-optimization/87954 * match.pd: Simplify mult where both arguments are 0 or 1. 2019-06-06 Martin Liska <mliska@suse.cz> PR tree-optimization/87954 * gcc.dg/pr87954.c: New test. From-SVN: r271991
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index 02e0471dd4e..88dae4231d8 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -217,6 +217,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
|| !COMPLEX_FLOAT_TYPE_P (type)))
(negate @0)))
+/* Transform { 0 or 1 } * { 0 or 1 } into { 0 or 1 } & { 0 or 1 } */
+(simplify
+ (mult SSA_NAME@1 SSA_NAME@2)
+ (if (INTEGRAL_TYPE_P (type)
+ && get_nonzero_bits (@1) == 1
+ && get_nonzero_bits (@2) == 1)
+ (bit_and @1 @2)))
+
/* Transform x * { 0 or 1, 0 or 1, ... } into x & { 0 or -1, 0 or -1, ...},
unless the target has native support for the former but not the latter. */
(simplify