2004-05-13 08:41:07 +02:00
|
|
|
/* Dead store elimination
|
|
|
|
Copyright (C) 2004 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
This file is part of GCC.
|
|
|
|
|
|
|
|
GCC is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
GCC is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GCC; see the file COPYING. If not, write to
|
|
|
|
the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "coretypes.h"
|
|
|
|
#include "tm.h"
|
|
|
|
#include "errors.h"
|
|
|
|
#include "ggc.h"
|
|
|
|
#include "tree.h"
|
|
|
|
#include "rtl.h"
|
|
|
|
#include "tm_p.h"
|
|
|
|
#include "basic-block.h"
|
|
|
|
#include "timevar.h"
|
|
|
|
#include "diagnostic.h"
|
|
|
|
#include "tree-flow.h"
|
|
|
|
#include "tree-pass.h"
|
|
|
|
#include "tree-dump.h"
|
|
|
|
#include "domwalk.h"
|
|
|
|
#include "flags.h"
|
|
|
|
|
|
|
|
/* This file implements dead store elimination.
|
|
|
|
|
|
|
|
A dead store is a store into a memory location which will later be
|
|
|
|
overwritten by another store without any intervening loads. In this
|
|
|
|
case the earlier store can be deleted.
|
|
|
|
|
|
|
|
In our SSA + virtual operand world we use immediate uses of virtual
|
|
|
|
operands to detect dead stores. If a store's virtual definition
|
|
|
|
is used precisely once by a later store to the same location which
|
|
|
|
post dominates the first store, then the first store is dead.
|
|
|
|
|
|
|
|
The single use of the store's virtual definition ensures that
|
|
|
|
there are no intervening aliased loads and the requirement that
|
|
|
|
the second load post dominate the first ensures that if the earlier
|
|
|
|
store executes, then the later stores will execute before the function
|
|
|
|
exits.
|
|
|
|
|
|
|
|
It may help to think of this as first moving the earlier store to
|
|
|
|
the point immediately before the later store. Again, the single
|
c-typeck.c, [...]: Fix comment typos.
* c-typeck.c, cfgexpand.c, ddg.c, ddg.h, df.c, fold-const.c,
gcov.c, gimplify.c, modulo-sched.c, passes.c, tree-cfg.c,
tree-mudflap.c, tree-nrv.c, tree-outof-ssa.c, tree-ssa-dom.c,
tree-ssa-dse.c, tree-ssa-operands.c, tree-ssa-pre.c,
tree-tailcall.c: Fix comment typos. Follow spelling
conventions.
From-SVN: r83703
2004-06-26 07:03:55 +02:00
|
|
|
use of the virtual definition and the post-dominance relationship
|
2004-05-13 08:41:07 +02:00
|
|
|
ensure that such movement would be safe. Clearly if there are
|
|
|
|
back to back stores, then the second is redundant.
|
|
|
|
|
|
|
|
Reviewing section 10.7.2 in Morgan's "Building an Optimizing Compiler"
|
|
|
|
may also help in understanding this code since it discusses the
|
|
|
|
relationship between dead store and redundant load elimination. In
|
|
|
|
fact, they are the same transformation applied to different views of
|
|
|
|
the CFG. */
|
|
|
|
|
|
|
|
|
|
|
|
struct dse_global_data
|
|
|
|
{
|
|
|
|
/* This is the global bitmap for store statements.
|
|
|
|
|
|
|
|
Each statement has a unique ID. When we encounter a store statement
|
|
|
|
that we want to record, set the bit corresponding to the statement's
|
|
|
|
unique ID in this bitmap. */
|
|
|
|
bitmap stores;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* We allocate a bitmap-per-block for stores which are encountered
|
|
|
|
during the scan of that block. This allows us to restore the
|
|
|
|
global bitmap of stores when we finish processing a block. */
|
|
|
|
struct dse_block_local_data
|
|
|
|
{
|
|
|
|
bitmap stores;
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool gate_dse (void);
|
|
|
|
static void tree_ssa_dse (void);
|
|
|
|
static void dse_initialize_block_local_data (struct dom_walk_data *,
|
|
|
|
basic_block,
|
|
|
|
bool);
|
|
|
|
static void dse_optimize_stmt (struct dom_walk_data *,
|
|
|
|
basic_block,
|
|
|
|
block_stmt_iterator);
|
|
|
|
static void dse_record_phis (struct dom_walk_data *, basic_block);
|
|
|
|
static void dse_finalize_block (struct dom_walk_data *, basic_block);
|
|
|
|
static void fix_phi_uses (tree, tree);
|
2004-06-10 23:41:08 +02:00
|
|
|
static void fix_stmt_v_may_defs (tree, tree);
|
2004-05-13 08:41:07 +02:00
|
|
|
static void record_voperand_set (bitmap, bitmap *, unsigned int);
|
|
|
|
|
2004-09-11 22:42:06 +02:00
|
|
|
static unsigned max_stmt_uid; /* Maximal uid of a statement. Uids to phi
|
|
|
|
nodes are assigned using the versions of
|
|
|
|
ssa names they define. */
|
|
|
|
|
|
|
|
/* Returns uid of statement STMT. */
|
|
|
|
|
|
|
|
static unsigned
|
|
|
|
get_stmt_uid (tree stmt)
|
|
|
|
{
|
|
|
|
if (TREE_CODE (stmt) == PHI_NODE)
|
|
|
|
return SSA_NAME_VERSION (PHI_RESULT (stmt)) + max_stmt_uid;
|
|
|
|
|
|
|
|
return stmt_ann (stmt)->uid;
|
|
|
|
}
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
/* Function indicating whether we ought to include information for 'var'
|
|
|
|
when calculating immediate uses. For this pass we only want use
|
|
|
|
information for virtual variables. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
need_imm_uses_for (tree var)
|
|
|
|
{
|
|
|
|
return !is_gimple_reg (var);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-10 23:41:08 +02:00
|
|
|
/* Replace uses in PHI which match V_MAY_DEF_RESULTs in STMT with the
|
|
|
|
corresponding V_MAY_DEF_OP in STMT. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
fix_phi_uses (tree phi, tree stmt)
|
|
|
|
{
|
|
|
|
stmt_ann_t ann = stmt_ann (stmt);
|
2004-06-10 23:41:08 +02:00
|
|
|
v_may_def_optype v_may_defs;
|
2004-05-13 08:41:07 +02:00
|
|
|
unsigned int i;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
get_stmt_operands (stmt);
|
2004-06-10 23:41:08 +02:00
|
|
|
v_may_defs = V_MAY_DEF_OPS (ann);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2004-06-10 23:41:08 +02:00
|
|
|
/* Walk each V_MAY_DEF in STMT. */
|
|
|
|
for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
2004-06-10 23:41:08 +02:00
|
|
|
tree v_may_def = V_MAY_DEF_RESULT (v_may_defs, i);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2004-06-10 23:41:08 +02:00
|
|
|
/* Find any uses in the PHI which match V_MAY_DEF and replace
|
|
|
|
them with the appropriate V_MAY_DEF_OP. */
|
2004-05-13 08:41:07 +02:00
|
|
|
for (j = 0; j < PHI_NUM_ARGS (phi); j++)
|
2004-06-10 23:41:08 +02:00
|
|
|
if (v_may_def == PHI_ARG_DEF (phi, j))
|
tree-cfg.c (tree_make_forwarder_block): Use SET_PHI_RESULT.
2004-06-16 Andrew MacLeod <amacleod@redhat.com>
* tree-cfg.c (tree_make_forwarder_block): Use SET_PHI_RESULT.
* tree-flow-inline.h (get_use_op_ptr): Return a use_operand_p.
(get_use_from_ptr, get_def_from_ptr): New. Return operand pointers.
(get_def_op_ptr): Return a def_operand_p instead of a 'tree *'.
(get_v_may_def_result_ptr): Return a def_operand_p.
(get_v_may_def_op_ptr, get_vuse_op_ptr): Return a use_operand_p.
(get_v_must_def_op_ptr): Return a def_operand_p.
(get_phi_result_ptr): New. Return a pointer to the result of a PHI.
(get_phi_arg_def_ptr): New. Return a pointer to an argument of a PHI.
(phi_element_for_edge): Remove.
* tree-flow.h (propagate_value, replace_exp): Change prototype.
(propagate_tree_value): Add new prototype.
(phi_element_for_edge): Remove prototype.
* tree-into-ssa.c (mark_def_sites): Use new operand types.
(prepare_operand_for_rename): Split into two functions.
(prepare_use_operand_for_rename): Prepare use operands.
(prepare_def_operand_for_rename): Prepare def operands.
(rewrite_stmt): Use new operand types.
(rewrite_operand): Use new operand types, change parameter type.
* tree-outof-ssa.c (replace_variable): Split into two functions.
(replace_use_variable): Rewrite uses.
(replace_def_variable): Rewrite defs.
(rewrite_trees, rewrite_vars_out_of_ssa): Use new operand types.
* tree-phinodes.c (make_phi_node, resize_phi_node): Use new types.
(add_phi_arg, remove_phi_arg_num): Use new operand types.
* tree-ssa-ccp.c (substitute_and_fold): Use new operand types.
(ccp_fold, replace_uses_in): Use new operand types.
* tree-ssa-copy.c (replace_ssa_names): Rename to replace_ssa_names_ann
and no longer set the value, change parameter type.
(replace_exp_1): Use new operand types.
(propagate_value): Change parameter type, use new operand types.
(propagate_tree_value): Propagate_value without SSA operands.
(replace_exp, cprop_operand, cprop_into_stmt): Use new operand types.
(cprop_into_successor_phis): Use new operand types.
* tree-ssa-dom.c (thread_across_edge): Use new operand types.
(eliminate_redundant_computations): Use new operand types.
* tree-ssa-dse.c (fix_phi_uses): Use new operand_types.
(fix_stmt_v_may_defs): Use new operand_types.
* tree-ssa-live.c (create_ssa_var_map): Use new operand_types.
(build_tree_conflict_graph): Use new operand_types.
* tree-ssa-loop.c (duplicate_blocks): Use PHI_ARG_DEF_FROM_EDGE.
* tree-ssa-operands.c (struct freelist_d): Remove.
(check_optype_freelist, add_optype_freelist): Remove.
(allocate_def_optype, allocate_use_optype, allocate_v_may_def_optype,
allocate_vuse_optype, allocate_v_must_def_optype): Call ggc_alloc.
(free_uses, free_defs, free_vuses, free_v_may_defs, free_v_must_defs):
Call ggc_free instead of add_optype_freelist.
(init_ssa_operands, fini_ssa_operands): Remove free list code.
(finalize_ssa_defs, finalize_ssa_uses): Set new use/def operands.
* tree-ssa-operands.h (struct def_optype_d): Change underlying type.
(struct use_optype_d): Change underlying type.
(def_operand_p, use_operand_p): New types for pointers to operands.
(USE_OP, DEF_OP, V_MAY_DEF_RESULT, V_MAY_DEF_OP, VUSE_OP,
V_MUST_DEF_OP): Use new pointer type instead of dereferencing directly.
(USE_FROM_PTR, DEF_FROM_PTR): New macros to "dereference" operand
pointer types.
(SET_USE, SET_DEF): New macros to set operands from their pointer.
(SET_USE_OP, SET_DEF_OP, SET_V_MAY_DEF_RESULT, SET_V_MAY_DEF_OP,
SET_VUSE_OP, SET_V_MUST_DEF_OP): New SET routines for operands.
(PHI_RESULT_PTR, PHI_RESULT, SET_PHI_RESULT): Macros to manage the
PHI result as an operand.
(PHI_ARG_DEF_PTR, PHI_ARG_DEF, SET_PHI_ARG_DEF, PHI_ARG_DEF_FROM_EDGE,
PHI_ARG_DEF_PTR_FROM_EDGE): Macros to manage the PHI arguments.
* tree-ssa-pre.c (eliminate): Call propagate_tree_value.
* tree-tailcall.c (independent_of_stmt_p, propagate_through_phis): Use
PHI_ARG_DEF_FROM_EDGE.
* tree.h (PHI_RESULT): Renamed to PHI_RESULT_TREE.
(PHI_ARG_DEF): Renamed to PHI_ARG_DEF_TREE.
From-SVN: r83298
2004-06-17 20:13:20 +02:00
|
|
|
SET_PHI_ARG_DEF (phi, j, V_MAY_DEF_OP (v_may_defs, i));
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-10 23:41:08 +02:00
|
|
|
/* Replace the V_MAY_DEF_OPs in STMT1 which match V_MAY_DEF_RESULTs
|
|
|
|
in STMT2 with the appropriate V_MAY_DEF_OPs from STMT2. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
2004-06-10 23:41:08 +02:00
|
|
|
fix_stmt_v_may_defs (tree stmt1, tree stmt2)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
stmt_ann_t ann1 = stmt_ann (stmt1);
|
|
|
|
stmt_ann_t ann2 = stmt_ann (stmt2);
|
2004-06-10 23:41:08 +02:00
|
|
|
v_may_def_optype v_may_defs1;
|
|
|
|
v_may_def_optype v_may_defs2;
|
2004-05-13 08:41:07 +02:00
|
|
|
unsigned int i, j;
|
|
|
|
|
|
|
|
get_stmt_operands (stmt1);
|
|
|
|
get_stmt_operands (stmt2);
|
2004-06-10 23:41:08 +02:00
|
|
|
v_may_defs1 = V_MAY_DEF_OPS (ann1);
|
|
|
|
v_may_defs2 = V_MAY_DEF_OPS (ann2);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2004-06-10 23:41:08 +02:00
|
|
|
/* Walk each V_MAY_DEF_OP in stmt1. */
|
|
|
|
for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs1); i++)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
2004-06-10 23:41:08 +02:00
|
|
|
tree v_may_def1 = V_MAY_DEF_OP (v_may_defs1, i);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2004-06-10 23:41:08 +02:00
|
|
|
/* Find the appropriate V_MAY_DEF_RESULT in STMT2. */
|
|
|
|
for (j = 0; j < NUM_V_MAY_DEFS (v_may_defs2); j++)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
2004-06-10 23:41:08 +02:00
|
|
|
if (v_may_def1 == V_MAY_DEF_RESULT (v_may_defs2, j))
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
/* Update. */
|
tree-cfg.c (tree_make_forwarder_block): Use SET_PHI_RESULT.
2004-06-16 Andrew MacLeod <amacleod@redhat.com>
* tree-cfg.c (tree_make_forwarder_block): Use SET_PHI_RESULT.
* tree-flow-inline.h (get_use_op_ptr): Return a use_operand_p.
(get_use_from_ptr, get_def_from_ptr): New. Return operand pointers.
(get_def_op_ptr): Return a def_operand_p instead of a 'tree *'.
(get_v_may_def_result_ptr): Return a def_operand_p.
(get_v_may_def_op_ptr, get_vuse_op_ptr): Return a use_operand_p.
(get_v_must_def_op_ptr): Return a def_operand_p.
(get_phi_result_ptr): New. Return a pointer to the result of a PHI.
(get_phi_arg_def_ptr): New. Return a pointer to an argument of a PHI.
(phi_element_for_edge): Remove.
* tree-flow.h (propagate_value, replace_exp): Change prototype.
(propagate_tree_value): Add new prototype.
(phi_element_for_edge): Remove prototype.
* tree-into-ssa.c (mark_def_sites): Use new operand types.
(prepare_operand_for_rename): Split into two functions.
(prepare_use_operand_for_rename): Prepare use operands.
(prepare_def_operand_for_rename): Prepare def operands.
(rewrite_stmt): Use new operand types.
(rewrite_operand): Use new operand types, change parameter type.
* tree-outof-ssa.c (replace_variable): Split into two functions.
(replace_use_variable): Rewrite uses.
(replace_def_variable): Rewrite defs.
(rewrite_trees, rewrite_vars_out_of_ssa): Use new operand types.
* tree-phinodes.c (make_phi_node, resize_phi_node): Use new types.
(add_phi_arg, remove_phi_arg_num): Use new operand types.
* tree-ssa-ccp.c (substitute_and_fold): Use new operand types.
(ccp_fold, replace_uses_in): Use new operand types.
* tree-ssa-copy.c (replace_ssa_names): Rename to replace_ssa_names_ann
and no longer set the value, change parameter type.
(replace_exp_1): Use new operand types.
(propagate_value): Change parameter type, use new operand types.
(propagate_tree_value): Propagate_value without SSA operands.
(replace_exp, cprop_operand, cprop_into_stmt): Use new operand types.
(cprop_into_successor_phis): Use new operand types.
* tree-ssa-dom.c (thread_across_edge): Use new operand types.
(eliminate_redundant_computations): Use new operand types.
* tree-ssa-dse.c (fix_phi_uses): Use new operand_types.
(fix_stmt_v_may_defs): Use new operand_types.
* tree-ssa-live.c (create_ssa_var_map): Use new operand_types.
(build_tree_conflict_graph): Use new operand_types.
* tree-ssa-loop.c (duplicate_blocks): Use PHI_ARG_DEF_FROM_EDGE.
* tree-ssa-operands.c (struct freelist_d): Remove.
(check_optype_freelist, add_optype_freelist): Remove.
(allocate_def_optype, allocate_use_optype, allocate_v_may_def_optype,
allocate_vuse_optype, allocate_v_must_def_optype): Call ggc_alloc.
(free_uses, free_defs, free_vuses, free_v_may_defs, free_v_must_defs):
Call ggc_free instead of add_optype_freelist.
(init_ssa_operands, fini_ssa_operands): Remove free list code.
(finalize_ssa_defs, finalize_ssa_uses): Set new use/def operands.
* tree-ssa-operands.h (struct def_optype_d): Change underlying type.
(struct use_optype_d): Change underlying type.
(def_operand_p, use_operand_p): New types for pointers to operands.
(USE_OP, DEF_OP, V_MAY_DEF_RESULT, V_MAY_DEF_OP, VUSE_OP,
V_MUST_DEF_OP): Use new pointer type instead of dereferencing directly.
(USE_FROM_PTR, DEF_FROM_PTR): New macros to "dereference" operand
pointer types.
(SET_USE, SET_DEF): New macros to set operands from their pointer.
(SET_USE_OP, SET_DEF_OP, SET_V_MAY_DEF_RESULT, SET_V_MAY_DEF_OP,
SET_VUSE_OP, SET_V_MUST_DEF_OP): New SET routines for operands.
(PHI_RESULT_PTR, PHI_RESULT, SET_PHI_RESULT): Macros to manage the
PHI result as an operand.
(PHI_ARG_DEF_PTR, PHI_ARG_DEF, SET_PHI_ARG_DEF, PHI_ARG_DEF_FROM_EDGE,
PHI_ARG_DEF_PTR_FROM_EDGE): Macros to manage the PHI arguments.
* tree-ssa-pre.c (eliminate): Call propagate_tree_value.
* tree-tailcall.c (independent_of_stmt_p, propagate_through_phis): Use
PHI_ARG_DEF_FROM_EDGE.
* tree.h (PHI_RESULT): Renamed to PHI_RESULT_TREE.
(PHI_ARG_DEF): Renamed to PHI_ARG_DEF_TREE.
From-SVN: r83298
2004-06-17 20:13:20 +02:00
|
|
|
SET_V_MAY_DEF_OP (v_may_defs1, i, V_MAY_DEF_OP (v_may_defs2, j));
|
2004-05-13 08:41:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-10 23:41:08 +02:00
|
|
|
/* If we did not find a corresponding V_MAY_DEF_RESULT, then something
|
2004-05-13 08:41:07 +02:00
|
|
|
has gone terribly wrong. */
|
targhooks.c (default_unwind_emit, [...]): Use gcc_assert, gcc_unreachable & internal_error instead of abort.
* targhooks.c (default_unwind_emit, default_scalar_mode_supported_p):
Use gcc_assert, gcc_unreachable & internal_error instead of abort.
* timevar.c (timevar_push, timevar_pop, timevar_start,
timevar_stop): Likewise.
* toplev.c (default_pch_valid_p): Likewise.
* tracer.c (tail_duplicate): Likewise.
* tree-alias-common.c (get_alias_var_decl,
get_values_from_constructor, create_alias_var, delete_alias_vars,
empty_points_to_set, same_points_to_set, ptr_may_alias_var):
Likewise.
* tree.c (tree_size, make_node_stat, copy_node_stat,
build_int_cst_wide, integer_all_onesp, list_length, chainon,
tree_node_structure, type_contains_placeholder_p, substitute_in_expr,
substitute_placeholder_in_expr, tabilize_reference_1, build0_stat,
build1_stat, build2_stat, build3_stat, build4_stat, is_attribute_p,
lookup_attribute, type_hash_canon, host_integerp, iterative_hash_expr,
build_method_type_directly, decl_type_context, get_callee_fndecl,
get_set_constructor_bits, build_vector_type_for_mode, int_cst_value,
tree_fold_gcd): Likewise.
* tree-cfg.c (create_bb, make_ctrl_stmt_edges, make_exit_edges,
make_cond_expr_edges, group_case_labels, tree_merge_blocks,
cleanup_control_expr_graph, find_taken_edge,
find_taken_edge_switch_expr, phi_alternatives_equal,
is_ctrl_altering_stmt, disband_implicit_edges, set_bb_for_stmt,
stmt_for_bsi, tree_find_edge_insert_loc, bsi_insert_on_edge_immediate,
tree_split_edge, tree_verify_flow_info, thread_jumps,
tree_redirect_edge_and_branch, tree_flow_call_edges_add): Likewise.
* tree-chrec.c (chrec_fold_poly_cst, chrec_fold_plus_poly_poly,
chrec_fold_multiply_poly_poly): Likewise.
* tree-complex.c (extract_component, expand_complex_division,
expand_complex_comparison, expand_complex_operations_1,
build_replicated_const, expand_vector_operations_1): Likewise.
* tree-data-ref.c (tree_fold_bezout, build_classic_dist_vector,
build_classic_dir_vector): Likewise.
* tree-dfa.c (compute_immediate_uses_for_phi,
compute_immediate_uses_for_stmt, create_var_ann, create_stmt_ann,
create_tree_ann, collect_dfa_stats, get_virtual_var): Likewise.
* tree-dump.c (dequeue_and_dump): Likewise.
* tree-eh.c (record_stmt_eh_region, add_stmt_to_eh_region,
record_in_finally_tree, replace_goto_queue_1,
maybe_record_in_goto_queue, verify_norecord_switch_expr,
do_return_redirection): Likewise.
* tree-if-conv.c (tree_if_convert_stmt, tree_if_convert_cond_expr,
add_to_dst_predicate_list, find_phi_replacement_condition,
replace_phi_with_cond_modify_expr, get_loop_body_in_if_conv_order):
Likewise.
* tree-inline.c (remap_decl, remap_type, remap_decls, copy_body_r,
initialize_inlined_parameters, declare_return_variable,
estimate_num_insns_1, expand_call_inline, expand_calls_inline,
optimize_inline_calls, copy_tree_r): Likewise.
* tree-into-ssa.c (rewrite_initialize_block_local_data, rewrite_stmt,
ssa_rewrite_stmt, rewrite_into_ssa): Likewise.
* tree-iterator.c (alloc_stmt_list, tsi_link_before, tsi_link_after,
tsi_split_statement_list_after, tsi_split_statement_list_before):
Likewise.
* tree-mudflap.c (mf_varname_tree): Likewise.
* tree-nested.c (create_tmp_var_for, lookup_field_for_decl,
lookup_tramp_for_decl, convert_all_function_calls): Likewise.
* tree-optimize.c (tree_rest_of_compilation): Likewise.
* tree-outof-ssa.c (create_temp, eliminate_build, eliminate_phi,
coalesce_abnormal_edges, coalesce_ssa_name, eliminate_virtual_phis,
free_temp_expr_table, add_dependance, finish_expr, rewrite_trees):
Likewise.
* tree-phinodes.c (resize_phi_node, add_phi_arg,
remove_all_phi_nodes_for): Likewise.
* tree-pretty-print.c (op_prio, print_call_name): Likewise.
* tree-profile.c (tree_gen_interval_profiler, tree_gen_pow2_profiler,
tree_gen_one_value_profiler, tree_gen_const_delta_profiler): Likewise.
* tree-sra.c (type_can_instantiate_all_elements, sra_hash_tree,
sra_elt_eq, sra_walk_expr, instantiate_missing_elements,
generate_one_element_ref, generate_element_copy,
generate_element_zero, scalarize_copy, scalarize_init,
scalarize_ldst): Likewise.
* tree-ssa-alias.c (delete_alias_info, group_aliases, may_alias_p,
add_may_alias, add_pointed_to_expr, add_pointed_to_var,
collect_points_to_info_r, get_tmt_for, get_ptr_info): Likewise.
* tree-ssa.c (walk_use_def_chains, check_phi_redundancy): Likewise.
* tree-ssa-ccp.c (dump_lattice_value, get_default_value, get_value,
set_lattice_value, likely_value, ccp_visit_phi_node, visit_assignment,
widen_bitfield, ccp_fold_builtin): Likewise.
* tree-ssa-copy.c (may_propagate_copy, merge_alias_info,
replace_exp_1, propagate_tree_value): Likewise.
* tree-ssa-copyrename.c (copy_rename_partition_coalesce): Likewise.
* tree-ssa-dce.c (set_control_dependence_map_bit,
find_control_dependence, find_pdom, mark_operand_necessary,
mark_stmt_if_obviously_necessary,
mark_control_dependent_edges_necessary, remove_dead_stmt): Likewise.
* tree-ssa-dom.c (dom_opt_initialize_block_local_data,
simplify_switch_and_lookup_avail_expr, cprop_into_successor_phis,
eliminate_redundant_computations, avail_expr_eq): Likewise.
* tree-ssa-dse.c (fix_stmt_v_may_defs): Likewise.
* tree-ssa-loop-ch.c (should_duplicate_loop_header_p,
duplicate_blocks): Likewise.
* tree-ssa-loop-im.c (for_each_index, set_level,
is_call_clobbered_ref): Likewise.
* tree-ssa-loop-ivopts.c (dump_use, divide, stmt_after_ip_normal_pos,
stmt_after_increment, set_iv, contains_abnormal_ssa_name_p,
find_interesting_uses_outer_or_nonlin, add_derived_ivs_candidates,
peel_address, ptr_difference_cost, may_replace_final_value,
determine_use_iv_cost, rewrite_use_nonlinear_expr, rewrite_use_outer,
rewrite_use, rewrite_uses): Likewise.
* tree-ssa-loop-manip.c (rewrite_into_loop_closed_ssa,
check_loop_closed_ssa_use): Likewise.
* tree-ssanames.c (make_ssa_name): Likewise.
* tree-ssa-operands.c (finalize_ssa_defs, finalize_ssa_uses,
finalize_ssa_v_must_defs, finalize_ssa_stmt_operands,
get_stmt_operands, get_expr_operands, get_asm_expr_operands,
get_indirect_ref_operands, add_stmt_operand): Likewise.
* tree-ssa-pre.c (value_exists_in_set_bitmap,
value_remove_from_set_bitmap, bitmap_insert_into_set, insert_into_set,
phi_translate, valid_in_set, compute_antic,
find_or_generate_expression, create_expression_by_pieces, insert_aux,
create_value_expr_from, eliminate): Likewise.
* tree-ssa-propagate.c (cfg_blocks_get): Likewise.
* tree-ssa-threadupdate.c (remove_last_stmt_and_useless_edges):
Likewise.
* tree-tailcall.c (independent_of_stmt_p, adjust_return_value,
eliminate_tail_call): Likewise.
* tree-vectorizer.c (vect_create_index_for_array_ref,
vect_align_data_ref, vect_create_data_ref,
vect_create_destination_var, vect_get_vec_def_for_operand,
vect_finish_stmt_generation, vect_transform_stmt,
vect_transform_loop_bound, vect_transform_loop,
vect_analyze_operations): Likewise.
* tree-vn.c (vn_compute, set_value_handle, get_value_handle):
Likewise.
* tree-flow-inline.h (var_ann, get_var_ann, get_def_from_ptr,
get_use_op_ptr, immediate_use, phi_ssa_name_p, bsi_start,
bsi_after_labels, bsi_last): Likewise.
* tree-ssa-live.c (var_union, change_partition_var,
create_ssa_var_map, calculate_live_on_entry, root_var_init,
type_var_init, add_coalesce, sort_coalesce_list, pop_best_coalesce):
Likewise.
* tree-ssa-live.h (partition_is_global, live_entry_blocks,
tpa_find_tree): Likewise.
(register_ssa_partition_check): Declare.
(register_ssa_partition): use it.
* tree-ssa-live.c: Include errors.h.
(register_ssa_partition_check): New.
* tree-ssa-operands.c: Include errors.h.
* Makefile.in (tree-ssa-operands.o): Depend on errors.h.
Co-Authored-By: Nathan Sidwell <nathan@codesourcery.com>
From-SVN: r87223
2004-09-09 09:54:12 +02:00
|
|
|
gcc_assert (j != NUM_V_MAY_DEFS (v_may_defs2));
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Set bit UID in bitmaps GLOBAL and *LOCAL, creating *LOCAL as needed. */
|
|
|
|
static void
|
|
|
|
record_voperand_set (bitmap global, bitmap *local, unsigned int uid)
|
|
|
|
{
|
|
|
|
/* Lazily allocate the bitmap. Note that we do not get a notification
|
|
|
|
when the block local data structures die, so we allocate the local
|
|
|
|
bitmap backed by the GC system. */
|
|
|
|
if (*local == NULL)
|
|
|
|
*local = BITMAP_GGC_ALLOC ();
|
|
|
|
|
|
|
|
/* Set the bit in the local and global bitmaps. */
|
|
|
|
bitmap_set_bit (*local, uid);
|
|
|
|
bitmap_set_bit (global, uid);
|
|
|
|
}
|
|
|
|
/* Initialize block local data structures. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
dse_initialize_block_local_data (struct dom_walk_data *walk_data,
|
|
|
|
basic_block bb ATTRIBUTE_UNUSED,
|
|
|
|
bool recycled)
|
|
|
|
{
|
|
|
|
struct dse_block_local_data *bd
|
|
|
|
= VARRAY_TOP_GENERIC_PTR (walk_data->block_data_stack);
|
|
|
|
|
|
|
|
/* If we are given a recycled block local data structure, ensure any
|
|
|
|
bitmap associated with the block is cleared. */
|
|
|
|
if (recycled)
|
|
|
|
{
|
|
|
|
if (bd->stores)
|
|
|
|
bitmap_clear (bd->stores);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attempt to eliminate dead stores in the statement referenced by BSI.
|
|
|
|
|
|
|
|
A dead store is a store into a memory location which will later be
|
|
|
|
overwritten by another store without any intervening loads. In this
|
|
|
|
case the earlier store can be deleted.
|
|
|
|
|
|
|
|
In our SSA + virtual operand world we use immediate uses of virtual
|
|
|
|
operands to detect dead stores. If a store's virtual definition
|
|
|
|
is used precisely once by a later store to the same location which
|
|
|
|
post dominates the first store, then the first store is dead. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
dse_optimize_stmt (struct dom_walk_data *walk_data,
|
|
|
|
basic_block bb ATTRIBUTE_UNUSED,
|
|
|
|
block_stmt_iterator bsi)
|
|
|
|
{
|
|
|
|
struct dse_block_local_data *bd
|
|
|
|
= VARRAY_TOP_GENERIC_PTR (walk_data->block_data_stack);
|
|
|
|
struct dse_global_data *dse_gd = walk_data->global_data;
|
|
|
|
tree stmt = bsi_stmt (bsi);
|
|
|
|
stmt_ann_t ann = stmt_ann (stmt);
|
2004-06-10 23:41:08 +02:00
|
|
|
v_may_def_optype v_may_defs;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
get_stmt_operands (stmt);
|
2004-06-10 23:41:08 +02:00
|
|
|
v_may_defs = V_MAY_DEF_OPS (ann);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
/* If this statement has no virtual uses, then there is nothing
|
|
|
|
to do. */
|
2004-06-10 23:41:08 +02:00
|
|
|
if (NUM_V_MAY_DEFS (v_may_defs) == 0)
|
2004-05-13 08:41:07 +02:00
|
|
|
return;
|
|
|
|
|
2004-07-08 18:16:41 +02:00
|
|
|
/* We know we have virtual definitions. If this is a MODIFY_EXPR that's
|
|
|
|
not also a function call, then record it into our table. */
|
|
|
|
if (get_call_expr_in (stmt))
|
|
|
|
return;
|
|
|
|
if (TREE_CODE (stmt) == MODIFY_EXPR)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
dataflow_t df = get_immediate_uses (stmt);
|
|
|
|
unsigned int num_uses = num_immediate_uses (df);
|
|
|
|
tree use;
|
|
|
|
tree skipped_phi;
|
|
|
|
|
|
|
|
|
|
|
|
/* If there are no uses then there is nothing left to do. */
|
|
|
|
if (num_uses == 0)
|
|
|
|
{
|
|
|
|
record_voperand_set (dse_gd->stores, &bd->stores, ann->uid);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
use = immediate_use (df, 0);
|
|
|
|
skipped_phi = NULL;
|
|
|
|
|
|
|
|
/* Skip through any PHI nodes we have already seen if the PHI
|
|
|
|
represents the only use of this store.
|
|
|
|
|
|
|
|
Note this does not handle the case where the store has
|
2004-06-10 23:41:08 +02:00
|
|
|
multiple V_MAY_DEFs which all reach a set of PHI nodes in the
|
2004-05-13 08:41:07 +02:00
|
|
|
same block. */
|
|
|
|
while (num_uses == 1
|
|
|
|
&& TREE_CODE (use) == PHI_NODE
|
2004-09-11 22:42:06 +02:00
|
|
|
&& bitmap_bit_p (dse_gd->stores, get_stmt_uid (use)))
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
/* Record the first PHI we skip so that we can fix its
|
|
|
|
uses if we find that STMT is a dead store. */
|
|
|
|
if (!skipped_phi)
|
|
|
|
skipped_phi = use;
|
|
|
|
|
|
|
|
/* Skip past this PHI and loop again in case we had a PHI
|
|
|
|
chain. */
|
|
|
|
df = get_immediate_uses (use);
|
|
|
|
num_uses = num_immediate_uses (df);
|
|
|
|
use = immediate_use (df, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we have precisely one immediate use at this point, then we may
|
|
|
|
have found redundant store. */
|
|
|
|
if (num_uses == 1
|
2004-09-11 22:42:06 +02:00
|
|
|
&& bitmap_bit_p (dse_gd->stores, get_stmt_uid (use))
|
2004-05-13 08:41:07 +02:00
|
|
|
&& operand_equal_p (TREE_OPERAND (stmt, 0),
|
|
|
|
TREE_OPERAND (use, 0), 0))
|
|
|
|
{
|
|
|
|
/* We need to fix the operands if either the first PHI we
|
|
|
|
skipped, or the store which we are not deleting if we did
|
|
|
|
not skip any PHIs. */
|
|
|
|
if (skipped_phi)
|
|
|
|
fix_phi_uses (skipped_phi, stmt);
|
|
|
|
else
|
2004-06-10 23:41:08 +02:00
|
|
|
fix_stmt_v_may_defs (use, stmt);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
{
|
|
|
|
fprintf (dump_file, " Deleted dead store '");
|
|
|
|
print_generic_expr (dump_file, bsi_stmt (bsi), dump_flags);
|
|
|
|
fprintf (dump_file, "'\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Any immediate uses which reference STMT need to instead
|
|
|
|
reference the new consumer, either SKIPPED_PHI or USE.
|
|
|
|
This allows us to cascade dead stores. */
|
|
|
|
redirect_immediate_uses (stmt, skipped_phi ? skipped_phi : use);
|
|
|
|
|
2004-09-15 06:12:18 +02:00
|
|
|
/* Be sure to remove any dataflow information attached to
|
|
|
|
this statement. */
|
|
|
|
free_df_for_stmt (stmt);
|
|
|
|
|
|
|
|
/* And release any SSA_NAMEs set in this statement back to the
|
|
|
|
SSA_NAME manager. */
|
|
|
|
release_defs (stmt);
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
/* Finally remove the dead store. */
|
|
|
|
bsi_remove (&bsi);
|
|
|
|
}
|
|
|
|
|
|
|
|
record_voperand_set (dse_gd->stores, &bd->stores, ann->uid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Record that we have seen the PHIs at the start of BB which correspond
|
|
|
|
to virtual operands. */
|
|
|
|
static void
|
|
|
|
dse_record_phis (struct dom_walk_data *walk_data, basic_block bb)
|
|
|
|
{
|
|
|
|
struct dse_block_local_data *bd
|
|
|
|
= VARRAY_TOP_GENERIC_PTR (walk_data->block_data_stack);
|
|
|
|
struct dse_global_data *dse_gd = walk_data->global_data;
|
|
|
|
tree phi;
|
|
|
|
|
tree.h (PHI_CHAIN): New.
* tree.h (PHI_CHAIN): New.
* (tree-cfg.c, tree-dfa.c, tree-flow-inline.h, tree-into-ssa.c,
tree-outof-ssa.c, tree-phinodes.c, tree-pretty-print.c,
tree-ssa-alias.c, tree-ssa-ccp.c, tree-ssa-dom.c, tree-ssa-dse.c,
tree-ssa-live.c, tree-ssa-loop.c, tree-ssa-phiopt.c, tree-ssa-pre.c,
tree-ssa.c, tree-tailcall.c): Use PHI_CHAIN instead of TREE_CHAIN
when traversing a list of PHI_NODEs.
From-SVN: r83273
2004-06-17 01:03:34 +02:00
|
|
|
for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
|
2004-05-13 08:41:07 +02:00
|
|
|
if (need_imm_uses_for (PHI_RESULT (phi)))
|
|
|
|
record_voperand_set (dse_gd->stores,
|
|
|
|
&bd->stores,
|
2004-09-11 22:42:06 +02:00
|
|
|
get_stmt_uid (phi));
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dse_finalize_block (struct dom_walk_data *walk_data,
|
|
|
|
basic_block bb ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
struct dse_block_local_data *bd
|
|
|
|
= VARRAY_TOP_GENERIC_PTR (walk_data->block_data_stack);
|
|
|
|
struct dse_global_data *dse_gd = walk_data->global_data;
|
|
|
|
bitmap stores = dse_gd->stores;
|
|
|
|
unsigned int i;
|
bitmap.h (EXECUTE_IF_SET_IN_BITMAP, [...]): Changed to iterator style.
* bitmap.h (EXECUTE_IF_SET_IN_BITMAP, EXECUTE_IF_AND_COMPL_IN_BITMAP,
EXECUTE_IF_AND_IN_BITMAP): Changed to iterator style.
(bitmap_iterator): New type.
(bmp_iter_common_next_1, bmp_iter_single_next_1, bmp_iter_single_init,
bmp_iter_end_p, bmp_iter_single_next, bmp_iter_and_not_next_1,
bmp_iter_and_not_init, bmp_iter_and_not_next, bmp_iter_and_next_1,
bmp_iter_and_init, bmp_iter_and_next): New functions.
* basic-block.h (EXECUTE_IF_SET_IN_REG_SET,
EXECUTE_IF_AND_COMPL_IN_REG_SET, EXECUTE_IF_AND_IN_REG_SET): Changed to
use iterator-style EXECUTE_IF_IN_BITMAP macros.
* bitmap.c (bitmap_print): Ditto.
* bt-load.c (clear_btr_from_live_range, add_btr_to_live_range,
btr_def_live_range): Ditto.
* cfganal.c (compute_dominance_frontiers_1) Ditto.
* cgraphunit.c (convert_UIDs_in_bitmap, cgraph_characterize_statics):
Ditto.
* ddg.c (build_inter_loop_deps): Ditto.
* df.c (FOR_EACH_BB_IN_BITMAP, df_bb_reg_info_compute, df_refs_update):
Ditto.
* except.c (remove_eh_handler): Ditto.
* flow.c (reg_set_to_hard_reg_set): Ditto.
* gcse.c (clear_modify_mem_tables): Ditto.
* global.c (build_insn_chain): Ditto.
* ifcvt.c (dead_or_predicable): Ditto.
* loop-invariant.c (get_inv_cost, set_move_mark, move_invariant_reg):
Ditto.
* ra-build.c (livethrough_conflicts_bb, conflicts_between_webs): Ditto.
* ra-rewrite.c (reloads_to_loads, rewrite_program2,
detect_web_parts_to_rebuild, delete_useless_defs, actual_spill): Ditto.
* tree-cfg.c (allocate_ssa_names, tree_duplicate_sese_region,
tree_purge_all_dead_eh_edges): Ditto.
* tree-into-ssa.c (compute_global_livein, insert_phi_nodes,
insert_phi_nodes_for, debug_def_blocks_r, invalidate_name_tags,
rewrite_ssa_into_ssa): Ditto.
* tree-outof-ssa.c (find_replaceable_exprs): Ditto.
* tree-sra.c (scan_function, decide_instantiations, scalarize_parms):
Ditto.
* tree-ssa-alias.c (init_alias_info, compute_points_to_and_addr_escape,
compute_flow_sensitive_aliasing, maybe_create_global_var,
dump_points_to_info_for): Ditto.
* tree-ssa-dce.c (EXECUTE_IF_CONTROL_DEPENDENT): Ditto.
* tree-ssa-dse.c (dse_finalize_block): Ditto.
* tree-ssa-live.c (live_worklist, calculate_live_on_entry,
calculate_live_on_exit, build_tree_conflict_graph, dump_live_info):
Ditto.
* tree-ssa-loop-ivopts.c (find_induction_variables,
find_interesting_uses, add_old_ivs_candidates, alloc_use_cost_map,
determine_use_iv_costs, determine_set_costs, find_best_candidate,
set_cost_up_to, create_new_ivs, remove_unused_ivs, free_loop_data):
Ditto.
* tree-ssa-loop-manip.c (add_exit_phis_var, add_exit_phis): Ditto.
* tree-ssa-operands.c (get_asm_expr_operands, add_call_clobber_ops,
add_call_read_ops): Ditto.
* tree-ssa-pre.c (bitmap_print_value_set, insert_aux): Ditto.
From-SVN: r88145
2004-09-26 21:53:13 +02:00
|
|
|
bitmap_iterator bi;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
/* Unwind the stores noted in this basic block. */
|
|
|
|
if (bd->stores)
|
bitmap.h (EXECUTE_IF_SET_IN_BITMAP, [...]): Changed to iterator style.
* bitmap.h (EXECUTE_IF_SET_IN_BITMAP, EXECUTE_IF_AND_COMPL_IN_BITMAP,
EXECUTE_IF_AND_IN_BITMAP): Changed to iterator style.
(bitmap_iterator): New type.
(bmp_iter_common_next_1, bmp_iter_single_next_1, bmp_iter_single_init,
bmp_iter_end_p, bmp_iter_single_next, bmp_iter_and_not_next_1,
bmp_iter_and_not_init, bmp_iter_and_not_next, bmp_iter_and_next_1,
bmp_iter_and_init, bmp_iter_and_next): New functions.
* basic-block.h (EXECUTE_IF_SET_IN_REG_SET,
EXECUTE_IF_AND_COMPL_IN_REG_SET, EXECUTE_IF_AND_IN_REG_SET): Changed to
use iterator-style EXECUTE_IF_IN_BITMAP macros.
* bitmap.c (bitmap_print): Ditto.
* bt-load.c (clear_btr_from_live_range, add_btr_to_live_range,
btr_def_live_range): Ditto.
* cfganal.c (compute_dominance_frontiers_1) Ditto.
* cgraphunit.c (convert_UIDs_in_bitmap, cgraph_characterize_statics):
Ditto.
* ddg.c (build_inter_loop_deps): Ditto.
* df.c (FOR_EACH_BB_IN_BITMAP, df_bb_reg_info_compute, df_refs_update):
Ditto.
* except.c (remove_eh_handler): Ditto.
* flow.c (reg_set_to_hard_reg_set): Ditto.
* gcse.c (clear_modify_mem_tables): Ditto.
* global.c (build_insn_chain): Ditto.
* ifcvt.c (dead_or_predicable): Ditto.
* loop-invariant.c (get_inv_cost, set_move_mark, move_invariant_reg):
Ditto.
* ra-build.c (livethrough_conflicts_bb, conflicts_between_webs): Ditto.
* ra-rewrite.c (reloads_to_loads, rewrite_program2,
detect_web_parts_to_rebuild, delete_useless_defs, actual_spill): Ditto.
* tree-cfg.c (allocate_ssa_names, tree_duplicate_sese_region,
tree_purge_all_dead_eh_edges): Ditto.
* tree-into-ssa.c (compute_global_livein, insert_phi_nodes,
insert_phi_nodes_for, debug_def_blocks_r, invalidate_name_tags,
rewrite_ssa_into_ssa): Ditto.
* tree-outof-ssa.c (find_replaceable_exprs): Ditto.
* tree-sra.c (scan_function, decide_instantiations, scalarize_parms):
Ditto.
* tree-ssa-alias.c (init_alias_info, compute_points_to_and_addr_escape,
compute_flow_sensitive_aliasing, maybe_create_global_var,
dump_points_to_info_for): Ditto.
* tree-ssa-dce.c (EXECUTE_IF_CONTROL_DEPENDENT): Ditto.
* tree-ssa-dse.c (dse_finalize_block): Ditto.
* tree-ssa-live.c (live_worklist, calculate_live_on_entry,
calculate_live_on_exit, build_tree_conflict_graph, dump_live_info):
Ditto.
* tree-ssa-loop-ivopts.c (find_induction_variables,
find_interesting_uses, add_old_ivs_candidates, alloc_use_cost_map,
determine_use_iv_costs, determine_set_costs, find_best_candidate,
set_cost_up_to, create_new_ivs, remove_unused_ivs, free_loop_data):
Ditto.
* tree-ssa-loop-manip.c (add_exit_phis_var, add_exit_phis): Ditto.
* tree-ssa-operands.c (get_asm_expr_operands, add_call_clobber_ops,
add_call_read_ops): Ditto.
* tree-ssa-pre.c (bitmap_print_value_set, insert_aux): Ditto.
From-SVN: r88145
2004-09-26 21:53:13 +02:00
|
|
|
EXECUTE_IF_SET_IN_BITMAP (bd->stores, 0, i, bi)
|
|
|
|
{
|
|
|
|
bitmap_clear_bit (stores, i);
|
|
|
|
}
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_ssa_dse (void)
|
|
|
|
{
|
|
|
|
struct dom_walk_data walk_data;
|
|
|
|
struct dse_global_data dse_gd;
|
|
|
|
basic_block bb;
|
|
|
|
|
|
|
|
/* Create a UID for each statement in the function. Ordering of the
|
|
|
|
UIDs is not important for this pass. */
|
2004-09-11 22:42:06 +02:00
|
|
|
max_stmt_uid = 0;
|
2004-05-13 08:41:07 +02:00
|
|
|
FOR_EACH_BB (bb)
|
|
|
|
{
|
|
|
|
block_stmt_iterator bsi;
|
|
|
|
|
|
|
|
for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
|
2004-09-11 22:42:06 +02:00
|
|
|
stmt_ann (bsi_stmt (bsi))->uid = max_stmt_uid++;
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* We might consider making this a property of each pass so that it
|
|
|
|
can be [re]computed on an as-needed basis. Particularly since
|
|
|
|
this pass could be seen as an extension of DCE which needs post
|
|
|
|
dominators. */
|
|
|
|
calculate_dominance_info (CDI_POST_DOMINATORS);
|
|
|
|
|
|
|
|
/* We also need immediate use information for virtual operands. */
|
|
|
|
compute_immediate_uses (TDFA_USE_VOPS, need_imm_uses_for);
|
|
|
|
|
|
|
|
/* Dead store elimination is fundamentally a walk of the post-dominator
|
|
|
|
tree and a backwards walk of statements within each block. */
|
|
|
|
walk_data.walk_stmts_backward = true;
|
|
|
|
walk_data.dom_direction = CDI_POST_DOMINATORS;
|
|
|
|
walk_data.initialize_block_local_data = dse_initialize_block_local_data;
|
|
|
|
walk_data.before_dom_children_before_stmts = NULL;
|
|
|
|
walk_data.before_dom_children_walk_stmts = dse_optimize_stmt;
|
|
|
|
walk_data.before_dom_children_after_stmts = dse_record_phis;
|
|
|
|
walk_data.after_dom_children_before_stmts = NULL;
|
|
|
|
walk_data.after_dom_children_walk_stmts = NULL;
|
|
|
|
walk_data.after_dom_children_after_stmts = dse_finalize_block;
|
|
|
|
|
|
|
|
walk_data.block_local_data_size = sizeof (struct dse_block_local_data);
|
|
|
|
|
|
|
|
/* This is the main hash table for the dead store elimination pass. */
|
|
|
|
dse_gd.stores = BITMAP_XMALLOC ();
|
|
|
|
walk_data.global_data = &dse_gd;
|
|
|
|
|
|
|
|
/* Initialize the dominator walker. */
|
|
|
|
init_walk_dominator_tree (&walk_data);
|
|
|
|
|
|
|
|
/* Recursively walk the dominator tree. */
|
|
|
|
walk_dominator_tree (&walk_data, EXIT_BLOCK_PTR);
|
|
|
|
|
|
|
|
/* Finalize the dominator walker. */
|
|
|
|
fini_walk_dominator_tree (&walk_data);
|
|
|
|
|
|
|
|
/* Release the main bitmap. */
|
|
|
|
BITMAP_XFREE (dse_gd.stores);
|
|
|
|
|
|
|
|
/* Free dataflow information. It's probably out of date now anyway. */
|
|
|
|
free_df ();
|
|
|
|
|
|
|
|
/* For now, just wipe the post-dominator information. */
|
|
|
|
free_dominance_info (CDI_POST_DOMINATORS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
gate_dse (void)
|
|
|
|
{
|
|
|
|
return flag_tree_dse != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct tree_opt_pass pass_dse = {
|
|
|
|
"dse", /* name */
|
|
|
|
gate_dse, /* gate */
|
|
|
|
tree_ssa_dse, /* execute */
|
|
|
|
NULL, /* sub */
|
|
|
|
NULL, /* next */
|
|
|
|
0, /* static_pass_number */
|
|
|
|
TV_TREE_DSE, /* tv_id */
|
2004-07-28 07:13:10 +02:00
|
|
|
PROP_cfg | PROP_ssa
|
|
|
|
| PROP_alias, /* properties_required */
|
2004-05-13 08:41:07 +02:00
|
|
|
0, /* properties_provided */
|
|
|
|
0, /* properties_destroyed */
|
|
|
|
0, /* todo_flags_start */
|
|
|
|
TODO_dump_func | TODO_ggc_collect /* todo_flags_finish */
|
Unify the management of RTL and tree-level dump files.
2004-09-06 Paolo Bonzini <bonzini@gnu.org>
Unify the management of RTL and tree-level dump files.
* cfgexpand.c (tree_expand_cfg): Fix incorrect comment.
Don't print function name to the dump file, the pass manager
would do this for us. Add code from the top of
rest_of_compilation, up to the initial RTL dump.
* passes.c (rest_of_handle_jump): Call fixup_tail_calls and
close the DFI_sibling dump file.
(rest_of_compilation): Don't do that here. Remove code up to the
initial RTL dump.
(init_optimization_passes): Remove.
(pass_rest_of_compilation): Change pass name to NULL.
* toplev.c (lang_dependent_init): Do not use an empty dump file prefix.
Do not call init_optimization_passes.
* toplev.h (init_optimization_passes): Remove.
* graph.c (print_rtl_graph_with_bb, clean_graph_dump_file,
finish_graph_dump_file): Remove SUFFIX parameter.
* graph.h (print_rtl_graph_with_bb, clean_graph_dump_file,
finish_graph_dump_file): Likewise.
* tree-pass.h (struct tree_opt_pass): Add `letter' field.
* cfgexpand.c (pass_expand): Adjust.
* gimple-low.c (pass_lower_cf, pass_remove_useless_vars): Adjust.
* passes.c (pass_rest_of_compilation): Adjust.
* predict.c (pass_profile): Adjust.
* tree-alias-common.c (pass_build_pta, pass_del_pta): Adjust.
* tree-cfg.c (pass_build_cfg, pass_remove_useless_stmts,
pass_split_crit_edges, pass_warn_function_return): Adjust.
* tree-complex.c (pass_lower_vector_ssa, pass_pre_expand): Adjust.
* tree-dfa.c (pass_referenced_vars): Adjust.
* tree-eh.c (pass_lower_eh): Adjust.
* tree-if-conv.c (pass_build_ssa): Adjust.
* tree-into-ssa.c (pass_build_ssa): Adjust.
* tree-mudflap.c (pass_mudflap_1, pass_mudflap_2): Adjust.
* tree-nomudflap.c (pass_mudflap_1, pass_mudflap_2): Adjust.
* tree-nrv.c (pass_nrv): Adjust.
* tree-optimize.c (pass_gimple, pass_all_optimizations,
pass_cleanup_cfg_post_optimizing, pass_free_datastructures,
pass_init_datastructures): Adjust.
* tree-outof-ssa.c (pass_del_ssa): Adjust.
* tree-profile.c (pass_tree_profile): Adjust.
* tree-sra.c (pass_sra): Adjust.
* tree-ssa-alias.c (pass_may_alias): Adjust.
* tree-ssa-ccp.c (pass_ccp, pass_fold_builtins): Adjust.
* tree-ssa-copyrename.c (pass_rename_ssa_copies): Adjust.
* tree-ssa-dce.c (pass_dce, pass_cd_dce): Adjust.
* tree-ssa-dom.c (pass_dominator): Adjust.
* tree-ssa-dse.c (pass_dse): Adjust.
* tree-ssa-forwprop.c (pass_forwprop): Adjust.
* tree-ssa-if-conv.c (pass_if_conversion): Adjust.
* tree-ssa-loop-ch.c (pass_ch): Adjust.
* tree-ssa-loop.c (pass_loop, pass_loop_init, pass_lim,
pass_loop_done, pass_complete_unroll, pass_iv_canon,
pass_iv_optimize, pass_vectorize): Adjust.
* tree-ssa-phiopt.c (pass_phiopt): Adjust.
* tree-ssa-pre.c (pass_pre, pass_fre): Adjust.
* tree-ssa.c (pass_redundant_phi, pass_early_warn_uninitialized,
pass_late_warn_uninnitialized): Adjust.
* tree-tailcall.c (pass_tail_recursion, pass_tail_calls): Adjust.
* Makefile.in (tree-dump.o): Add new dependencies.
* cgraph.c (cgraph_remove_node): TDF_all -> TDF_tree_all.
* cgraphunit.c (cgraph_preserve_function_body_p, cgraph_optimize):
Likewise.
* toplev.c (dump_file_name): New.
* tree-dump.c (dump_enable_all): Add LETTER parameter.
(struct dump_file_info): Add NUM and LETTER fields.
(dump_files): Adjust and add RTL dump files.
(dump_register): Add NUM and LETTER fields.
(get_dump_file_name, dump_initialized_p, enable_rtl_dump_file): New.
(dump_begin): Use get_dump_file_name.
(dump_switch_p_1): Adjust call to dump_enable_all.
* tree-dump.h (dump_register): Adjust prototype.
* tree-optimize.c (register_one_dump_file): Take dump file index.
Support flags for RTL dumps.
(register_dump_files): Fill in NUM field of struct dump_file_info.
Track properties both when the gate is executed and when it is not.
(execute_todo): Dump RTL. Add PROPERTIES parameter.
(execute_one_pass): Pass properties to execute_todo. Handle VCG
dumps of RTL.
* tree-pass.h (dump_file_name): New.
* tree.h (TDF_TREE, TDF_RTL, get_dump_file_name, dump_initialized_p):
New.
* Makefile.in (passes.o): Add new dependencies.
* passes.c (struct dump_file_info, enum dump_file_index,
dump_file_tbl, init_optimization_passes): Remove.
(open_dump_file, close_dump_file): Use tree-dumping infrastructure.
(rest_of_handle_new_regalloc, rest_of_handle_old_regalloc): Use
dump_enabled_p.
(finish_optimization_passes): Update finish_graph_dump_file loop.
(enable_rtl_dump_file): Remove.
* tree-dump.c (dump_files): Adjust and add RTL dump files.
(enable_rtl_dump_file): Add here.
* tree.h (enum tree_dump_index): Add RTL dump file indices.
* doc/invoke.texi (Debugging options): Document new RTL debugging
options. Update.
From-SVN: r87113
2004-09-06 12:08:17 +02:00
|
|
|
| TODO_verify_ssa,
|
|
|
|
0 /* letter */
|
2004-05-13 08:41:07 +02:00
|
|
|
};
|