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: 1773938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=x043r5eL; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q5scH0RCsz23vH for ; Wed, 26 Apr 2023 18:34:39 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 02A033858412 for ; Wed, 26 Apr 2023 08:34:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02A033858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682498077; 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=x043r5eLp9I/6DiCpq6kdq40S342W/j6A1yu4bUjoc3hMVnc9ziZBzt5hufHuwEcD motPpXk4L2TKZB/yeGoubr8RXmd2WjvoR3DD3VIfKLUQeOBufVqVhR2271band4jvz V9ydxIF6RTZA09NJ0b9GNYevWgesUhWzdKYP9ieY= 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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)