From patchwork Tue Sep 12 15:25:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 138274 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp495516vqx; Tue, 12 Sep 2023 08:41:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXJPoLvc2RXziWcv+z1pkfMMr6Jif16jFELmDLP25U452PmtXTYj4Ulloqb7BeX7BIpWZc X-Received: by 2002:a17:906:31d8:b0:9a5:b814:8254 with SMTP id f24-20020a17090631d800b009a5b8148254mr10140669ejf.24.1694533268476; Tue, 12 Sep 2023 08:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694533268; cv=none; d=google.com; s=arc-20160816; b=A+ifRpBmZrJFc3UvSpe/ogqqYELTeZ0GV/k8/Oi0FG0YbR3P5r6nt8A/pLB7voXcV3 dGUVLlO7z8By/+3uOycCTWjP/Tt8+maRRrUv+HiqSPtxSHc+M3uMIjuh4usxlAeKj4af 5AmxwAjeIx2RuiLPNzXQSFAdL9VQfjznFbqXrcyxoVc8a1sX7WmyDoB85XnP9fb/DKF2 5DAZTcWvVXI0YgvH7RkLL7Qa45YjxiBWjqd2yM4nNlzjchm19WbXi4/VJzNV2IMKPdH5 K40DHni97x8Dw2A2gvishvQOq2L1+wMuNTH/i3CGHUOZZXdZhxPjR2dEeVUwI1UBNYTg 3dfA== 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=ujfIvN7hchX6OYrZV3iVlGisvE1JQxpzZFCd8qAdqHo=; fh=XbcmRug6/SzczusyoNU1I7Lu5oY0AN2u0mWDzKoxdSs=; b=FWx68/oIPJv4MYT6jSqLi/2PcB9T4MXHBEi11sH2eSSlFKgI4s2M2bYu85zTzJr9xt /3Kc1TazABCCXr+3LRGAx/70GdMRWDij5DHa7+PoklfGfK776I+D0vp4QwZmo1wS99wL tqDUKrXxcHQhiecAZ8pT3UCgCHzepGZnC/5QrdcbnvkSDM6JzGqcv1/4Dg2f6wi7i/R7 +xKR4/tZec+EtMjtl/JK3fJRMZ2PxSDy31ABzspl64D8qPpmXw9FFmRfJ39KJO+4EamY 2m0zfxfUiWi7yrPhWTv4voDAgf9UM02drUeih6wJjxsFsRPKLeC9NP7oh+dLEaWHB7JN eJMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=a2gn4ny3; 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 qu15-20020a170907110f00b0099b56bacec3si9106990ejb.955.2023.09.12.08.41.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 08:41:08 -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=a2gn4ny3; 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 7D7E43899426 for ; Tue, 12 Sep 2023 15:32:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D7E43899426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694532764; bh=ujfIvN7hchX6OYrZV3iVlGisvE1JQxpzZFCd8qAdqHo=; 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=a2gn4ny3BAdEOeNPY1yqNEOJI/85UexgD5jEULusSKT6zRa95ftApXSVHsU9hE4ab lBXoWwqBsOpoVhQb0UZW6hPj2tCXUOJ/85+qVr2lrvxP/+JnX/AiusJR4jJLNMOdE5 7vtVvtVDrdkKakK/+nrI+2I+i45Np0tMrLCE/SWE= 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 AA6D438515C9 for ; Tue, 12 Sep 2023 15:25:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA6D438515C9 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 38C7K8ES031999 for ; Tue, 12 Sep 2023 08:25:57 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3t2kgesv4t-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 12 Sep 2023 08:25:57 -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; Tue, 12 Sep 2023 08:25:56 -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 08:25:56 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 9C8A63F7045; Tue, 12 Sep 2023 08:25:55 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH 2/2] MATCH: Move `X <= MAX(X, Y)` before `MIN (X, C1) < C2` pattern Date: Tue, 12 Sep 2023 08:25:42 -0700 Message-ID: <20230912152542.1440800-2-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230912152542.1440800-1-apinski@marvell.com> References: <20230912152542.1440800-1-apinski@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: H0lxwctXnL2OZ8rP5SSCiLvTICjM5xgV X-Proofpoint-ORIG-GUID: H0lxwctXnL2OZ8rP5SSCiLvTICjM5xgV 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_14,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: 1776846916496693885 X-GMAIL-MSGID: 1776846916496693885 Since matching C1 as C2 here will decrease how much other simplifications will need to happen to get the final answer. OK? Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * match.pd (`X <= MAX(X, Y)`): Move before `MIN (X, C1) < C2` pattern. --- gcc/match.pd | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 36e3da4841b..34b67df784e 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3931,13 +3931,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (wi::lt_p (wi::to_wide (@1), wi::to_wide (@2), TYPE_SIGN (TREE_TYPE (@0)))) (cmp @0 @2))))) -/* MIN (X, C1) < C2 -> X < C2 || C1 < C2 */ -(for minmax (min min max max min min max max ) - cmp (lt le gt ge gt ge lt le ) - comb (bit_ior bit_ior bit_ior bit_ior bit_and bit_and bit_and bit_and) - (simplify - (cmp (minmax @0 INTEGER_CST@1) INTEGER_CST@2) - (comb (cmp @0 @2) (cmp @1 @2)))) /* X <= MAX(X, Y) -> true X > MAX(X, Y) -> false @@ -3949,6 +3942,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cmp:c @0 (minmax:c @0 @1)) { constant_boolean_node (cmp == GE_EXPR || cmp == LE_EXPR, type); } )) +/* MIN (X, C1) < C2 -> X < C2 || C1 < C2 */ +(for minmax (min min max max min min max max ) + cmp (lt le gt ge gt ge lt le ) + comb (bit_ior bit_ior bit_ior bit_ior bit_and bit_and bit_and bit_and) + (simplify + (cmp (minmax @0 INTEGER_CST@1) INTEGER_CST@2) + (comb (cmp @0 @2) (cmp @1 @2)))) + /* Undo fancy ways of writing max/min or other ?: expressions, like a - ((a - b) & -(a < b)) and a - (a - b) * (a < b) into (a < b) ? b : a. People normally use ?: and that is what we actually try to optimize. */