From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1314) id 79E143857009; Wed, 2 Aug 2023 08:09:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79E143857009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690963747; bh=inc5zRpn1c1MNjlqjBbfBwt2ezd5km+ftZy8rprRNug=; h=From:To:Subject:Date:From; b=B6kBVNxNcd+6JGr6eVQnIwmtKYZSPoPtcg9zimmmF/HxJPnuJSdWNHFWRzRurzz48 byF7pN8Ae2CfoJQveS9Nz32AlEfp/7c+T6o9c3bAset8AfiqE8vxspM6Mgvw2jXqhf anwZqbVSBcPNRotwVEPh1B2d5VpzkuPH2Yt5qcLk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Pinski To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-2925] Move `~X & X` and `~X | X` over to use bitwise_inverted_equal_p X-Act-Checkin: gcc X-Git-Author: Andrew Pinski X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 7ff1d1b156cc78034e299757629de33e110a30b1 X-Git-Newrev: 2bae476b511dc441bf61da8a49cca655575e7dd6 Message-Id: <20230802080907.79E143857009@sourceware.org> Date: Wed, 2 Aug 2023 08:09:07 +0000 (GMT) List-Id: https://gcc.gnu.org/g:2bae476b511dc441bf61da8a49cca655575e7dd6 commit r14-2925-g2bae476b511dc441bf61da8a49cca655575e7dd6 Author: Andrew Pinski Date: Sat Jul 29 13:00:04 2023 -0700 Move `~X & X` and `~X | X` over to use bitwise_inverted_equal_p This is a simple patch to move these 2 patterns over to use bitwise_inverted_equal_p. It also allows us to remove 2 other patterns which were used on comparisons as they are now handled by the original pattern. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * match.pd (`~X & X`, `~X | X`): Move over to use bitwise_inverted_equal_p, removing :c as bitwise_inverted_equal_p handles that already. Remove range test simplifications to true/false as they are now handled by these patterns. Diff: --- gcc/match.pd | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index cfd6ea08807..c62f205c13c 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1157,8 +1157,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* Simplify ~X & X as zero. */ (simplify - (bit_and:c (convert? @0) (convert? (bit_not @0))) - { build_zero_cst (type); }) + (bit_and (convert? @0) (convert? @1)) + (if (bitwise_inverted_equal_p (@0, @1)) + { build_zero_cst (type); })) /* PR71636: Transform x & ((1U << b) - 1) -> x & ~(~0U << b); */ (simplify @@ -1395,8 +1396,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* ~x ^ x -> -1 */ (for op (bit_ior bit_xor) (simplify - (op:c (convert? @0) (convert? (bit_not @0))) - (convert { build_all_ones_cst (TREE_TYPE (@0)); }))) + (op (convert? @0) (convert? @1)) + (if (bitwise_inverted_equal_p (@0, @1)) + (convert { build_all_ones_cst (TREE_TYPE (@0)); })))) /* x ^ x -> 0 */ (simplify @@ -6004,24 +6006,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_and:c (ordered @0 @0) (ordered:c@2 @0 @1)) @2) -/* Simple range test simplifications. */ -/* A < B || A >= B -> true. */ -(for test1 (lt le le le ne ge) - test2 (ge gt ge ne eq ne) - (simplify - (bit_ior:c (test1 @0 @1) (test2 @0 @1)) - (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) - || VECTOR_INTEGER_TYPE_P (TREE_TYPE (@0))) - { constant_boolean_node (true, type); }))) -/* A < B && A >= B -> false. */ -(for test1 (lt lt lt le ne eq) - test2 (ge gt eq gt eq gt) - (simplify - (bit_and:c (test1 @0 @1) (test2 @0 @1)) - (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) - || VECTOR_INTEGER_TYPE_P (TREE_TYPE (@0))) - { constant_boolean_node (false, type); }))) - /* A & (2**N - 1) <= 2**K - 1 -> A & (2**N - 2**K) == 0 A & (2**N - 1) > 2**K - 1 -> A & (2**N - 2**K) != 0