aboutsummaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-06-16 14:37:06 +0200
committerJakub Jelinek <jakub@redhat.com>2022-06-16 14:37:36 +0200
commit9642d07c35f14b9917cd115e8a9f0210fbcdcf4f (patch)
treeb6044081dc305a37c466d1858594ca8479dcb46b /gcc/match.pd
parent74e6a40335765077e235269f19d2d9905d0d9e44 (diff)
downloadgcc-9642d07c35f14b9917cd115e8a9f0210fbcdcf4f.zip
gcc-9642d07c35f14b9917cd115e8a9f0210fbcdcf4f.tar.gz
gcc-9642d07c35f14b9917cd115e8a9f0210fbcdcf4f.tar.bz2
match.pd: Improve y == MIN || x < y optimization [PR105983]
On the following testcase, we only optimize bar where this optimization is performed at GENERIC folding time, but on GIMPLE it doesn't trigger anymore, as we actually don't see (bit_and (ne @1 min_value) (ge @0 @1)) but (bit_and (ne @1 min_value) (le @1 @0)) genmatch handles :c modifier not just on commutative operations, but also comparisons and in that case it means it swaps the comparison. 2022-06-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/105983 * match.pd (y == XXX_MIN || x < y -> x <= y - 1, y != XXX_MIN && x >= y -> x > y - 1): Use :cs instead of :s on non-equality comparisons. * gcc.dg/tree-ssa/pr105983.c: New test.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index ae5dc82..3e9572e 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -2460,14 +2460,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* y == XXX_MIN || x < y --> x <= y - 1 */
(simplify
- (bit_ior:c (eq:s @1 min_value) (lt:s @0 @1))
+ (bit_ior:c (eq:s @1 min_value) (lt:cs @0 @1))
(if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
&& TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1)))
(le @0 (minus @1 { build_int_cst (TREE_TYPE (@1), 1); }))))
/* y != XXX_MIN && x >= y --> x > y - 1 */
(simplify
- (bit_and:c (ne:s @1 min_value) (ge:s @0 @1))
+ (bit_and:c (ne:s @1 min_value) (ge:cs @0 @1))
(if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
&& TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1)))
(gt @0 (minus @1 { build_int_cst (TREE_TYPE (@1), 1); }))))