From patchwork Thu Aug 24 19:14:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 136866 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp1335868vqm; Thu, 24 Aug 2023 12:16:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfL8i2MZMmZ+pm+SGF0RJMvtgbChWgmC2U68lFWMOT3wgJbF9nlz5GJMCg8pewwVXD95dx X-Received: by 2002:a05:6512:3d1a:b0:500:a60d:c677 with SMTP id d26-20020a0565123d1a00b00500a60dc677mr611522lfv.59.1692904617184; Thu, 24 Aug 2023 12:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692904617; cv=none; d=google.com; s=arc-20160816; b=RK5YT4cqdPJaRpE6X+8qrboLd0lZWlKmCGG20djcbRTU8h64RRiIlRIklFUcw031zn 8dZlX+8pTlXcYsrwVk1XMwVIhSOE/hdtf1AHh3vmeherKP2pPrWoBOWvdJhXUZIb15Uq 0N/6M70C3zANZKWmvthzh3sTlYbWHi2+h+XGQEfP5j7OeKlakHvmAdC4gMzglMP3LA33 ghicUOfEPYFjHxtahmH0tNOCAZCnH9MIxRJFz8W6LJxSVfKjfVYFDrA5wfymV3HJ4/gG CazZy7po/ysc4tnSLZmNuWU5gXc/3IRI0d6tCsDFOC7O6OVp6W1azb7Z+GHBxMf3UZcU nvaQ== 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=5qPbo+1pCMquMgFi2VlLdnKIjk+DRY5c6740cJF3Mn8=; fh=XbcmRug6/SzczusyoNU1I7Lu5oY0AN2u0mWDzKoxdSs=; b=SOy8tjXX88qwtQUx9v/AFAV6ztWdG3ER+m6XCRInf0TzlVcu6U2bOzWSgaW98kxJPp yjZf+rasTI+o/uTJAXCkBaDXfRSsHX11oivvcCvjXNhjByaLyV10P9jlhdCjecwg3kn7 /RplpXVnsR20K0Kabh3CFM1rWaxdq56CZh/uRE8VSLdpb0atd1enonaKkRA6H9In+ezS mBWRTHNOh/ZEA+8ZccKTLOMIFa91iGxUZJTyLXVvrUzi92NDC2Cpz/EibxiieFt+F0UF 5JSCLUqW4ESWf7ZHeOZ44GGFcxnutwRtjafwoFL3lAfnOVzDRN3ddRpmttAVbcyVVNJd 0N3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Z8bm1NRq; 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 h10-20020aa7de0a000000b00522270f709csi118599edv.514.2023.08.24.12.16.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 12:16:57 -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=Z8bm1NRq; 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 E0E943853559 for ; Thu, 24 Aug 2023 19:15:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E0E943853559 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692904557; bh=5qPbo+1pCMquMgFi2VlLdnKIjk+DRY5c6740cJF3Mn8=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Z8bm1NRqF35IDSFRKhlrGwYyEtjjWj+YFDfjZpWnhh1OIV+JeFDXKJvwImO2CTngT 00xJccmhkk5we/yFcw1WK84ts0Le8uC74uxC2mGMduDWnnRlMo4Smkm4AVo8fEfc/x bEZAULTtkdN2UglQaRyOsu/9B9P1qaOD1MdushBQ= 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 1C6F3385842E for ; Thu, 24 Aug 2023 19:15:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C6F3385842E 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 37OHwCo3001835 for ; Thu, 24 Aug 2023 12:15:07 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3sn20d14tm-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 24 Aug 2023 12:15:06 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 24 Aug 2023 12:15:03 -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; Thu, 24 Aug 2023 12:15:03 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 712AF3F70AC; Thu, 24 Aug 2023 12:15:03 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH 1/3] MATCH: Move `a ? one_zero : one_zero` matching after min/max matching Date: Thu, 24 Aug 2023 12:14:53 -0700 Message-ID: <20230824191455.3547513-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Proofpoint-GUID: ah7aDjCfHQ_-rD3U826D_f_g54aHYeDe X-Proofpoint-ORIG-GUID: ah7aDjCfHQ_-rD3U826D_f_g54aHYeDe 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-08-24_15,2023-08-24_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.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: INBOX X-GMAIL-THRID: 1775139152059308106 X-GMAIL-MSGID: 1775139152059308106 In PR 106677, I noticed that on the trunk we were producing: ``` _25 = SR.116_117 == 0; _27 = (unsigned char) _25; _32 = _27 | SR.116_117; ``` From `SR.115_117 != 0 ? SR.115_117 : 1` Rather than: ``` _119 = MAX_EXPR <1, SR.115_117>; ``` Or (rather) ``` _119 = SR.115_117 | 1; ``` Due to the order of the patterns. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * match.pd (`a ? one_zero : one_zero`): Move below detection of minmax. --- gcc/match.pd | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 890f050cbad..c87a0795667 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -4950,24 +4950,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) ) ) -(simplify - (cond @0 zero_one_valued_p@1 zero_one_valued_p@2) - (switch - /* bool0 ? bool1 : 0 -> bool0 & bool1 */ - (if (integer_zerop (@2)) - (bit_and (convert @0) @1)) - /* bool0 ? 0 : bool2 -> (bool0^1) & bool2 */ - (if (integer_zerop (@1)) - (bit_and (bit_xor (convert @0) { build_one_cst (type); } ) @2)) - /* bool0 ? 1 : bool2 -> bool0 | bool2 */ - (if (integer_onep (@1)) - (bit_ior (convert @0) @2)) - /* bool0 ? bool1 : 1 -> (bool0^1) | bool1 */ - (if (integer_onep (@2)) - (bit_ior (bit_xor (convert @0) @2) @1)) - ) -) - /* Optimize # x_5 in range [cst1, cst2] where cst2 = cst1 + 1 x_5 ? cstN ? cst4 : cst3 @@ -5298,6 +5280,26 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && integer_nonzerop (fold_build2 (GE_EXPR, boolean_type_node, @3, @1))) (max @2 @4)))))) +#if GIMPLE +(simplify + (cond @0 zero_one_valued_p@1 zero_one_valued_p@2) + (switch + /* bool0 ? bool1 : 0 -> bool0 & bool1 */ + (if (integer_zerop (@2)) + (bit_and (convert @0) @1)) + /* bool0 ? 0 : bool2 -> (bool0^1) & bool2 */ + (if (integer_zerop (@1)) + (bit_and (bit_xor (convert @0) { build_one_cst (type); } ) @2)) + /* bool0 ? 1 : bool2 -> bool0 | bool2 */ + (if (integer_onep (@1)) + (bit_ior (convert @0) @2)) + /* bool0 ? bool1 : 1 -> (bool0^1) | bool1 */ + (if (integer_onep (@2)) + (bit_ior (bit_xor (convert @0) @2) @1)) + ) +) +#endif + /* X != C1 ? -X : C2 simplifies to -X when -C1 == C2. */ (simplify (cond (ne @0 INTEGER_CST@1) (negate@3 @0) INTEGER_CST@2) From patchwork Thu Aug 24 19:14:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 136865 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp1335860vqm; Thu, 24 Aug 2023 12:16:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2NCFpx9Sp1Uxsh6S8tVsfkKzlXMfAcaOERMisO1EYbw4ZVn6rDWaCBojn49ki7DCwp/+y X-Received: by 2002:aa7:c38e:0:b0:523:3e5d:8aa2 with SMTP id k14-20020aa7c38e000000b005233e5d8aa2mr13494077edq.14.1692904616458; Thu, 24 Aug 2023 12:16:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692904616; cv=none; d=google.com; s=arc-20160816; b=y8dzL7V1iiH8QlcQ6Pm/V9sGgttqn3LPnqh4e0wpD+ERroKO/+q77wMTYi6yc9a7R1 tHPJ/7uW9/h+foMds3COHlZ+1MhjU8jOvbKOg+ID1UnIaAEtK1QS0fY6ztKG2dsqwNP+ WPYq4tvx4s4CMBPDQL3DQimEN4VTnj3E5IsEnKkVyWoxr4l0cI/HCHjs99NYwVzyMrdX H+66nxVq4+x9vRHT53Kqah9Pst7rwV7gkv8XaC7U+rENPQTNO9f7V/wdHOMj0HEBLIvP /praCj+krUBV/J23IxcZPM/ZQKuonp27/P7vf2j7jyr8DPNg77oVp6870vmYlsRIoft5 Fkxw== 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:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=OMrbTz3XG11+rfXwTbDpkVkihwGZ1jOJi1xNHElmE38=; fh=XbcmRug6/SzczusyoNU1I7Lu5oY0AN2u0mWDzKoxdSs=; b=zv7y2I7gvGkuqGPolA99ZAuK40EKjTqlf/drYbNULTtLL8u/3SPYb9eC+KHXjC/fqq QL5BS0zij27s+Jc4iy52YeG/UxB8qmXI4QIgdlGJrBpse6XY2p44cT7tb86VJ/u1Et1O PZioZq04ti+qmoVmuwGBlFgYGlQEE5T7GMJ1FmcK/hkBSdVSQ2mb+bpF4XZGIPHH2Q+u +piJf8S+ABC67+i0/vPAG/6olp8fxTY54Xabotc7MsUJFtldplii1sZdVSQSTbACsSao FEvUsqWN4goFlQQROJV20F0xt+wpnlYqUoSmlRzUkamZL0OxExoW0TRAMXNcGhAbtxo4 4grg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="NMn/buT9"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r3-20020aa7d143000000b005255ad4798bsi114442edo.455.2023.08.24.12.16.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 12:16:56 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="NMn/buT9"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 7728D3851C20 for ; Thu, 24 Aug 2023 19:15:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7728D3851C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692904557; bh=OMrbTz3XG11+rfXwTbDpkVkihwGZ1jOJi1xNHElmE38=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=NMn/buT9fCbUsHb7uxrqwUxalV4v9Yh1Y9C3qbBb9XlzBnHsNOLd3lDZY8DO26KPR j7nWIM/fCiSlrutgII6cjZLphJzAsJKzWDmmoNS1u4uxdUxETd5qRSJY96VwtW2hbj Y733evMi3+8UNj8OOz5an+umO1zwMf7VCYb8Fj3g= 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 288E7385800A for ; Thu, 24 Aug 2023 19:15:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 288E7385800A 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 37OFgOAB012153 for ; Thu, 24 Aug 2023 12:15:07 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3sn20d14u9-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 24 Aug 2023 12:15:07 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 24 Aug 2023 12:15:04 -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; Thu, 24 Aug 2023 12:15:04 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id E012A3F7087; Thu, 24 Aug 2023 12:15:03 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH 2/3] MATCH: `a | C -> C` when we know that `a & ~C == 0` Date: Thu, 24 Aug 2023 12:14:54 -0700 Message-ID: <20230824191455.3547513-2-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230824191455.3547513-1-apinski@marvell.com> References: <20230824191455.3547513-1-apinski@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: HHHWhcr9chOTS9Q1neSt3zxuH8p1De5O X-Proofpoint-ORIG-GUID: HHHWhcr9chOTS9Q1neSt3zxuH8p1De5O 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-08-24_15,2023-08-24_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.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: INBOX X-GMAIL-THRID: 1775139150677850637 X-GMAIL-MSGID: 1775139150677850637 Even though this is handled by other code inside both VRP and CCP, sometimes we want to optimize this outside of VRP and CCP. An example is given in PR 106677 where phiopt will happen after VRP (which removes a cast for a comparison) and then phiopt will optimize the phi to be `a | 1` which can then be optimized to `1` due to this patch. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Note Similar code already exists in simplify_rtx for the RTL level; it was moved from combine to simplify_rtx in r0-72539-gbd1ef757767f6d. gcc/ChangeLog: * match.pd (`a | C -> C`): New pattern. --- gcc/match.pd | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/match.pd b/gcc/match.pd index c87a0795667..3bbeceb37b4 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1456,6 +1456,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && wi::bit_and_not (get_nonzero_bits (@0), wi::to_wide (@1)) == 0) @0)) +/* x | C -> C if we know that x & ~C == 0. */ +(simplify + (bit_ior SSA_NAME@0 INTEGER_CST@1) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) + && wi::bit_and_not (get_nonzero_bits (@0), wi::to_wide (@1)) == 0) + @1)) #endif /* ~(~X - Y) -> X + Y and ~(~X + Y) -> X - Y. */ From patchwork Thu Aug 24 19:14:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 136867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp1335923vqm; Thu, 24 Aug 2023 12:17:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZIj761gdX+7oy12flXdkqY/CyXeF+kaN+eDtjyn8yYDJogqUzdy9bj2yGOXuOfD9TYO3h X-Received: by 2002:a05:6402:b04:b0:525:ce69:b52d with SMTP id bm4-20020a0564020b0400b00525ce69b52dmr12206296edb.39.1692904622306; Thu, 24 Aug 2023 12:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692904622; cv=none; d=google.com; s=arc-20160816; b=YnECMqNkIdbpKhHYnT0mJF8RuDgBHexne6QFQfcgUMxr86ODRftm7rwtw+iRd94WB4 2Q7kGpd71f9Gnbpdb0EnUfHLcOLLGtuJ3apSBd27BloHaVur1CGpGYUL9UazY0ZSPIq6 4NW29sWL1GZRu8tHOAx3lF93AvacUlEZAM7x3r3H2H37clOTOMKLNVw7BBkycBBLIxnC QdiU2jqxPOFYJmKtEyQd78I/H1MpAAEU7UBzf16y/NnApKlCSRl1vnM5IDwz+vdt1qV6 lmuYhdlxRMK0msV59puYPyp/o3qFioQjvSrRx8P7H1U67MQFtSJ70LcrfVvyiGAlUN67 J/1w== 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:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=iHs8w/HrqfwP78VSTBWHRh+e6H2nspgm7cZoMYvbC+8=; fh=XbcmRug6/SzczusyoNU1I7Lu5oY0AN2u0mWDzKoxdSs=; b=SVyU26v6FSbiXdB9l74pUDhRqMFhHlcNb2e6+8B+oAWJ2Z0uSU87Au7aNQLTKL4UNL LFhjQqoDfKCIQsDBD5qn98yvkVSPrQiVgHHMKQGT2lm/VcCe6tQohV+vwcJVf+0V0e/S J4CSWJzg9PeUv98d6+xY1nDCkkfxVLxf9P4fVJxc1pk0nB/UTG+Pp019KieueODsjLjh pOonjWtbTaX5fGWa0J6rsPybUZws1q8GRejqIiZycwbztTPa5ynBh/U+DrBirl5LZ+OB J7TsmzQ/WRYk/tojoFsK+6ggNwei+NKU4R0bHgVn8irQ2Ab7GXtqHYUK13gzJF67Z0EW BRYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xHFGF05L; 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 j15-20020a50ed0f000000b0052328d01e51si115925eds.407.2023.08.24.12.17.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 12:17:02 -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=xHFGF05L; 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 31B0D38319F8 for ; Thu, 24 Aug 2023 19:16:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31B0D38319F8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692904560; bh=iHs8w/HrqfwP78VSTBWHRh+e6H2nspgm7cZoMYvbC+8=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=xHFGF05L0BQys3az7m46QAdBpL4GjI6dhQBE9ER45NtrZ64NXQbZGPBwE9na9k39m wMrc2bpnlzQadlhrsUZme51IOCBGFskMXlVXxoBTRmkOyI8aS3cmCMq8qKMvxc1aWU eGIFXY3Ex1BwXZMtFv0keoZbbFKrvAhhRwou+bAw= 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 BECAA3857027 for ; Thu, 24 Aug 2023 19:15:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BECAA3857027 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 37OFgOAC012153 for ; Thu, 24 Aug 2023 12:15:08 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3sn20d14u9-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 24 Aug 2023 12:15:08 -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; Thu, 24 Aug 2023 12:15:04 -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; Thu, 24 Aug 2023 12:15:04 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 613D23F707D; Thu, 24 Aug 2023 12:15:04 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH 3/3] PHIOPT: Allow BIT_AND and BIT_IOR in early phiopt Date: Thu, 24 Aug 2023 12:14:55 -0700 Message-ID: <20230824191455.3547513-3-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230824191455.3547513-1-apinski@marvell.com> References: <20230824191455.3547513-1-apinski@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: 0m5GYBZXbKE5rICc8wqXzf4EKxpHqL5g X-Proofpoint-ORIG-GUID: 0m5GYBZXbKE5rICc8wqXzf4EKxpHqL5g 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-08-24_15,2023-08-24_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.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: INBOX X-GMAIL-THRID: 1775139157266261935 X-GMAIL-MSGID: 1775139157266261935 Now that MIN/MAX can sometimes be transformed into BIT_AND/BIT_IOR, we should allow BIT_AND and BIT_IOR in the early phiopt. Also we produce BIT_AND/BIT_IOR for things like `bool0 ? bool1 : 0` which seems like a good thing to allow early on too. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (phiopt_early_allow): Allow BIT_AND_EXPR and BIT_IOR_EXPR. --- gcc/tree-ssa-phiopt.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 54706f4c7e7..7e63fb115db 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -469,6 +469,9 @@ phiopt_early_allow (gimple_seq &seq, gimple_match_op &op) { case MIN_EXPR: case MAX_EXPR: + /* MIN/MAX could be convert into these. */ + case BIT_IOR_EXPR: + case BIT_AND_EXPR: case ABS_EXPR: case ABSU_EXPR: case NEGATE_EXPR: