From patchwork Sun Nov 7 18:10:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 47193 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 3E9BE3858429 for ; Sun, 7 Nov 2021 18:11:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E9BE3858429 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636308676; bh=UvegJKgTVA5XeSikJ4Fcs4rypJLVm1gb3RPOKGo5314=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=TTJtxOfcIqV1S2Xm7W2M+907j40MbntHShMclNnl48m3dDwNLN/TCuH3gLMKVE9fY BPuHsgqudg9+x2+P6Q3Fm3cBBis9PIrCS3fommhIKNKrQGD//2FXGwukxxq1BDCfaK eTqKEO/uXHJVxxxBjBF6EJ4swkltXDJmm9kCxgCg= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id E41013858401 for ; Sun, 7 Nov 2021 18:10:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E41013858401 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-595-azj-ix2mOWWPVCruIarhbw-1; Sun, 07 Nov 2021 13:10:41 -0500 X-MC-Unique: azj-ix2mOWWPVCruIarhbw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F38F71030C20; Sun, 7 Nov 2021 18:10:39 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8490819730; Sun, 7 Nov 2021 18:10:39 +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 1A7IAaDM172542 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 7 Nov 2021 19:10:36 +0100 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 1A7IAalt172541; Sun, 7 Nov 2021 19:10:36 +0100 To: GCC patches Subject: [COMMITTED] Remove VRP threader. Date: Sun, 7 Nov 2021 19:10:33 +0100 Message-Id: <20211107181033.172452-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.3 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, RCVD_IN_MSPIKE_H2, 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" Now that things have stabilized, we can remove the old code. I have left the hybrid threader in tree-ssa-threadedge, even though the VRP threader was the only user, because we may need it as an interim step for DOM threading removal. Tested on x86-64 Linux. p.s. I tried testing on ppc64le Linux, but it was broken at the time of testing with: /tmp/ccSw6Ajh.s: Assembler messages: /tmp/ccSw6Ajh.s:399: Error: unrecognized opcode: `mtvsrws' make[3]: *** [printf/quadmath-printf.lo] Error 1 gcc/ChangeLog: * tree-pass.h (make_pass_vrp_threader): Remove. * tree-ssa-threadbackward.c (back_threader_profitability::profitable_path_p): Remove ASSERT_EXPR references. * tree-ssa-threadedge.c (jt_state::register_equivs_stmt): Same. * tree-vrp.c (vrp_folder::simplify_casted_conds): Same. (execute_vrp): Same. (class hybrid_threader): Remove. (hybrid_threader::hybrid_threader): Remove. (hybrid_threader::~hybrid_threader): Remove. (hybrid_threader::before_dom_children): Remove. (hybrid_threader::after_dom_children): Remove. (execute_vrp_threader): Remove. (class pass_vrp_threader): Remove. (make_pass_vrp_threader): Remove. --- gcc/tree-pass.h | 1 - gcc/tree-ssa-threadbackward.c | 2 - gcc/tree-ssa-threadedge.c | 12 +-- gcc/tree-vrp.c | 137 +--------------------------------- 4 files changed, 5 insertions(+), 147 deletions(-) diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index e807ad855ef..d494aff1c4c 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -463,7 +463,6 @@ extern gimple_opt_pass *make_pass_copy_prop (gcc::context *ctxt); extern gimple_opt_pass *make_pass_isolate_erroneous_paths (gcc::context *ctxt); extern gimple_opt_pass *make_pass_early_vrp (gcc::context *ctxt); extern gimple_opt_pass *make_pass_vrp (gcc::context *ctxt); -extern gimple_opt_pass *make_pass_vrp_threader (gcc::context *ctxt); extern gimple_opt_pass *make_pass_uncprop (gcc::context *ctxt); extern gimple_opt_pass *make_pass_return_slot (gcc::context *ctxt); extern gimple_opt_pass *make_pass_reassoc (gcc::context *ctxt); diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index 0085ad01cdc..f9485bf9046 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -710,8 +710,6 @@ back_threader_profitability::profitable_path_p (const vec &m_path, return false; /* Do not count empty statements and labels. */ if (gimple_code (stmt) != GIMPLE_NOP - && !(gimple_code (stmt) == GIMPLE_ASSIGN - && gimple_assign_rhs_code (stmt) == ASSERT_EXPR) && !is_gimple_debug (stmt)) n_insns += estimate_num_insns (stmt, &eni_size_weights); } diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index a63a9764ff8..f693db17064 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -1334,25 +1334,19 @@ jt_state::register_equivs_stmt (gimple *stmt, basic_block bb, to expose more context sensitive equivalences which in turn may allow us to simplify the condition at the end of the loop. - Handle simple copy operations as well as implied copies from - ASSERT_EXPRs. */ + Handle simple copy operations. */ tree cached_lhs = NULL; if (gimple_assign_single_p (stmt) && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME) cached_lhs = gimple_assign_rhs1 (stmt); - else if (gimple_assign_single_p (stmt) - && TREE_CODE (gimple_assign_rhs1 (stmt)) == ASSERT_EXPR) - cached_lhs = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0); else { - /* A statement that is not a trivial copy or ASSERT_EXPR. + /* A statement that is not a trivial copy. Try to fold the new expression. Inserting the expression into the hash table is unlikely to help. */ /* ??? The DOM callback below can be changed to setting the mprts_hook around the call to thread_across_edge, - avoiding the use substitution. The VRP hook should be - changed to properly valueize operands itself using - SSA_NAME_VALUE in addition to its own lattice. */ + avoiding the use substitution. */ cached_lhs = gimple_fold_stmt_to_constant_1 (stmt, threadedge_valueize); if (NUM_SSA_OPERANDS (stmt, SSA_OP_ALL_USES) != 0 diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 5380508a9ec..dd7723629ba 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -43,7 +43,6 @@ along with GCC; see the file COPYING3. If not see #include "cfgloop.h" #include "tree-scalar-evolution.h" #include "tree-ssa-propagate.h" -#include "tree-ssa-threadedge.h" #include "domwalk.h" #include "vr-values.h" #include "gimple-array-bounds.h" @@ -3684,9 +3683,7 @@ vrp_asserts::all_imm_uses_in_stmt_or_feed_cond (tree var, However, by converting the assertion into the implied copy operation N_i = N_j, we will then copy-propagate N_j into the uses - of N_i and lose the range information. We may want to hold on to - ASSERT_EXPRs a little while longer as the ranges could be used in - things like jump threading. + of N_i and lose the range information. The problem with keeping ASSERT_EXPRs around is that passes after VRP need to handle them appropriately. @@ -4121,11 +4118,7 @@ vrp_folder::fold_stmt (gimple_stmt_iterator *si) /* A comparison of an SSA_NAME against a constant where the SSA_NAME was set by a type conversion can often be rewritten to use the RHS of the type conversion. Do this optimization for all conditionals - in FUN. - - However, doing so inhibits jump threading through the comparison. - So that transformation is not performed until after jump threading - is complete. */ + in FUN. */ void vrp_folder::simplify_casted_conds (function *fun) @@ -4244,9 +4237,6 @@ execute_vrp (struct function *fun, bool warn_array_bounds_p) free_numbers_of_iterations_estimates (fun); - /* ASSERT_EXPRs must be removed before finalizing jump threads - as finalizing jump threads calls the CFG cleanup code which - does not properly handle ASSERT_EXPRs. */ assert_engine.remove_range_assertions (); scev_finalize (); @@ -4429,126 +4419,3 @@ make_pass_vrp (gcc::context *ctxt) { return new pass_vrp (ctxt); } - -// This is the dom walker for the hybrid threader. The reason this is -// here, as opposed to the generic threading files, is because the -// other client would be DOM, and they have their own custom walker. - -class hybrid_threader : public dom_walker -{ -public: - hybrid_threader (); - ~hybrid_threader (); - - void thread_jumps (function *fun) - { - walk (fun->cfg->x_entry_block_ptr); - } - bool thread_through_all_blocks () - { - return m_threader->thread_through_all_blocks (false); - } - -private: - edge before_dom_children (basic_block) override; - void after_dom_children (basic_block bb) override; - - hybrid_jt_simplifier *m_simplifier; - jump_threader *m_threader; - jt_state *m_state; - gimple_ranger *m_ranger; - path_range_query *m_query; -}; - -hybrid_threader::hybrid_threader () : dom_walker (CDI_DOMINATORS, REACHABLE_BLOCKS) -{ - loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS); - scev_initialize (); - calculate_dominance_info (CDI_DOMINATORS); - mark_dfs_back_edges (); - - m_ranger = new gimple_ranger; - m_query = new path_range_query (*m_ranger, /*resolve=*/true); - m_simplifier = new hybrid_jt_simplifier (m_ranger, m_query); - m_state = new hybrid_jt_state; - m_threader = new jump_threader (m_simplifier, m_state); -} - -hybrid_threader::~hybrid_threader () -{ - delete m_simplifier; - delete m_threader; - delete m_state; - delete m_ranger; - delete m_query; - - scev_finalize (); - loop_optimizer_finalize (); -} - -edge -hybrid_threader::before_dom_children (basic_block bb) -{ - gimple_stmt_iterator gsi; - int_range<2> r; - - for (gsi = gsi_start_nondebug_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - { - gimple *stmt = gsi_stmt (gsi); - m_ranger->range_of_stmt (r, stmt); - } - return NULL; -} - -void -hybrid_threader::after_dom_children (basic_block bb) -{ - m_threader->thread_outgoing_edges (bb); -} - -static unsigned int -execute_vrp_threader (function *fun) -{ - hybrid_threader threader; - threader.thread_jumps (fun); - if (threader.thread_through_all_blocks ()) - return (TODO_cleanup_cfg | TODO_update_ssa); - return 0; -} - -namespace { - -const pass_data pass_data_vrp_threader = -{ - GIMPLE_PASS, /* type */ - "vrp-thread", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - TV_TREE_VRP_THREADER, /* tv_id */ - PROP_ssa, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ -}; - -class pass_vrp_threader : public gimple_opt_pass -{ -public: - pass_vrp_threader (gcc::context *ctxt) - : gimple_opt_pass (pass_data_vrp_threader, ctxt) - {} - - /* opt_pass methods: */ - opt_pass * clone () { return new pass_vrp_threader (m_ctxt); } - virtual bool gate (function *) { return flag_tree_vrp != 0; } - virtual unsigned int execute (function *fun) - { return execute_vrp_threader (fun); } -}; - -} // namespace { - -gimple_opt_pass * -make_pass_vrp_threader (gcc::context *ctxt) -{ - return new pass_vrp_threader (ctxt); -}