aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2016-05-23 19:49:10 +0200
committerMarc Glisse <glisse@gcc.gnu.org>2016-05-23 17:49:10 +0000
commitece46666cd43d0996769a2e97d8acef7faa94b4d (patch)
treefff4a123b19c2bf2f538648f2f64ba9d9b634207
parentbb5e62d648ee35bf23639af2fda4ebadde9f1338 (diff)
downloadgcc-ece46666cd43d0996769a2e97d8acef7faa94b4d.zip
gcc-ece46666cd43d0996769a2e97d8acef7faa94b4d.tar.gz
gcc-ece46666cd43d0996769a2e97d8acef7faa94b4d.tar.bz2
match.pd: Relax some tree_nop_conversion_p
2016-05-23 Marc Glisse <marc.glisse@inria.fr> gcc/ * match.pd (a * (1 << b), ~x & ~y, ~X ^ ~Y, (X ^ Y) ^ Y, ~ (-A), ~ (A - 1), ~(~X >> Y), ~(~X >>r Y)): Relax constraints. gcc/testsuite/ * gcc.dg/fold-notshift-2.c: Adjust. From-SVN: r236601
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/match.pd36
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/fold-notshift-2.c6
4 files changed, 33 insertions, 18 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f487139..6091b69 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-23 Marc Glisse <marc.glisse@inria.fr>
+
+ * match.pd (a * (1 << b), ~x & ~y, ~X ^ ~Y, (X ^ Y) ^ Y, ~ (-A),
+ ~ (A - 1), ~(~X >> Y), ~(~X >>r Y)): Relax constraints.
+
2016-05-23 Jeff Law <law@redhat.com>
* tree-ssa-threadbackward.c (profitable_jump_thread_path): New function
diff --git a/gcc/match.pd b/gcc/match.pd
index f11ce7c..8d05e86 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -454,7 +454,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(simplify
(mult:c @0 (convert? (lshift integer_onep@1 @2)))
(if (! FLOAT_TYPE_P (type)
- && tree_nop_conversion_p (type, TREE_TYPE (@1)))
+ && (element_precision (type) <= element_precision (TREE_TYPE (@1))
+ || TYPE_UNSIGNED (TREE_TYPE (@1))))
(lshift @0 @2)))
/* Fold (C1/X)*C2 into (C1*C2)/X. */
@@ -655,8 +656,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
rop (bit_ior bit_and)
(simplify
(op (convert1? (bit_not @0)) (convert2? (bit_not @1)))
- (if (tree_nop_conversion_p (type, TREE_TYPE (@0))
- && tree_nop_conversion_p (type, TREE_TYPE (@1)))
+ (if (element_precision (type) <= element_precision (TREE_TYPE (@0))
+ && element_precision (type) <= element_precision (TREE_TYPE (@1)))
(bit_not (rop (convert @0) (convert @1))))))
/* If we are XORing or adding two BIT_AND_EXPR's, both of which are and'ing
@@ -681,8 +682,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* Convert ~X ^ ~Y to X ^ Y. */
(simplify
(bit_xor (convert1? (bit_not @0)) (convert2? (bit_not @1)))
- (if (tree_nop_conversion_p (type, TREE_TYPE (@0))
- && tree_nop_conversion_p (type, TREE_TYPE (@1)))
+ (if (element_precision (type) <= element_precision (TREE_TYPE (@0))
+ && element_precision (type) <= element_precision (TREE_TYPE (@1)))
(bit_xor (convert @0) (convert @1))))
/* Convert ~X ^ C to X ^ ~C. */
@@ -722,8 +723,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* (X ^ Y) ^ Y -> X */
(simplify
(bit_xor:c (convert? (bit_xor:c @0 @1)) (convert? @1))
- (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
- (convert @0)))
+ (convert @0))
/* (X & Y) & (X & Z) -> (X & Y) & Z
(X | Y) | (X | Z) -> (X | Y) | Z */
(for op (bit_and bit_ior)
@@ -915,17 +915,20 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* Convert ~ (-A) to A - 1. */
(simplify
(bit_not (convert? (negate @0)))
- (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+ (if (element_precision (type) <= element_precision (TREE_TYPE (@0))
+ || !TYPE_UNSIGNED (TREE_TYPE (@0)))
(convert (minus @0 { build_each_one_cst (TREE_TYPE (@0)); }))))
/* Convert ~ (A - 1) or ~ (A + -1) to -A. */
(simplify
(bit_not (convert? (minus @0 integer_each_onep)))
- (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+ (if (element_precision (type) <= element_precision (TREE_TYPE (@0))
+ || !TYPE_UNSIGNED (TREE_TYPE (@0)))
(convert (negate @0))))
(simplify
(bit_not (convert? (plus @0 integer_all_onesp)))
- (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+ (if (element_precision (type) <= element_precision (TREE_TYPE (@0))
+ || !TYPE_UNSIGNED (TREE_TYPE (@0)))
(convert (negate @0))))
/* Part of convert ~(X ^ Y) to ~X ^ Y or X ^ ~Y if ~X or ~Y simplify. */
@@ -1505,9 +1508,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(simplify
(bit_not (convert1?:s (rshift:s (convert2?@0 (bit_not @1)) @2)))
(if (!TYPE_UNSIGNED (TREE_TYPE (@0))
- && element_precision (TREE_TYPE (@0))
- <= element_precision (TREE_TYPE (@1))
- && element_precision (type) <= element_precision (TREE_TYPE (@0)))
+ && (element_precision (TREE_TYPE (@0))
+ <= element_precision (TREE_TYPE (@1))
+ || !TYPE_UNSIGNED (TREE_TYPE (@1))))
(with
{ tree shift_type = TREE_TYPE (@0); }
(convert (rshift (convert:shift_type @1) @2)))))
@@ -1517,8 +1520,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(for rotate (lrotate rrotate)
(simplify
(bit_not (convert1?:s (rotate:s (convert2?@0 (bit_not @1)) @2)))
- (if (element_precision (TREE_TYPE (@0)) <= element_precision (TREE_TYPE (@1))
- && element_precision (type) <= element_precision (TREE_TYPE (@0)))
+ (if ((element_precision (TREE_TYPE (@0))
+ <= element_precision (TREE_TYPE (@1))
+ || !TYPE_UNSIGNED (TREE_TYPE (@1)))
+ && (element_precision (type) <= element_precision (TREE_TYPE (@0))
+ || !TYPE_UNSIGNED (TREE_TYPE (@0))))
(with
{ tree rotate_type = TREE_TYPE (@0); }
(convert (rotate (convert:rotate_type @1) @2))))))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5a5c7b8..4d39198 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2016-05-23 Marc Glisse <marc.glisse@inria.fr>
+
+ * gcc.dg/fold-notshift-2.c: Adjust.
+
2016-05-23 Marek Polacek <polacek@redhat.com>
PR c/49859
diff --git a/gcc/testsuite/gcc.dg/fold-notshift-2.c b/gcc/testsuite/gcc.dg/fold-notshift-2.c
index 32635f1..f8aab2a 100644
--- a/gcc/testsuite/gcc.dg/fold-notshift-2.c
+++ b/gcc/testsuite/gcc.dg/fold-notshift-2.c
@@ -15,17 +15,17 @@ sl (int a, int b)
return ~((~a) << b);
}
-typedef __INT32_TYPE__ int32_t;
+typedef unsigned __INT32_TYPE__ uint32_t;
typedef __INT64_TYPE__ int64_t;
int64_t
-asr_widen1 (int32_t a, int b)
+asr_widen1 (uint32_t a, int b)
{
return ~((int64_t)(~a) >> b);
}
int64_t
-asr_widen2 (int32_t a, int b)
+asr_widen2 (uint32_t a, int b)
{
return ~(int64_t)(~a >> b);
}