summaryrefslogtreecommitdiff
path: root/gcc/tree-dfa.c
diff options
context:
space:
mode:
authorbbooth <bbooth@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-10 21:41:08 +0000
committerbbooth <bbooth@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-10 21:41:08 +0000
commit2cf24776875d22c8713d227df0ed663a10e739a5 (patch)
tree390a758454170e0dc2e6aea71342ec3d64fd2501 /gcc/tree-dfa.c
parentdeeb83d60346e094b6636a49606677384a699502 (diff)
downloadgcc-2cf24776875d22c8713d227df0ed663a10e739a5.tar.gz
* doc/tree-ssa.texi: Remove references to VDEF and add descriptions
of V_MAY_DEF and V_MUST_DEF. * tree-dfa.c (dfa_stats_d): Add num_v_must_defs and rename num_vdefs to num_v_may_defs. (compute_immediate_uses_for_stmt): Rename occurences of vdef to v_may_def. (redirect_immediate_uses): Ditto. (dump_dfa_stats): Ditto. Also added code to dump num_v_must_defs. (collect_dfa_stats_r): Rename occurences of vdef to v_may_def. Also add code to sum up the number of v_must_defs. (vdefs_disappeared_p): Replace with... (v_may_defs_disappeared_p): This. (v_must_defs_disappeared_p): New function. (mark_new_vars_to_rename): Rename occurences of vdef to v_may_def. Also add code to mark new variables found in V_MUST_DEFs for renameing. * tree-flow.h (stmt_ann_d): Add v_must_def_ops and replace vdef_ops to v_may_def_ops. (get_vdef_ops): Replace with... (get_v_may_def_ops): This. * tree-flow-inline.h (get_vdef_ops): Replace with... (get_v_may_def_ops): This. (get_v_must_def_ops): New function. (get_vdef_result_ptr): Replace with... (get_v_may_def_result_ptr): This. (get_vdef_op_ptr): Ditto with... (get_v_may_def_op_ptr); This. (get_v_must_def_op_ptr): New function. * tree-into-ssa.c (mark_def_sites): Rename occurences of vdef to v_may_def. Also add code to mark statements with V_MUST_DEFs as definition sites. (rewrite_stmt): Rename occurences of vdef to v_may_def. Also add code to register new V_MUST_DEFs made by the statement. * tree-outof-ssa.c (VIRTUAL_PARTITION): Update comments. (check_replaceable): Rename occurences of vdef to v_may_def. Also add check for V_MUST_DEFs. (find_replaceable_in_bb): Ditto. * tree-pretty-print.c (dump_vops): Rename occurences of vdef to v_may_def. Also add code to dump V_MUST_DEFs. * tree-sra.c (mark_all_vdefs): Replace with... (mark_all_v_may_defs): This. (mark_all_v_must_defs): New function. (create_scalar_copies): Replace call to mark_all_vdefs with calls to mark_all_v_may_defs and mark_all_v_must_defs. (scalarize_structures): Rename occurences of vdef to v_may_def. Also add a check for V_MUST_DEFs. (scalarize_modify_expr): Rename occurences of vdef to v_may_def. * tree-ssa-alias.c (global_var): Update comment. (compute_may_aliases): Ditto. (compute_points_to_and_addr_escape): Rename occurences of vdef to v_may_def. Also add code to mark variables in V_MUST_DEF operands as being written to. (group_aliases): Update comment. (maybe_create_global_var): Ditto. * tree-ssa.c (verify_ssa): Rename occurences of vdef to v_may_def. Also add a check for V_MUST_DEFs on GIMPLE registers. (replace_immediate_uses): Rename occurences of vdef to v_may_def. * tree-ssa-ccp.c (visit_stmt): Rename occurences of vdef to v_may_def. Also add code to mark all V_MUST_DEF operands VARYING. (initialize): Ditto. (set_rhs): Rename occurences of vdef to v_may_def. Also add code to update SSA_NAMEs in V_MUST_DEFs. * tree-ssa-copy.c (cprop_into_stmt): Rename occurences of vdef to v_may_def. * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Rename occurences of vdef to v_may_def. Also add code to mark statements with V_MUST_DEFs as necessary. (propagate_necessity): Rename occurences of vdef to v_may_def. * tree-ssa-dom.c (redirect_edges_and_update_ssa_graph): Rename occurences of vdef to v_may_def. Also add code to mark operands in V_MUST_DEFs for renaming. (eliminate_redundant_computations): Rename occurences of vdef to v_may_def. (record_equivalences_from_stmt): Rename occurences of vdef to v_may_def. Also add code to record VUSEs for V_MUST_DEFs. (optimize_stmt): Remove unnesessary variable vdefs. Update comment. (register_definitions_for_stmt): Rename occurences of vdef to v_may_def. Also add code to register definitions made with V_MUST_DEFs. * tree-ssa-dse.c (fix_stmt_vdefs): Replace with... (fix_stmt_v_may_defs): This. (fix_phi_uses): Rename occurences of vdef to v_may_def. (dse_optimize_stmt): Ditto. * tree-ssa-live.c (create_ssa_var_map): Rename occurences of vdef to v_may_def. Also add code to mark V_MUST_DEF operands as being used in virtual operators. * tree-ssa-loop.c (mark_defs_for_rewrite): Rename occurences of vdef to v_may_def. Also add code to mark V_MUST_DEF operands for renaming. * tree-ssa-operands.c (opf_kill_def): New flag for killing definitions. (build_vdefs): Renamed to... (build_v_may_defs): This. (build_v_must_defs): New variable. (voperands_d): Add v_must_def_ops and replace vdef_ops with v_may_def_ops. (append_vdef): Replace with... (append_v_may_def): This. (append_v_must_def): New function. (NUM_FREE): Increment for V_MUST_DEF (optype_freelist): Increment its size for V_MUST_DEF (allocate_vdef_optype): Replace with... (allocate_v_may_def_optype): This. (allocate_v_must_def_optype): New function. (free_vdefs): Replace with... (free_v_may_defs): This. (free_v_must_defs): New function. (remove_vdefs): Replace with... (remove_v_may_defs): This. (remove_v_must_defs): New function. (init_ssa_operands): Rename occurences of vdef to v_may_def. Also add code to initialize build_v_must_defs. (finalize_ssa_vdefs): Replace with... (finalize_ssa_v_may_defs): This. (finalize_ssa_vuses): Rename occurences of vdef to v_may_def. (finalize_ssa_v_must_defs): New function. (finalize_ssa_stmt_operands): Replace call to finalize_ssa_vdefs with calls to finalize_ssa_v_may_defs and finalize_ssa_v_must_defs. (verify_start_operands): Rename occurences of vdef to v_may_def. Also add check for build_v_must_defs. (get_stmt_operands): Rename occurences of vdef to v_may_def. Also add code to handle V_MUST_DEFs and to use opf_kill_def for killing definitions. (get_expr_operands): Update comment and use opf_kill_def for killing definitions. (add_stmt_operand): Replace code that appends VDEFs with code that appends V_MUST_DEFs when opf_kill_def is set and V_MAY_DEFs otherwise. (add_call_clobber_ops): Update comments. * tree-ssa-operands.h (vdef_optype_d): Replace with... (v_may_def_optype_d): This. (v_must_def_optype_d): New structure. (VDEF_OPS): Replace with... (V_MAY_DEF_OPS): This. (STMT_VDEF_OPS): Same with... (STMT_V_MAY_DEF_OPS): This. (NUM_VDEFS): And... (NUM_V_MAY_DEFS): This. (VDEF_RESULT_PTR): As well as... (V_MAY_DEF_RESULT_PTR): This. (VDEF_RESULT): Same goes for... (V_MAY_DEF_RESULT): This. (VDEF_OP_PTR): And... (V_MAY_DEF_OP_PTR): This. (VDEF_OP): And... (V_MAY_DEF_OP): This. (V_MUST_DEF_OPS): New macro. (STMT_V_MUST_DEF_OPS): Ditto. (NUM_V_MUST_DEFS): Ditto. (V_MUST_DEF_OP_PTR): Ditto. (V_MUST_DEF_OP): Ditto. (remove_vdefs): Replace signature with... (remove_v_may_defs): This. (remove_v_must_defs): New function signature. * tree-ssa-pre.c (subst_phis): Replace call to remove_vdefs with calls to remove_v_may_defs and remove_v_must_defs. (process_left_occs_and_kills): Rename occurences of vdef to v_may_def. Also add code that marks left occurences of operands in V_MUST_DEFs. * tree-tailcall.c (find_tail_calls): Rename occurences of vdef to v_may_def. Also add check for V_MUST_DEFs. (eliminate_tail_call):Rename occurences of vdef to v_may_def. testsuite: * gcc.dg/tree-ssa/20031015-1.c: Scan for V_MAY_DEF instead of VDEF. * gcc.dg/tree-ssa/20040517-1.c: Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82947 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-dfa.c')
-rw-r--r--gcc/tree-dfa.c108
1 files changed, 81 insertions, 27 deletions
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index 00d008fbaaf..3bcf1d525c9 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -59,8 +59,9 @@ struct dfa_stats_d
long num_phis;
long num_phi_args;
int max_num_phi_args;
- long num_vdefs;
+ long num_v_may_defs;
long num_vuses;
+ long num_v_must_defs;
};
@@ -280,7 +281,7 @@ compute_immediate_uses_for_stmt (tree stmt, int flags, bool (*calc_for)(tree))
size_t i;
use_optype uses;
vuse_optype vuses;
- vdef_optype vdefs;
+ v_may_def_optype v_may_defs;
stmt_ann_t ann;
#ifdef ENABLE_CHECKING
@@ -314,10 +315,10 @@ compute_immediate_uses_for_stmt (tree stmt, int flags, bool (*calc_for)(tree))
add_immediate_use (imm_rdef_stmt, stmt);
}
- vdefs = VDEF_OPS (ann);
- for (i = 0; i < NUM_VDEFS (vdefs); i++)
+ v_may_defs = V_MAY_DEF_OPS (ann);
+ for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++)
{
- tree vuse = VDEF_OP (vdefs, i);
+ tree vuse = V_MAY_DEF_OP (v_may_defs, i);
tree imm_rdef_stmt = SSA_NAME_DEF_STMT (vuse);
if (!IS_EMPTY_STMT (imm_rdef_stmt) && (!calc_for || calc_for (vuse)))
add_immediate_use (imm_rdef_stmt, stmt);
@@ -390,7 +391,7 @@ redirect_immediate_uses (tree old, tree new)
stmt_ann_t ann = get_stmt_ann (old);
use_optype uses = USE_OPS (ann);
vuse_optype vuses = VUSE_OPS (ann);
- vdef_optype vdefs = VDEF_OPS (ann);
+ v_may_def_optype v_may_defs = V_MAY_DEF_OPS (ann);
unsigned int i;
/* Look at USE_OPS or VUSE_OPS according to FLAGS. */
@@ -400,8 +401,8 @@ redirect_immediate_uses (tree old, tree new)
for (i = 0; i < NUM_VUSES (vuses); i++)
redirect_immediate_use (VUSE_OP (vuses, i), old, new);
- for (i = 0; i < NUM_VDEFS (vdefs); i++)
- redirect_immediate_use (VDEF_OP (vdefs, i), old, new);
+ for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++)
+ redirect_immediate_use (V_MAY_DEF_OP (v_may_defs, i), old, new);
}
@@ -699,9 +700,14 @@ dump_dfa_stats (FILE *file)
fprintf (file, fmt_str_1, "VUSE operands", dfa_stats.num_vuses,
SCALE (size), LABEL (size));
- size = dfa_stats.num_vdefs * sizeof (tree *);
+ size = dfa_stats.num_v_may_defs * sizeof (tree *);
total += size;
- fprintf (file, fmt_str_1, "VDEF operands", dfa_stats.num_vdefs,
+ fprintf (file, fmt_str_1, "V_MAY_DEF operands", dfa_stats.num_v_may_defs,
+ SCALE (size), LABEL (size));
+
+ size = dfa_stats.num_v_must_defs * sizeof (tree *);
+ total += size;
+ fprintf (file, fmt_str_1, "V_MUST_DEF operands", dfa_stats.num_v_must_defs,
SCALE (size), LABEL (size));
size = dfa_stats.num_phis * sizeof (struct tree_phi_node);
@@ -797,8 +803,11 @@ collect_dfa_stats_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
dfa_stats_p->num_stmt_anns++;
dfa_stats_p->num_defs += NUM_DEFS (DEF_OPS (ann));
dfa_stats_p->num_uses += NUM_USES (USE_OPS (ann));
- dfa_stats_p->num_vdefs += NUM_VDEFS (VDEF_OPS (ann));
+ dfa_stats_p->num_v_may_defs +=
+ NUM_V_MAY_DEFS (V_MAY_DEF_OPS (ann));
dfa_stats_p->num_vuses += NUM_VUSES (VUSE_OPS (ann));
+ dfa_stats_p->num_v_must_defs +=
+ NUM_V_MUST_DEFS (V_MUST_DEF_OPS (ann));
break;
}
@@ -1012,21 +1021,43 @@ add_referenced_tmp_var (tree var)
add_referenced_var (var, NULL);
}
+/* Return true if V_MAY_DEFS_AFTER contains fewer entries than
+ V_MAY_DEFS_BEFORE. Note that this assumes that both varrays
+ are V_MAY_DEF operands for the same statement. */
+
+static inline bool
+v_may_defs_disappeared_p (v_may_def_optype v_may_defs_before,
+ v_may_def_optype v_may_defs_after)
+{
+ /* If there was nothing before, nothing could've disappeared. */
+ if (v_may_defs_before == NULL)
+ return false;
+
+ /* All/some of them gone. */
+ if (v_may_defs_after == NULL
+ || NUM_V_MAY_DEFS (v_may_defs_before) >
+ NUM_V_MAY_DEFS (v_may_defs_after))
+ return true;
+
+ return false;
+}
-/* Return true if VDEFS_AFTER contains fewer entries than VDEFS_BEFORE.
- Note that this assumes that both varrays are VDEF operands for the same
- statement. */
+/* Return true if V_MUST_DEFS_AFTER contains fewer entries than
+ V_MUST_DEFS_BEFORE. Note that this assumes that both varrays
+ are V_MUST_DEF operands for the same statement. */
static inline bool
-vdefs_disappeared_p (vdef_optype vdefs_before, vdef_optype vdefs_after)
+v_must_defs_disappeared_p (v_must_def_optype v_must_defs_before,
+ v_must_def_optype v_must_defs_after)
{
/* If there was nothing before, nothing could've disappeared. */
- if (vdefs_before == NULL)
+ if (v_must_defs_before == NULL)
return false;
/* All/some of them gone. */
- if (vdefs_after == NULL
- || NUM_VDEFS (vdefs_before) > NUM_VDEFS (vdefs_after))
+ if (v_must_defs_after == NULL
+ || NUM_V_MUST_DEFS (v_must_defs_before) >
+ NUM_V_MUST_DEFS (v_must_defs_after))
return true;
return false;
@@ -1041,12 +1072,14 @@ mark_new_vars_to_rename (tree stmt, bitmap vars_to_rename)
{
def_optype defs;
use_optype uses;
- vdef_optype vdefs;
+ v_may_def_optype v_may_defs;
vuse_optype vuses;
+ v_must_def_optype v_must_defs;
size_t i;
bitmap vars_in_vops_to_rename;
bool found_exposed_symbol = false;
- vdef_optype vdefs_before, vdefs_after;
+ v_may_def_optype v_may_defs_before, v_may_defs_after;
+ v_must_def_optype v_must_defs_before, v_must_defs_after;
stmt_ann_t ann;
vars_in_vops_to_rename = BITMAP_XMALLOC ();
@@ -1061,10 +1094,10 @@ mark_new_vars_to_rename (tree stmt, bitmap vars_to_rename)
rename them if there are not any newly exposed symbols in the
statement operands. */
ann = stmt_ann (stmt);
- vdefs_before = vdefs = VDEF_OPS (ann);
- for (i = 0; i < NUM_VDEFS (vdefs); i++)
+ v_may_defs_before = v_may_defs = V_MAY_DEF_OPS (ann);
+ for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++)
{
- tree var = VDEF_RESULT (vdefs, i);
+ tree var = V_MAY_DEF_RESULT (v_may_defs, i);
if (!DECL_P (var))
var = SSA_NAME_VAR (var);
bitmap_set_bit (vars_in_vops_to_rename, var_ann (var)->uid);
@@ -1079,6 +1112,15 @@ mark_new_vars_to_rename (tree stmt, bitmap vars_to_rename)
bitmap_set_bit (vars_in_vops_to_rename, var_ann (var)->uid);
}
+ v_must_defs_before = v_must_defs = V_MUST_DEF_OPS (ann);
+ for (i = 0; i < NUM_V_MUST_DEFS (v_must_defs); i++)
+ {
+ tree var = V_MUST_DEF_OP (v_must_defs, i);
+ if (!DECL_P (var))
+ var = SSA_NAME_VAR (var);
+ bitmap_set_bit (vars_in_vops_to_rename, var_ann (var)->uid);
+ }
+
/* Now force an operand re-scan on the statement and mark any newly
exposed variables. */
modify_stmt (stmt);
@@ -1106,10 +1148,10 @@ mark_new_vars_to_rename (tree stmt, bitmap vars_to_rename)
}
}
- vdefs_after = vdefs = VDEF_OPS (ann);
- for (i = 0; i < NUM_VDEFS (vdefs); i++)
+ v_may_defs_after = v_may_defs = V_MAY_DEF_OPS (ann);
+ for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++)
{
- tree var = VDEF_RESULT (vdefs, i);
+ tree var = V_MAY_DEF_RESULT (v_may_defs, i);
if (DECL_P (var))
{
found_exposed_symbol = true;
@@ -1127,6 +1169,17 @@ mark_new_vars_to_rename (tree stmt, bitmap vars_to_rename)
bitmap_set_bit (vars_to_rename, var_ann (var)->uid);
}
}
+
+ v_must_defs_after = v_must_defs = V_MUST_DEF_OPS (ann);
+ for (i = 0; i < NUM_V_MUST_DEFS (v_must_defs); i++)
+ {
+ tree var = V_MUST_DEF_OP (v_must_defs, i);
+ if (DECL_P (var))
+ {
+ found_exposed_symbol = true;
+ bitmap_set_bit (vars_to_rename, var_ann (var)->uid);
+ }
+ }
/* If we found any newly exposed symbols, or if there are fewer VDEF
operands in the statement, add the variables we had set in
@@ -1134,7 +1187,8 @@ mark_new_vars_to_rename (tree stmt, bitmap vars_to_rename)
vanishing VDEFs because in those cases, the names that were formerly
generated by this statement are not going to be available anymore. */
if (found_exposed_symbol
- || vdefs_disappeared_p (vdefs_before, vdefs_after))
+ || v_may_defs_disappeared_p (v_may_defs_before, v_may_defs_after)
+ || v_must_defs_disappeared_p (v_must_defs_before, v_must_defs_after))
bitmap_a_or_b (vars_to_rename, vars_to_rename, vars_in_vops_to_rename);
BITMAP_XFREE (vars_in_vops_to_rename);