From patchwork Mon Apr 24 21:30:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 87169 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3016684vqo; Mon, 24 Apr 2023 14:33:51 -0700 (PDT) X-Google-Smtp-Source: AKy350aPmdP7lNWelm7yFX1z7oHVATXBpXEZPXtpm3jU/emIeHA2LQpDWIiO50d8mfn8NTdp3mU+ X-Received: by 2002:a17:906:2e8f:b0:94e:fd61:8482 with SMTP id o15-20020a1709062e8f00b0094efd618482mr11789740eji.35.1682372031128; Mon, 24 Apr 2023 14:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682372031; cv=none; d=google.com; s=arc-20160816; b=OC+uJZMrx8bWmu+wZBlRcwhdCq//wAoMI3BPsuYgol64/Zz8XqGxt5UOLWR/3EqMeE z2HM0dtt1gJWE+Kv0MLU1SA2o3ckfqyPqQpX9j/ozsz+Yz/IyeRrdAJhveaFOOxAt/Pb U8/sQWcgOgz8bZRY05vTcztr+pLPFW1FwXeW+qpM4mcyTArqpr84d5F3PWcivrOHfNUv F5LYkfJzyG9+9M9l6zIXFtakBJpMECpVmKdLPH1kYELt17uAAYS7MJ5z64M+HEcYLCnK pM2EPDE50N3JP3iaX24IoaPA/EwuvxBrAVpeYRSPDkgrgKjD98LkpxpdnHx0JaDV3Wx8 I7rg== 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=QfwfrWDzxGU+gKIx5vlYer0NKaxbi8iE7VhxQtfmRrQ=; b=FQh7UpkzMpmiMDm6EPAe1R6rOw22+x7UoEGJAUhJGq6RjHsIH7csLi/bvHz09GsB/I 6FJr1IY7NlWCIP7+OfvU7+lUhG2+SfIPbcakOpYgzFAJ2CX836EdJ36a1y71medjoLM3 1JsgXEdSSfQ0PKwTxvAAoPPN4nS23tKoEynncizJUwaPMERDoH2M6pXVvmmNlkhrcebL G0GCRXlQ/Uu95OoPnr8GuywnACicK3h78u66abnWbeBHBO9CgL5ME9cjdsyugPVg6bjc fcZnUshr8r1qYmHCor+DaC3Rx0ogk6SYV2Hme+p0f4gDs+Q51ed+tdUm1beu+1KS8hwN mC3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BLagoUOU; 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 s5-20020a170906c30500b0094f38484c95si8001048ejz.171.2023.04.24.14.33.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Apr 2023 14:33:51 -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=BLagoUOU; 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 00787385B518 for ; Mon, 24 Apr 2023 21:32:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00787385B518 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682371929; bh=QfwfrWDzxGU+gKIx5vlYer0NKaxbi8iE7VhxQtfmRrQ=; 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=BLagoUOUS0VLAy40BQocBbhinpxYlGXK8eFL1o+GeYCkEJiRXDYtCwvWMvU1YhcY1 HVCytrxTMXpBXk1kGcsD7CDwS0/ang2/ub525AMrbAT5yUNlhLBzjj1D8DMWxe+thN QxV/kKziViNtAot4zT5yUKq0K0onfEiC88bPW93U= 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 E14283858D32 for ; Mon, 24 Apr 2023 21:30:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E14283858D32 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 33OKnSI4010728 for ; Mon, 24 Apr 2023 14:30:25 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3q4f3p7pyj-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 24 Apr 2023 14:30:25 -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; Mon, 24 Apr 2023 14:30:21 -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; Mon, 24 Apr 2023 14:30:21 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 49A263F70B6; Mon, 24 Apr 2023 14:30:21 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH 5/7] PHIOPT: Allow MIN/MAX to have up to 2 MIN/MAX expressions for early phiopt Date: Mon, 24 Apr 2023 14:30:09 -0700 Message-ID: <20230424213011.528181-6-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230424213011.528181-1-apinski@marvell.com> References: <20230424213011.528181-1-apinski@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: JXlWfd9yETdLjgvrSB1QGGjRlnlYMU5V X-Proofpoint-GUID: JXlWfd9yETdLjgvrSB1QGGjRlnlYMU5V X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-24_11,2023-04-21_01,2023-02-09_01 X-Spam-Status: No, score=-14.5 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_NONE, 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?1764094934982502013?= X-GMAIL-MSGID: =?utf-8?q?1764094934982502013?= In the early PHIOPT mode, the original minmax_replacement, would replace a PHI node with up to 2 min/max expressions in some cases, this allows for that too. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (phiopt_early_allow): Allow for up to 2 min/max expressions in the sequence/match code. --- gcc/tree-ssa-phiopt.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index fb2d2c9fc1a..de1896aa91a 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -542,9 +542,23 @@ phiopt_early_allow (gimple_seq &seq, gimple_match_op &op) return false; tree_code code = (tree_code)op.code; - /* For non-empty sequence, only allow one statement. */ + /* For non-empty sequence, only allow one statement + except for MIN/MAX, allow max 2 statements, + each with MIN/MAX. */ if (!gimple_seq_empty_p (seq)) { + if (code == MIN_EXPR || code == MAX_EXPR) + { + if (!gimple_seq_singleton_p (seq)) + return false; + + gimple *stmt = gimple_seq_first_stmt (seq); + /* Only allow assignments. */ + if (!is_gimple_assign (stmt)) + return false; + code = gimple_assign_rhs_code (stmt); + return code == MIN_EXPR || code == MAX_EXPR; + } /* Check to make sure op was already a SSA_NAME. */ if (code != SSA_NAME) return false;