From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id 00E38385841E for ; Mon, 31 Jul 2023 17:46:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 00E38385841E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=marvell.com Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36VFtPkP005867 for ; Mon, 31 Jul 2023 10:46:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=TJoVrqE7BWmYjWxjimS5GC4ng0bOnHzbXl7/8wcWj5k=; b=OBvTEuSx1TgVtwhifxq2ZFcGoTU8413KOdUx8y0XXsVkmMbZKTw+XDRurNPhdIBPy07m OSmmYV8g/PN+ZcpP5fnJg4M5ES/ROjl/kbJLRgbWX8EeK+P73VUvyUi7wsQe3AWZXsK8 f+XP6P5ENjZvxVJx/t6Xien+PgzYq5OdnjYm5eOzdyhwd8NnUSGMwdMcZRaoO2DNXadW 2YXwTEeMUGhHBFVX5BhnOGj5nE2TmnGQoNelxE3nQThd+S7728P0esnFjzPzxlK4w32q GzBIjQq+1oA3sSI4n/zghugrBZlvOt+v9wzC3NYHy8oYqej3+5mher8ymntu53Wa+SgG iQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3s529k5ubs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 31 Jul 2023 10:46:19 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 31 Jul 2023 10:46:15 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Mon, 31 Jul 2023 10:46:15 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 327E43F70C4; Mon, 31 Jul 2023 10:46:15 -0700 (PDT) From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH 1/2] Move `~X & X` and `~X | X` over to use bitwise_inverted_equal_p Date: Mon, 31 Jul 2023 10:46:05 -0700 Message-ID: <20230731174606.2132534-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: dUzdOGcVlJgz4T0x_I2NGR20i7VOtdRG X-Proofpoint-ORIG-GUID: dUzdOGcVlJgz4T0x_I2NGR20i7VOtdRG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-31_11,2023-07-31_02,2023-05-22_02 X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. --- gcc/match.pd | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 74f0a84f31d..7d030262698 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 @@ -5994,24 +5996,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 -- 2.31.1