From patchwork Mon Jun 5 05:53:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 103086 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2473678vqr; Sun, 4 Jun 2023 22:54:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ht/Z2+xQF9HbaQj+8UCf2qjKnc4TzNwSHHe/Oxu0wK/MwDSb9kpZCbX3RgkPMcRD/ExeT X-Received: by 2002:a17:907:3e1e:b0:973:d857:9a33 with SMTP id hp30-20020a1709073e1e00b00973d8579a33mr5550694ejc.11.1685944490254; Sun, 04 Jun 2023 22:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685944490; cv=none; d=google.com; s=arc-20160816; b=bwMUH3e2VZ/61QzYd5tpUw4xNFU+Zai+D8jFIcpRSl79FCDcy0RZMXkVueKHcl81QP hA8GaE1hBd4e0cZK94jURmM+Qje/3fJJRsaRInP2WEzGKSDdblPO5AiHN7B89oB7J7bx 1BZcmkdpNMgbJoZ3JCSGSbJ3nv2Vm2oyzsmkamIwj8j4u9dBEqP/KjAugRMdXrFGiaU1 8Tg6BMOu08VF0ylNLlJKNRhnyylADETIIzcy9fdyaCytY9AT8/zHRo0U2Git10ALzPDg Ee7UAxVH1M7tHNiu1RwCbEuKLe5/8Y92rZn9au/stMF+JzpixEbcyl1Z2PV6zpIwH9Bh YW4A== 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=8ENLvHp9UqS+Lsdgk0t9HoL/4d4Xppd0saDIWAphxlY=; b=UWXJBSJ3Vu4oSYRDjSknAxErh39NhxQzcKWZqQ/LHTnWRCGNkL+8173k5WtQwe2+Qc YVTLJMImt86U0ftI+xndzj3a9K15z51Vv1XfJ1BuQdyXR3X86JhwaPhIcBYcfh3g4Jsz ZODNqcB/Ie33QlKN2GtH2O5LWMv8MWCgxBQBCuGSBwr/ta7A3aT6T7qUmK/9Z9q5X2dZ Vl6u8a/S8r5NBs6RZXQfCAp30ZfBRSSgEzb0F20f4rC/fwPTGeAu2RJaNNEtw0dxfICD 29jBeTJHwQCXZtr7M4yJmf8GNx1W9S7cyfTFVT/N9pxbHImwWPCJKUxuMsl3IanMkZ5y Xq2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ynyhojCK; 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 sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 29-20020a170906225d00b0096f61c20399si4647064ejr.689.2023.06.04.22.54.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jun 2023 22:54:50 -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=ynyhojCK; 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 64D30385660D for ; Mon, 5 Jun 2023 05:54:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64D30385660D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685944480; bh=8ENLvHp9UqS+Lsdgk0t9HoL/4d4Xppd0saDIWAphxlY=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ynyhojCKWHHzpx2wMrclp0q4JozhuSFLeP+Cy16CC7HPDdY+TqwzurIcFyWQIsUlq p8V3YgqAdQ1CW64XdfOmDVJqgJnXsIdsvUIyNYNf3AZUvLbrOAuBTMgBK6Et5NHtCP b0ATMO20btJvWKAbtRCi7r/lV0JLtHO6uwU9R71Q= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by sourceware.org (Postfix) with ESMTPS id 634CD3858401 for ; Mon, 5 Jun 2023 05:53:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 634CD3858401 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 354KeHLP015673 for ; Sun, 4 Jun 2023 22:53:56 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3r02vpda1j-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sun, 04 Jun 2023 22:53:56 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sun, 4 Jun 2023 22:53:55 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Sun, 4 Jun 2023 22:53:55 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id DFA0F3F704A; Sun, 4 Jun 2023 22:53:54 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH 1/2] Improve do_store_flag for single bit when there is no non-zero bits Date: Sun, 4 Jun 2023 22:53:30 -0700 Message-ID: <20230605055331.2864335-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Proofpoint-GUID: oxDWcxofHo5L3OtPZ-Mju7SnL79a0nQe X-Proofpoint-ORIG-GUID: oxDWcxofHo5L3OtPZ-Mju7SnL79a0nQe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-03_08,2023-06-02_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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767840929844887208?= X-GMAIL-MSGID: =?utf-8?q?1767840929844887208?= In r14-1534-g908e5ab5c11c, I forgot you could turn off CCP or turn off the bit tracking part of CCP so we would lose out what TER was able to do before hand. This moves around the TER code so that it is used instead of just the nonzerobits. It also makes it easier to remove the TER part of the code later on too. OK? Bootstrapped and tested on x86_64-linux-gnu. Note it reintroduces PR 110117 (which was accidently fixed after r14-1534-g908e5ab5c11c). The next patch in series will fix that. gcc/ChangeLog: * expr.cc (do_store_flag): Rearrange the TER code so that it overrides the nonzero bits info if we had `a & POW2`. --- gcc/expr.cc | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/gcc/expr.cc b/gcc/expr.cc index 58f5fe76372..ca008cd453e 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -13164,38 +13164,32 @@ do_store_flag (sepops ops, rtx target, machine_mode mode) && (TYPE_PRECISION (ops->type) != 1 || TYPE_UNSIGNED (ops->type))) { wide_int nz = tree_nonzero_bits (arg0); + gimple *srcstmt = get_def_for_expr (arg0, BIT_AND_EXPR); + /* If the defining statement was (x & POW2), then use that instead of + the non-zero bits. */ + if (srcstmt && integer_pow2p (gimple_assign_rhs2 (srcstmt))) + { + nz = wi::to_wide (gimple_assign_rhs2 (srcstmt)); + arg0 = gimple_assign_rhs1 (srcstmt); + } if (wi::popcount (nz) == 1 && (integer_zerop (arg1) || wi::to_wide (arg1) == nz)) { - tree op0; - int bitnum; - gimple *srcstmt = get_def_for_expr (arg0, BIT_AND_EXPR); - /* If the defining statement was (x & POW2), then remove the and - as we are going to add it back. */ - if (srcstmt - && integer_pow2p (gimple_assign_rhs2 (srcstmt))) - { - op0 = gimple_assign_rhs1 (srcstmt); - bitnum = tree_log2 (gimple_assign_rhs2 (srcstmt)); - } - else - { - op0 = arg0; - bitnum = wi::exact_log2 (nz); - } + int bitnum = wi::exact_log2 (nz); enum tree_code tcode = EQ_EXPR; if ((code == NE) ^ !integer_zerop (arg1)) tcode = NE_EXPR; type = lang_hooks.types.type_for_mode (mode, unsignedp); return expand_single_bit_test (loc, tcode, - op0, + arg0, bitnum, type, target, mode); } } + if (! get_subtarget (target) || GET_MODE (subtarget) != operand_mode) subtarget = 0;