From patchwork Wed Apr 26 08:33:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 87726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp90018vqo; Wed, 26 Apr 2023 01:35:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6rAzLx6jtulvsG5nHHjnnvLZ3cPoCu3mIEMwOqBnRk1v1GXBeHGzE72jJCTzNGfzbcIQC4 X-Received: by 2002:a17:906:198:b0:94e:cfd0:ed9f with SMTP id 24-20020a170906019800b0094ecfd0ed9fmr1464896ejb.26.1682498152981; Wed, 26 Apr 2023 01:35:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682498152; cv=none; d=google.com; s=arc-20160816; b=nZb2CDBvMqiQtKwUAQ7AHgetmGD44YQJmgpy29s3RVF5TlxV/wdoj2eLMUef84Zshp QL2fxHdVdWY4g1yid9xAy4GD5TWbdWRRlubA6COp/QSSfcXyMH0wiUaNCIM0TQl7Tl+Y jgW/nkFy5329/jBz12BdMrv+/6ILlqzy4ilskT3mYLn9sAXIK/SywFr0kZ89dNPYVxlK hf0lMctNncToKlV+bUyH5qnjp4Ny1K6J327CN+htR8R/WwRf1K1AOnuOCtM3zf0v/RAQ pXf0nw+yUkxtASwUU144xtugTKuu4JhTq9xti4kTgI/b6aRZbnr6/1Ut0zzkffFH0TI7 24vg== 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=6+T9Y7viJiqsI2iYjTudEVUeDDe+Nsn8nMMbHSnhM6I=; b=jRlBYRDLtAxsIS7j3Tv/G6cncLBe6lLkU9PjtaUmdobTOaGmU+TGnSPEXlg8FrKE9l HITdq05lHmzggqO4hdQUx1taXRevlmrwuQpQPVIATY1uyHZYjBQuA+y4SD8PRkHwmam7 OTJZc7vI5jMX9WpYKd8ZnhoC0jVNP+s1ZVHwWD+/vWUx0AVHU1JXWEqvrk8n/icLFRGR m0d7FaT4ymxqaxbit2ssnOcQEkioINuQPYW+IVWfr/sDH0ben6Fzlx89XcHX6McNqCdE w+rB8OcP0P266NLvkZD9ud9664nUtWgmo7V364Ng2oxEHlbymrpuuXf7N8eUw4yZMu1b Zm6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kd2QyrlL; 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l4-20020a170906a40400b0094f435036c0si11813367ejz.378.2023.04.26.01.35.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 01:35:52 -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=kd2QyrlL; 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 6A9B3385624A for ; Wed, 26 Apr 2023 08:35:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A9B3385624A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682498105; bh=6+T9Y7viJiqsI2iYjTudEVUeDDe+Nsn8nMMbHSnhM6I=; 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=kd2QyrlLhGIo0vPtaXxeyVWasm95Ii+NsVEo1Y3hzCcrNS22EMMJiRJ0K+GBt6GRC rB2p8vmOAAjXDDO0UKe6C84tB2weqALindTSG7xlAp/xH/0ATMgIMOkuyvfGGmaes5 sEOMEedOhaDIEQKCX46LePI3hjlfK4xnf35G6sVk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 48AE23858C1F for ; Wed, 26 Apr 2023 08:34:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 48AE23858C1F Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-652-1-72kPk7OUWM7KFNH3JgMA-1; Wed, 26 Apr 2023 04:34:04 -0400 X-MC-Unique: 1-72kPk7OUWM7KFNH3JgMA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 376443C1068E for ; Wed, 26 Apr 2023 08:34:04 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.195.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C394B1121315; Wed, 26 Apr 2023 08:34:03 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 33Q8Y17f313610 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 26 Apr 2023 10:34:01 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 33Q8Y1K9313609; Wed, 26 Apr 2023 10:34:01 +0200 To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] Remove deprecated range_fold_{unary, binary}_expr uses from ipa-*. Date: Wed, 26 Apr 2023 10:33:23 +0200 Message-Id: <20230426083328.313566-4-aldyh@redhat.com> In-Reply-To: <20230426083328.313566-1-aldyh@redhat.com> References: <20230426083328.313566-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez 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?1764227182925788111?= X-GMAIL-MSGID: =?utf-8?q?1764227182925788111?= gcc/ChangeLog: * ipa-cp.cc (ipa_vr_operation_and_type_effects): Convert to ranger API. (ipa_value_range_from_jfunc): Same. (propagate_vr_across_jump_function): Same. * ipa-fnsummary.cc (evaluate_conditions_for_known_args): Same. * ipa-prop.cc (ipa_compute_jump_functions_for_edge): Same. * vr-values.cc (bounds_of_var_in_loop): Same. --- gcc/ipa-cp.cc | 28 +++++++++++++++++++++------ gcc/ipa-fnsummary.cc | 45 ++++++++++++++++++++++++++++---------------- gcc/ipa-prop.cc | 5 ++--- gcc/vr-values.cc | 6 ++++-- 4 files changed, 57 insertions(+), 27 deletions(-) diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 65c49558b58..6788883c40b 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -128,6 +128,7 @@ along with GCC; see the file COPYING3. If not see #include "attribs.h" #include "dbgcnt.h" #include "symtab-clones.h" +#include "gimple-range.h" template class ipcp_value; @@ -1900,10 +1901,15 @@ ipa_vr_operation_and_type_effects (value_range *dst_vr, enum tree_code operation, tree dst_type, tree src_type) { - range_fold_unary_expr (dst_vr, operation, dst_type, src_vr, src_type); - if (dst_vr->varying_p () || dst_vr->undefined_p ()) + if (!irange::supports_p (dst_type) || !irange::supports_p (src_type)) return false; - return true; + + range_op_handler handler (operation, dst_type); + return (handler + && handler.fold_range (*dst_vr, dst_type, + *src_vr, value_range (dst_type)) + && !dst_vr->varying_p () + && !dst_vr->undefined_p ()); } /* Determine value_range of JFUNC given that INFO describes the caller node or @@ -1958,8 +1964,13 @@ ipa_value_range_from_jfunc (ipa_node_params *info, cgraph_edge *cs, value_range op_res, res; tree op = ipa_get_jf_pass_through_operand (jfunc); value_range op_vr (op, op); + range_op_handler handler (operation, vr_type); + + if (!handler + || !op_res.supports_type_p (vr_type) + || !handler.fold_range (op_res, vr_type, srcvr, op_vr)) + op_res.set_varying (vr_type); - range_fold_binary_expr (&op_res, operation, vr_type, &srcvr, &op_vr); if (ipa_vr_operation_and_type_effects (&res, &op_res, NOP_EXPR, parm_type, @@ -2748,9 +2759,14 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc, tree op = ipa_get_jf_pass_through_operand (jfunc); value_range op_vr (op, op); value_range op_res,res; + range_op_handler handler (operation, operand_type); + + if (!handler + || !op_res.supports_type_p (operand_type) + || !handler.fold_range (op_res, operand_type, + src_lats->m_value_range.m_vr, op_vr)) + op_res.set_varying (operand_type); - range_fold_binary_expr (&op_res, operation, operand_type, - &src_lats->m_value_range.m_vr, &op_vr); ipa_vr_operation_and_type_effects (&vr, &op_res, NOP_EXPR, param_type, diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc index d4b2a073240..03142960e60 100644 --- a/gcc/ipa-fnsummary.cc +++ b/gcc/ipa-fnsummary.cc @@ -481,13 +481,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node, && (TYPE_SIZE (c->type) == TYPE_SIZE (vr.type ()))) { if (!useless_type_conversion_p (c->type, vr.type ())) - { - value_range res; - range_fold_unary_expr (&res, NOP_EXPR, - c->type, &vr, vr.type ()); - vr = res; - } - tree type = c->type; + range_cast (vr, c->type); for (j = 0; vec_safe_iterate (c->param_ops, j, &op); j++) { @@ -496,26 +490,45 @@ evaluate_conditions_for_known_args (struct cgraph_node *node, value_range res; if (!op->val[0]) - range_fold_unary_expr (&res, op->code, op->type, &vr, type); + { + range_op_handler handler (op->code, op->type); + if (!handler + || !res.supports_type_p (op->type) + || !handler.fold_range (res, op->type, vr, + value_range (op->type))) + res.set_varying (op->type); + } else if (!op->val[1]) { value_range op0 (op->val[0], op->val[0]); - range_fold_binary_expr (&res, op->code, op->type, - op->index ? &op0 : &vr, - op->index ? &vr : &op0); + range_op_handler handler (op->code, op->type); + + if (!handler + || !res.supports_type_p (op->type) + || !handler.fold_range (res, op->type, + op->index ? op0 : vr, + op->index ? vr : op0)) + res.set_varying (op->type); } else res.set_varying (op->type); - type = op->type; vr = res; } if (!vr.varying_p () && !vr.undefined_p ()) { value_range res; - value_range val_vr (c->val, c->val); - range_fold_binary_expr (&res, c->code, boolean_type_node, - &vr, - &val_vr); + value_range val_vr; + if (TREE_CODE (c->val) == INTEGER_CST) + val_vr.set (c->val, c->val); + else + val_vr.set_varying (TREE_TYPE (c->val)); + range_op_handler handler (c->code, boolean_type_node); + + if (!handler + || !res.supports_type_p (boolean_type_node) + || !handler.fold_range (res, boolean_type_node, vr, val_vr)) + res.set_varying (boolean_type_node); + if (res.zero_p ()) continue; } diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index a55cc72b0fd..f706f099f7a 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -2323,9 +2323,8 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, && get_range_query (cfun)->range_of_expr (vr, arg) && !vr.undefined_p ()) { - value_range resvr; - range_fold_unary_expr (&resvr, NOP_EXPR, param_type, - &vr, TREE_TYPE (arg)); + value_range resvr = vr; + range_cast (resvr, param_type); if (!resvr.undefined_p () && !resvr.varying_p ()) ipa_set_jfunc_vr (jfunc, &resvr); else diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc index 41e12daf7f8..ea4fbd7af67 100644 --- a/gcc/vr-values.cc +++ b/gcc/vr-values.cc @@ -579,8 +579,10 @@ bounds_of_var_in_loop (tree *min, tree *max, range_query *query, vr0.set_varying (TREE_TYPE (init)); tree tem = wide_int_to_tree (TREE_TYPE (init), wtmp); vr1.set (tem, tem); - range_fold_binary_expr (&maxvr, PLUS_EXPR, - TREE_TYPE (init), &vr0, &vr1); + + range_op_handler handler (PLUS_EXPR, TREE_TYPE (init)); + if (!handler.fold_range (maxvr, TREE_TYPE (init), vr0, vr1)) + maxvr.set_varying (TREE_TYPE (init)); /* Likewise if the addition did. */ if (maxvr.kind () == VR_RANGE)