Commit 56b043c8 by Jeff Law Committed by Jeff Law

Makefile.in (OBJC-common): Add tree-ssa-threadupdate.c

        * Makefile.in (OBJC-common): Add tree-ssa-threadupdate.c
        (tree-ssa-threadupdate.o): Add dependencies.
        * tree-ssa-threadupdate.c: New file.
        * tree-flow.h (incoming_edge_threaded): New flag in block annotation.
        (rewrite_vars_out_of_ssa): Remove prototype.
        (cleanup_tree_cfg): Returns a bool.
        * tree.h (thread_through_all_blocks): Prototype.
        * tree-outof-ssa.c  (SSANORM_*): Move into here.
        (remove_ssa_form): Now static.
        (rewrite_vars_out_of_ssa): Kill.
        * tree-ssa-live.c (register_ssa_partitions_for_vars): Kill.
        * tree-ssa-live.h (SSANORM_*): Moved into tree-outof-ssa.c.
        (remove_ssa_form, register_partitions_for_vars): Kill declarations.
        * tree-cfg.c (cleanup_tree_cfg): Return a value indicating if
        anything was changed.
        * tree-phinodes.c (add_phi_arg): Get the block for the PHI
        from the PHI's annotation rather than the edge associated with
        the new argument.
        * tree-ssa-dom.c (redirection_edges): Kill.
        (redirect_edges_and_update_ssa_graph): Kill.
        (tree_ssa_dominator_optimize): Do not reset forwardable flag
        for blocks anymore.  Do not initialize redirection_edges.
        Call thread_through_all_blocks.  Simplify code for cleanup
        of the CFG and iterating.  No longer call cleanup_tree_cfg
        outside the iteration loop.
        (thread_across_edge): No longer mess with forwardable blocks.

From-SVN: r85721
parent 9b305d55
2004-08-09 Jeff Law <law@redhat.com>
* Makefile.in (OBJC-common): Add tree-ssa-threadupdate.c
(tree-ssa-threadupdate.o): Add dependencies.
* tree-ssa-threadupdate.c: New file.
* tree-flow.h (incoming_edge_threaded): New flag in block annotation.
(rewrite_vars_out_of_ssa): Remove prototype.
(cleanup_tree_cfg): Returns a bool.
* tree.h (thread_through_all_blocks): Prototype.
* tree-outof-ssa.c (SSANORM_*): Move into here.
(remove_ssa_form): Now static.
(rewrite_vars_out_of_ssa): Kill.
* tree-ssa-live.c (register_ssa_partitions_for_vars): Kill.
* tree-ssa-live.h (SSANORM_*): Moved into tree-outof-ssa.c.
(remove_ssa_form, register_partitions_for_vars): Kill declarations.
* tree-cfg.c (cleanup_tree_cfg): Return a value indicating if
anything was changed.
* tree-phinodes.c (add_phi_arg): Get the block for the PHI
from the PHI's annotation rather than the edge associated with
the new argument.
* tree-ssa-dom.c (redirection_edges): Kill.
(redirect_edges_and_update_ssa_graph): Kill.
(tree_ssa_dominator_optimize): Do not reset forwardable flag
for blocks anymore. Do not initialize redirection_edges.
Call thread_through_all_blocks. Simplify code for cleanup
of the CFG and iterating. No longer call cleanup_tree_cfg
outside the iteration loop.
(thread_across_edge): No longer mess with forwardable blocks.
2004-08-09 Zack Weinberg <zack@codesourcery.com>
* explow.c (memory_address): Use memory_address_p.
......
......@@ -898,7 +898,7 @@ OBJS-common = \
tree-ssa-phiopt.o tree-ssa-forwprop.o tree-nested.o tree-ssa-dse.o \
tree-ssa-dom.o domwalk.o tree-tailcall.o gimple-low.o tree-iterator.o \
tree-phinodes.o tree-ssanames.o tree-sra.o tree-complex.o tree-ssa-loop.o \
tree-ssa-loop-niter.o tree-ssa-loop-manip.o \
tree-ssa-loop-niter.o tree-ssa-loop-manip.o tree-ssa-threadupdate.o \
alias.o bb-reorder.o bitmap.o builtins.o caller-save.o calls.o \
cfg.o cfganal.o cfgbuild.o cfgcleanup.o cfglayout.o cfgloop.o \
cfgloopanal.o cfgloopmanip.o loop-init.o loop-unswitch.o loop-unroll.o \
......@@ -1632,6 +1632,10 @@ tree-ssa-dom.o : tree-ssa-dom.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \
errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \
$(BASIC_BLOCK_H) domwalk.h real.h tree-pass.h $(FLAGS_H) langhooks.h
tree-ssa-threadupdate.o : tree-ssa-threadupdate.c $(TREE_FLOW_H) $(CONFIG_H) \
$(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h \
diagnostic.h errors.h function.h $(TM_H) coretypes.h $(TREE_DUMP_H) \
$(BASIC_BLOCK_H) $(FLAGS_H) tree-pass.h
tree-ssanames.o : tree-ssanames.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(TREE_H) varray.h $(GGC_H) gt-tree-ssanames.h $(TREE_FLOW_H)
tree-phinodes.o : tree-phinodes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
......
......@@ -717,10 +717,11 @@ make_goto_expr_edges (basic_block bb)
/* Remove unreachable blocks and other miscellaneous clean up work. */
void
bool
cleanup_tree_cfg (void)
{
bool something_changed = true;
bool retval = false;
timevar_push (TV_TREE_CLEANUP_CFG);
......@@ -731,6 +732,7 @@ cleanup_tree_cfg (void)
something_changed = cleanup_control_flow ();
something_changed |= delete_unreachable_blocks ();
something_changed |= thread_jumps ();
retval |= something_changed;
}
/* Merging the blocks creates no new opportunities for the other
......@@ -743,6 +745,7 @@ cleanup_tree_cfg (void)
verify_flow_info ();
#endif
timevar_pop (TV_TREE_CLEANUP_CFG);
return retval;
}
......
......@@ -356,6 +356,10 @@ struct bb_ann_d GTY(())
/* Nonzero if this block contains an escape point (see is_escape_site). */
unsigned has_escape_site : 1;
/* Nonzero if one or more incoming edges to this block should be threaded
to an outgoing edge of this block. */
unsigned incoming_edge_threaded : 1;
struct edge_prediction *predictions;
};
......@@ -474,7 +478,7 @@ extern void debug_loop_ir (void);
extern void print_loop_ir (FILE *);
extern void cleanup_dead_labels (void);
extern void group_case_labels (void);
extern void cleanup_tree_cfg (void);
extern bool cleanup_tree_cfg (void);
extern tree first_stmt (basic_block);
extern tree last_stmt (basic_block);
extern tree *last_stmt_ptr (basic_block);
......@@ -561,7 +565,6 @@ typedef bool (*walk_use_def_chains_fn) (tree, tree, void *);
/* In tree-ssa.c */
extern void init_tree_ssa (void);
extern void rewrite_vars_out_of_ssa (bitmap);
extern void dump_reaching_defs (FILE *);
extern void debug_reaching_defs (void);
extern void dump_tree_ssa (FILE *);
......
......@@ -48,6 +48,14 @@ Boston, MA 02111-1307, USA. */
#include "tree-ssa-live.h"
#include "tree-pass.h"
/* Flags to pass to remove_ssa_form. */
#define SSANORM_PERFORM_TER 0x1
#define SSANORM_COMBINE_TEMPS 0x2
#define SSANORM_REMOVE_ALL_PHIS 0x4
#define SSANORM_COALESCE_PARTITIONS 0x8
#define SSANORM_USE_COALESCE_LIST 0x10
/* Used to hold all the components required to do SSA PHI elimination.
The node and pred/succ list is a simple linear list of nodes and
edges represented as pairs of nodes.
......@@ -1956,7 +1964,7 @@ rewrite_trees (var_map map, tree *values)
/* Remove the variables specified in MAP from SSA form. Any debug information
is sent to DUMP. FLAGS indicate what options should be used. */
void
static void
remove_ssa_form (FILE *dump, var_map map, int flags)
{
tree_live_info_p liveinfo;
......@@ -2039,122 +2047,6 @@ remove_ssa_form (FILE *dump, var_map map, int flags)
dump_file = save;
}
/* Take a subset of the variables VARS in the current function out of SSA
form. */
void
rewrite_vars_out_of_ssa (bitmap vars)
{
if (bitmap_first_set_bit (vars) >= 0)
{
var_map map;
basic_block bb;
tree phi;
int i;
int ssa_flags;
/* Search for PHIs in which one of the PHI arguments is marked for
translation out of SSA form, but for which the PHI result is not
marked for translation out of SSA form.
Our per-variable out of SSA translation can not handle that case;
however we can easily handle it here by creating a new instance
of the PHI result's underlying variable and initializing it to
the offending PHI argument on the edge associated with the
PHI argument. We then change the PHI argument to use our new
instead of the PHI's underlying variable.
You might think we could register partitions for the out-of-ssa
translation here and avoid a second walk of the PHI nodes. No
such luck since the size of the var map will change if we have
to manually take variables out of SSA form here. */
FOR_EACH_BB (bb)
{
for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
{
tree result = SSA_NAME_VAR (PHI_RESULT (phi));
/* If the definition is marked for renaming, then we need
to do nothing more for this PHI node. */
if (bitmap_bit_p (vars, var_ann (result)->uid))
continue;
/* Look at all the arguments and see if any of them are
marked for renaming. If so, we need to handle them
specially. */
for (i = 0; i < PHI_NUM_ARGS (phi); i++)
{
tree arg = PHI_ARG_DEF (phi, i);
/* If the argument is not an SSA_NAME, then we can ignore
this argument. */
if (TREE_CODE (arg) != SSA_NAME)
continue;
/* If this argument is marked for renaming, then we need
to undo the copy propagation so that we can take
the argument out of SSA form without taking the
result out of SSA form. */
arg = SSA_NAME_VAR (arg);
if (bitmap_bit_p (vars, var_ann (arg)->uid))
{
tree new_name, copy;
/* Get a new SSA_NAME for the copy, it is based on
the result, not the argument! We use the PHI
as the definition since we haven't created the
definition statement yet. */
new_name = make_ssa_name (result, phi);
/* Now create the copy statement. */
copy = build (MODIFY_EXPR, TREE_TYPE (arg),
new_name, PHI_ARG_DEF (phi, i));
/* Now update SSA_NAME_DEF_STMT to point to the
newly created statement. */
SSA_NAME_DEF_STMT (new_name) = copy;
/* Now make the argument reference our new SSA_NAME. */
SET_PHI_ARG_DEF (phi, i, new_name);
/* Queue the statement for insertion. */
bsi_insert_on_edge (PHI_ARG_EDGE (phi, i), copy);
modify_stmt (copy);
}
}
}
}
/* If any copies were inserted on edges, actually insert them now. */
bsi_commit_edge_inserts (NULL);
/* Now register partitions for all instances of the variables we
are taking out of SSA form. */
map = init_var_map (num_ssa_names + 1);
register_ssa_partitions_for_vars (vars, map);
/* Now that we have all the partitions registered, translate the
appropriate variables out of SSA form. */
ssa_flags = SSANORM_COALESCE_PARTITIONS;
if (flag_tree_combine_temps)
ssa_flags |= SSANORM_COMBINE_TEMPS;
remove_ssa_form (dump_file, map, ssa_flags);
/* And finally, reset the out_of_ssa flag for each of the vars
we just took out of SSA form. */
EXECUTE_IF_SET_IN_BITMAP (vars, 0, i,
{
var_ann (referenced_var (i))->out_of_ssa_tag = 0;
});
/* Free the map as we are done with it. */
delete_var_map (map);
}
}
/* Take the current function out of SSA form, as described in
R. Morgan, ``Building an Optimizing Compiler'',
Butterworth-Heinemann, Boston, MA, 1998. pp 176-186. */
......
......@@ -335,17 +335,24 @@ add_phi_arg (tree *phi, tree def, edge e)
release the old PHI node. */
if (*phi != old_phi)
{
/* Extract the basic block for the PHI from the PHI's annotation
rather than the edge. This works better as the edge's
destination may not currently be the block with the PHI
node if we are in the process of threading the edge to
a new destination. */
basic_block bb = bb_for_stmt (*phi);
release_phi_node (old_phi);
/* Update the list head if replacing the first listed phi. */
if (phi_nodes (e->dest) == old_phi)
bb_ann (e->dest)->phi_nodes = *phi;
if (phi_nodes (bb) == old_phi)
bb_ann (bb)->phi_nodes = *phi;
else
{
/* Traverse the list looking for the phi node to chain to. */
tree p;
for (p = phi_nodes (e->dest);
for (p = phi_nodes (bb);
p && PHI_CHAIN (p) != old_phi;
p = PHI_CHAIN (p))
;
......
......@@ -1827,95 +1827,3 @@ dump_live_info (FILE *f, tree_live_info_p live, int flag)
}
}
}
/* Register partitions in MAP so that we can take VARS out of SSA form.
This requires a walk over all the PHI nodes and all the statements. */
void
register_ssa_partitions_for_vars (bitmap vars, var_map map)
{
basic_block bb;
if (bitmap_first_set_bit (vars) >= 0)
{
/* Find every instance (SSA_NAME) of variables in VARs and
register a new partition for them. This requires examining
every statement and every PHI node once. */
FOR_EACH_BB (bb)
{
block_stmt_iterator bsi;
tree next;
tree phi;
/* Register partitions for SSA_NAMEs appearing in the PHI
nodes in this basic block.
Note we delete PHI nodes in this loop if they are
associated with virtual vars which are going to be
renamed. */
for (phi = phi_nodes (bb); phi; phi = next)
{
tree result = SSA_NAME_VAR (PHI_RESULT (phi));
next = PHI_CHAIN (phi);
if (bitmap_bit_p (vars, var_ann (result)->uid))
{
if (! is_gimple_reg (result))
remove_phi_node (phi, NULL_TREE, bb);
else
{
int i;
/* Register a partition for the result. */
register_ssa_partition (map, PHI_RESULT (phi), 0);
/* Register a partition for each argument as needed. */
for (i = 0; i < PHI_NUM_ARGS (phi); i++)
{
tree arg = PHI_ARG_DEF (phi, i);
if (TREE_CODE (arg) != SSA_NAME)
continue;
if (!bitmap_bit_p (vars,
var_ann (SSA_NAME_VAR (arg))->uid))
continue;
register_ssa_partition (map, arg, 1);
}
}
}
}
/* Now register partitions for SSA_NAMEs appearing in each
statement in this block. */
for (bsi = bsi_start (bb); ! bsi_end_p (bsi); bsi_next (&bsi))
{
stmt_ann_t ann = stmt_ann (bsi_stmt (bsi));
use_optype uses = USE_OPS (ann);
def_optype defs = DEF_OPS (ann);
unsigned int i;
for (i = 0; i < NUM_USES (uses); i++)
{
tree op = USE_OP (uses, i);
if (TREE_CODE (op) == SSA_NAME
&& bitmap_bit_p (vars, var_ann (SSA_NAME_VAR (op))->uid))
register_ssa_partition (map, op, 1);
}
for (i = 0; i < NUM_DEFS (defs); i++)
{
tree op = DEF_OP (defs, i);
if (TREE_CODE (op) == SSA_NAME
&& bitmap_bit_p (vars,
var_ann (SSA_NAME_VAR (op))->uid))
register_ssa_partition (map, op, 0);
}
}
}
}
}
......@@ -58,22 +58,12 @@ typedef struct _var_map
#define VARMAP_NORMAL 0
#define VARMAP_NO_SINGLE_DEFS 1
/* Flags to pass to remove_ssa_form. */
#define SSANORM_PERFORM_TER 0x1
#define SSANORM_COMBINE_TEMPS 0x2
#define SSANORM_REMOVE_ALL_PHIS 0x4
#define SSANORM_COALESCE_PARTITIONS 0x8
#define SSANORM_USE_COALESCE_LIST 0x10
extern var_map init_var_map (int);
extern void delete_var_map (var_map);
extern void dump_var_map (FILE *, var_map);
extern int var_union (var_map, tree, tree);
extern void change_partition_var (var_map, tree, int);
extern void compact_var_map (var_map, int);
extern void remove_ssa_form (FILE *, var_map, int);
extern void register_ssa_partitions_for_vars (bitmap vars, var_map map);
extern tree make_ssa_temp (tree);
static inline int num_var_partitions (var_map);
......
......@@ -3770,4 +3770,7 @@ extern bool in_gimple_form;
tree lower_bound_in_type (tree, tree);
tree upper_bound_in_type (tree, tree);
/* In tree-ssa-threadupdate.c. */
extern bool thread_through_all_blocks (void);
#endif /* GCC_TREE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment