From patchwork Tue Sep 12 22:10:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 138459 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp709432vqx; Tue, 12 Sep 2023 15:11:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGk2SGjh4svlcJ447bvlCC+JUpC0XshVjGvnfa+37pbZKrsNOt8vBdUei9aFx9uayOg+ptu X-Received: by 2002:a05:6402:795:b0:52a:1d9c:83f2 with SMTP id d21-20020a056402079500b0052a1d9c83f2mr729132edy.23.1694556671759; Tue, 12 Sep 2023 15:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694556671; cv=none; d=google.com; s=arc-20160816; b=tsPOB04SFvB6NaAggIjnfdJpqEIcFDMz013ZmG/Xzqa353zYXBfwe7vDnqc+Kl429u b6+XZU1olZwvPAF3XUYQz4+8JIEVvlStu1QFpuImaChPL3PKxLuoECmnL5mI7bMCOSmY G4QJCosFcLO13HgX9L6MqL/Q7y4ZkflcNH3WAYqZwXuufzuLYKvfiG88Oqx5Bamjro03 FamnxQkhny1d9SNAfWCoyRqnDCXOLv8EyWHwApz5+DCW8DJ489wGouAad7XgxlcEUNJb oNHtWPVV/WLwfBXDgXYA+S7Rj6SGb3sjBRxvVGUu5Qx4rC+8f4dIHFYupD4IHYHN89yR rrmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=CGDQ1wjjJO9XyRXArXBGBck8Sa11drDu95mFjXzsFrM=; fh=XbcmRug6/SzczusyoNU1I7Lu5oY0AN2u0mWDzKoxdSs=; b=LD89n8iAIXfVYVgvhWtZAzGRtIl9y9d3l1m+ZLD6UTd7QDi0hnJ1fLYUQd3LxrxKFP SZQuO+mwtM3/qR22ca2t3ph9cELtwV/W1/I42k92m0C9zKzh/Hcif8eFVo9btDCtDcC3 PV5AS+fNktzi3Im+Qscu8Imakr9G2Nl1b0nvv73VsxhIaJRk+b2FRMF1bsrKXLQrjFgn GO1uAs7JEa4gHRP0pflQRE/7yKEV3maPaoXC7EZz4IH9S/Wm6zs4aR5RoV+tWFIFlx9p CTNC+E4awIj6KcU9dyKbNgxQL3VxYpenLGm+rVPONopaJNxm+H1bvTyTOFdHV990T320 80Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=PTQ5vxqq; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r20-20020aa7cfd4000000b00525761581ddsi9362915edy.25.2023.09.12.15.11.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 15:11:11 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=PTQ5vxqq; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A67A13856DFE for ; Tue, 12 Sep 2023 22:11:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A67A13856DFE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694556670; bh=CGDQ1wjjJO9XyRXArXBGBck8Sa11drDu95mFjXzsFrM=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=PTQ5vxqqVhIokABe14qTsqgYxkdUNm55tv0w8wf1XCrgNdaI6//wsxyrZX/DEU815 WvkorX4sWU++5dVSYN5g37Qsog2V8zoJ54wZCAUN1NXXg40z26JqjJ7MQTd59+8Dso 8w1rgRPopIjj3VsvrQqqSJJW/vAGmPYChGdrX/Qs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id A19553858D3C for ; Tue, 12 Sep 2023 22:10:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A19553858D3C 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 38CKfXOH024911 for ; Tue, 12 Sep 2023 15:10:24 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3t2y860a71-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 12 Sep 2023 15:10:24 -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; Tue, 12 Sep 2023 15:10:22 -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; Tue, 12 Sep 2023 15:10:22 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id AE7173F70F2; Tue, 12 Sep 2023 15:10:21 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH] MATCH: Simplify `(X % Y) < Y` pattern. Date: Tue, 12 Sep 2023 15:10:13 -0700 Message-ID: <20230912221013.1456582-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: -NWxRbBfxBnmuvrW-wiZ7Ix8gVRf3a3b X-Proofpoint-GUID: -NWxRbBfxBnmuvrW-wiZ7Ix8gVRf3a3b X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-12_21,2023-09-05_01,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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Pinski via Gcc-patches From: Andrew Pinski Reply-To: Andrew Pinski Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776871456501093994 X-GMAIL-MSGID: 1776871456501093994 This merges the two patterns to catch `(X % Y) < Y` and `Y > (X % Y)` into one by using :c on the comparison operator. It does not change any code generation nor anything else. It is more to allow for better maintainability of this pattern. OK? Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * match.pd (`Y > (X % Y)`): Merge into ... (`(X % Y) < Y`): Pattern by adding `:c` on the comparison. --- gcc/match.pd | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 39c7ea1088f..24fd29863fb 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1483,14 +1483,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* X % Y is smaller than Y. */ (for cmp (lt ge) (simplify - (cmp (trunc_mod @0 @1) @1) + (cmp:c (trunc_mod @0 @1) @1) (if (TYPE_UNSIGNED (TREE_TYPE (@0))) { constant_boolean_node (cmp == LT_EXPR, type); }))) -(for cmp (gt le) - (simplify - (cmp @1 (trunc_mod @0 @1)) - (if (TYPE_UNSIGNED (TREE_TYPE (@0))) - { constant_boolean_node (cmp == GT_EXPR, type); }))) /* x | ~0 -> ~0 */ (simplify