From patchwork Mon Sep 27 09:46:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 45461 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3E0E1385843A for ; Mon, 27 Sep 2021 09:47:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E0E1385843A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1632736061; bh=6szQZO839OVJlwkbVYoVikkQOIjlPILSuyORc85gJr4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=g3WtF73ZqflknkjFTF6ITPLg13WOo6XknODBmqYRre3roUTEhHn4XIBndjAHK0M/Z oaQnUX3hgN/8dV42sxnOIaFKEsOVbxjgjS0eCwujD//XmDwb5VxQARiFcdDmOEidFM LS/MS6luUTmy/ydzgDYzQVm6wxSlTDZRnp+Qa9yI= 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.129.124]) by sourceware.org (Postfix) with ESMTP id 041913858C3A for ; Mon, 27 Sep 2021 09:47:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 041913858C3A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-21-iTEdDHItOB2mkB_SWCXAAg-1; Mon, 27 Sep 2021 05:47:06 -0400 X-MC-Unique: iTEdDHItOB2mkB_SWCXAAg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22FDE802947; Mon, 27 Sep 2021 09:47:05 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.193.174]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8084060938; Mon, 27 Sep 2021 09:47:03 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.16.1/8.15.2) with ESMTPS id 18R9l0ah743629 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 27 Sep 2021 11:47:01 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 18R9l00e743627; Mon, 27 Sep 2021 11:47:00 +0200 To: GCC patches Subject: [COMMITTED] Convert some evrp uses in DOM to the range_query API. Date: Mon, 27 Sep 2021 11:46:49 +0200 Message-Id: <20210927094649.743544-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.1 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_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" DOM is the last remaining user of the evrp engine. This patch converts a few uses of the engine and vr-values into the new API. There is one subtle change. The call to vr_value's op_with_constant_singleton_value_range can theoretically return non-constants, unlike the range_query API which only returns constants. In this particular case it doesn't matter because the symbolic stuff will have been handled by the const_and_copies/avail_exprs read in the SSA_NAME_VALUE copy immediately before. I have verified this is the case by asserting that all calls to op_with_constant_singleton_value_range at this point return either NULL or an INTEGER_CST. Tested on x86-64 Linux with a regstrap, as well as the aforementioned assert. Committed to trunk. gcc/ChangeLog: * gimple-ssa-evrp-analyze.h (class evrp_range_analyzer): Remove vrp_visit_cond_stmt. * tree-ssa-dom.c (cprop_operand): Convert to range_query API. (cprop_into_stmt): Same. (dom_opt_dom_walker::optimize_stmt): Same. --- gcc/gimple-ssa-evrp-analyze.h | 7 ------- gcc/tree-ssa-dom.c | 17 +++++++++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/gcc/gimple-ssa-evrp-analyze.h b/gcc/gimple-ssa-evrp-analyze.h index 0a70a1e58bd..4cf82e69c3a 100644 --- a/gcc/gimple-ssa-evrp-analyze.h +++ b/gcc/gimple-ssa-evrp-analyze.h @@ -38,13 +38,6 @@ class evrp_range_analyzer : public vr_values /* Record a new unwindable range. */ void push_value_range (tree var, value_range_equiv *vr); - /* A bit of a wart. This should ideally go away. */ - void vrp_visit_cond_stmt (gcond *cond, edge *e) - { - simplify_using_ranges simpl (this); - simpl.vrp_visit_cond_stmt (cond, e); - } - private: DISABLE_COPY_AND_ASSIGN (evrp_range_analyzer); diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index f58b6b78a41..a8a5b34f725 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -1810,7 +1810,7 @@ record_equivalences_from_stmt (gimple *stmt, int may_optimize_p, CONST_AND_COPIES. */ static void -cprop_operand (gimple *stmt, use_operand_p op_p, vr_values *vr_values) +cprop_operand (gimple *stmt, use_operand_p op_p, range_query *query) { tree val; tree op = USE_FROM_PTR (op_p); @@ -1820,7 +1820,12 @@ cprop_operand (gimple *stmt, use_operand_p op_p, vr_values *vr_values) CONST_AND_COPIES. */ val = SSA_NAME_VALUE (op); if (!val) - val = vr_values->op_with_constant_singleton_value_range (op); + { + value_range r; + tree single; + if (query->range_of_expr (r, op, stmt) && r.singleton_p (&single)) + val = single; + } if (val && val != op) { @@ -1878,7 +1883,7 @@ cprop_operand (gimple *stmt, use_operand_p op_p, vr_values *vr_values) vdef_ops of STMT. */ static void -cprop_into_stmt (gimple *stmt, vr_values *vr_values) +cprop_into_stmt (gimple *stmt, range_query *query) { use_operand_p op_p; ssa_op_iter iter; @@ -1895,7 +1900,7 @@ cprop_into_stmt (gimple *stmt, vr_values *vr_values) operands. */ if (old_op != last_copy_propagated_op) { - cprop_operand (stmt, op_p, vr_values); + cprop_operand (stmt, op_p, query); tree new_op = USE_FROM_PTR (op_p); if (new_op != old_op && TREE_CODE (new_op) == SSA_NAME) @@ -2203,8 +2208,8 @@ dom_opt_dom_walker::optimize_stmt (basic_block bb, gimple_stmt_iterator *si, SSA_NAMES. */ update_stmt_if_modified (stmt); edge taken_edge = NULL; - m_evrp_range_analyzer->vrp_visit_cond_stmt - (as_a (stmt), &taken_edge); + simplify_using_ranges simpl (m_evrp_range_analyzer); + simpl.vrp_visit_cond_stmt (as_a (stmt), &taken_edge); if (taken_edge) { if (taken_edge->flags & EDGE_TRUE_VALUE)