diff options
author | amacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-08-25 21:21:19 +0000 |
---|---|---|
committer | amacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-08-25 21:21:19 +0000 |
commit | 43daa21e7c3b20f510ed5e16e2aef1b806d69d2b (patch) | |
tree | 22414e194e2c3d5262c72554997d72332edaa89c /gcc/tree-ssa-ccp.c | |
parent | dc5fda0ed00721c5c3c4d23e13ba4be8897c4c20 (diff) | |
download | gcc-43daa21e7c3b20f510ed5e16e2aef1b806d69d2b.tar.gz |
2004-08-25 Andrew MacLeod <amacleod@redhat.com>
* tree-ssa-operands.h (struct ssa_operand_iterator_d): New. SSA operand
iterator controlling structure.
(SSA_OP_USE, SSA_OP_DEF, SSA_OP_VUSE, SSA_OP_VMAYUSE, SSA_OP_VMAYDEF,
SSA_OP_VMUSTDEF, SSA_OP_VIRTUAL_USES, SSA_OP_VIRTUAL_DEFS,
SSA_OP_ALL_USES, SSA_OP_ALL_DEFS, SSA_OP_ALL_OPERANDS): New. Operand
iterator flags.
(FOR_EACH_SSA_TREE_OPERAND): New. Iterate over operands as trees.
(FOR_EACH_SSA_USE_OPERAND): New. Iterate over operands as uses.
(FOR_EACH_SSA_DEF_OPERAND): New. Iterate over operands as defs.
(FOR_EACH_SSA_MAYDEF_OPERAND): New. Iterate over V_MAY_DEFs.
* tree-ssa-operands.c (NULL_DEF_OPERAND_P, NULL_USE_OPERAND_P): New.
Empty operand pointers.
* tree-flow-inline.h (op_iter_done): New. Return true if finished.
(op_iter_next_use): New. Return next use_operand_p.
(op_iter_next_def): New. Return next def_operand_p.
(op_iter_next_tree): New. Return next operands as a tree.
(op_iter_init): New. Initialize an iterator structure.
(op_iter_init_use): New. Initialize structure and get the first use.
(op_iter_init_def): New. Initialize structure and get the first def.
(op_iter_init_tree): New. Initialize structure and get the first tree.
(op_iter_next_maydef): New. Return next V_MAY_DEF operands.
(op_iter_init_maydef): New. Initialize structure and get the first
V_MAY_DEF operands.
* tree-cfg.c (tree_duplicate_bb): Use new operand iterator.
* tree-dfa.c (compute_immediate_uses_for_stmt,
redirect_immediate_uses): Use new operand iterator.
(v_may_defs_disappeared_p, v_must_defs_disappeared_p): Delete.
(mark_new_vars_to_rename): Use new operand iterator. Count virtual
operands instead of using *_disappeared_p routines.
* tree-into-ssa.c (mark_def_sites, ssa_mark_def_sites, rewrite_stmt,
ssa_rewrite_stmt): Use new operand iterator.
* tree-outof-ssa.c (check_replaceable, find_replaceable_in_bb,
rewrite_trees): Use new operand iterator.
* tree-pretty-print.c (dump_vops): Use new operand iterator.
* tree-sra.c (mark_all_v_defs): Use new operand iterator.
* tree-ssa-alias.c (compute_points_to_and_addr_escape,
dump_points_to_info): Use new operand iterator.
* tree-ssa-ccp.c (cp_lattice_meet, visit_stmt, initialize,
replace_uses_in, replace_vuse_in, likely_value, set_rhs): Use new
operand iterator.
* tree-ssa-dce.c (mark_stmt_if_obviously_necessary,
propagate_necessity): Use new operand iterator.
* tree-ssa-dom.c (cprop_into_stmt, optimize_stmt): Use operand iterator.
(register_definitions_for_stmt): Use new operand iterator. Take stmt as
a parameter instead of a stmt_ann_t.
* tree-ssa-live.c (create_ssa_var_map, calculate_live_on_entry,
build_tree_conflict_graph): Use new operand iterator.
* tree-ssa-loop-im.c (determine_max_movement, single_reachable_address,
rewrite_mem_refs): Use new operand iterator.
* tree-ssa-loop-manip.c (find_uses_to_rename_stmt,
check_loop_closed_ssa_use): Use new operand iterator.
* tree-ssa.c (verify_ssa, replace_immediate_uses): Use operand iterator.
* tree-ssanames.c (release_defs): Use new operand iterator.
* tree-vectorizer.c (vect_create_data_ref): Use new operand iterator.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86583 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 91 |
1 files changed, 25 insertions, 66 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index f8f2ba504bb..bffc888fc0e 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -644,11 +644,11 @@ cp_lattice_meet (value val1, value val2) static void visit_stmt (tree stmt) { - size_t i; stmt_ann_t ann; - def_optype defs; v_may_def_optype v_may_defs; v_must_def_optype v_must_defs; + tree def; + ssa_op_iter iter; /* If the statement has already been deemed to be VARYING, don't simulate it again. */ @@ -684,12 +684,11 @@ visit_stmt (tree stmt) /* Definitions made by statements other than assignments to SSA_NAMEs represent unknown modifications to their outputs. Mark them VARYING. */ - else if (NUM_DEFS (defs = DEF_OPS (ann)) != 0) + else if (NUM_DEFS (DEF_OPS (ann)) != 0) { DONT_SIMULATE_AGAIN (stmt) = 1; - for (i = 0; i < NUM_DEFS (defs); i++) + FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF) { - tree def = DEF_OP (defs, i); def_to_varying (def); } } @@ -712,9 +711,8 @@ visit_stmt (tree stmt) } /* Mark all V_MAY_DEF operands VARYING. */ - v_may_defs = V_MAY_DEF_OPS (ann); - for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++) - def_to_varying (V_MAY_DEF_RESULT (v_may_defs, i)); + FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_VMAYDEF) + def_to_varying (def); } @@ -1187,6 +1185,8 @@ initialize (void) edge e; basic_block bb; sbitmap virtual_var; + tree def; + ssa_op_iter iter; /* Worklists of SSA edges. */ VARRAY_TREE_INIT (ssa_edges, 20, "ssa_edges"); @@ -1211,11 +1211,6 @@ initialize (void) { block_stmt_iterator i; tree stmt; - stmt_ann_t ann; - def_optype defs; - v_may_def_optype v_may_defs; - v_must_def_optype v_must_defs; - size_t x; int vary; /* Get the default value for each definition. */ @@ -1224,33 +1219,22 @@ initialize (void) vary = 0; stmt = bsi_stmt (i); get_stmt_operands (stmt); - ann = stmt_ann (stmt); - defs = DEF_OPS (ann); - for (x = 0; x < NUM_DEFS (defs); x++) + + /* Get the default value for each DEF and V_MUST_DEF. */ + FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, + (SSA_OP_DEF | SSA_OP_VMUSTDEF)) { - tree def = DEF_OP (defs, x); if (get_value (def)->lattice_val == VARYING) vary = 1; } - /* Get the default value for each V_MUST_DEF. */ - v_must_defs = V_MUST_DEF_OPS (ann); - for (x = 0; x < NUM_V_MUST_DEFS (v_must_defs); x++) - { - tree v_must_def = V_MUST_DEF_OP (v_must_defs, x); - if (get_value (v_must_def)->lattice_val == VARYING) - vary = 1; - } - DONT_SIMULATE_AGAIN (stmt) = vary; /* Mark all V_MAY_DEF operands VARYING. */ - v_may_defs = V_MAY_DEF_OPS (ann); - for (x = 0; x < NUM_V_MAY_DEFS (v_may_defs); x++) + FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_VMAYDEF) { - tree res = V_MAY_DEF_RESULT (v_may_defs, x); - get_value (res)->lattice_val = VARYING; - SET_BIT (virtual_var, SSA_NAME_VERSION (res)); + get_value (def)->lattice_val = VARYING; + SET_BIT (virtual_var, SSA_NAME_VERSION (def)); } } @@ -1494,18 +1478,16 @@ static bool replace_uses_in (tree stmt, bool *replaced_addresses_p) { bool replaced = false; - use_optype uses; - size_t i; + use_operand_p use; + ssa_op_iter iter; if (replaced_addresses_p) *replaced_addresses_p = false; get_stmt_operands (stmt); - uses = STMT_USE_OPS (stmt); - for (i = 0; i < NUM_USES (uses); i++) + FOR_EACH_SSA_USE_OPERAND (use, stmt, iter, SSA_OP_USE) { - use_operand_p use = USE_OP_PTR (uses, i); value *val = get_value (USE_FROM_PTR (use)); if (val->lattice_val == CONSTANT) @@ -1575,11 +1557,11 @@ replace_vuse_in (tree stmt, bool *replaced_addresses_p) static latticevalue likely_value (tree stmt) { - use_optype uses; vuse_optype vuses; - size_t i; int found_constant = 0; stmt_ann_t ann; + tree use; + ssa_op_iter iter; /* If the statement makes aliased loads or has volatile operands, it won't fold to a constant value. */ @@ -1594,10 +1576,8 @@ likely_value (tree stmt) get_stmt_operands (stmt); - uses = USE_OPS (ann); - for (i = 0; i < NUM_USES (uses); i++) + FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE) { - tree use = USE_OP (uses, i); value *val = get_value (use); if (val->lattice_val == UNDEFINED) @@ -1627,7 +1607,7 @@ likely_value (tree stmt) found_constant = 1; } - return ((found_constant || (!uses && !vuses)) ? CONSTANT : VARYING); + return ((found_constant || (!USE_OPS (ann) && !vuses)) ? CONSTANT : VARYING); } /* A subroutine of fold_stmt_r. Attempts to fold *(A+O) to A[X]. @@ -2266,6 +2246,8 @@ set_rhs (tree *stmt_p, tree expr) tree stmt = *stmt_p, op; enum tree_code code = TREE_CODE (expr); stmt_ann_t ann; + tree var; + ssa_op_iter iter; /* Verify the constant folded result is valid gimple. */ if (TREE_CODE_CLASS (code) == '2') @@ -2321,33 +2303,10 @@ set_rhs (tree *stmt_p, tree expr) if (TREE_SIDE_EFFECTS (expr)) { - def_optype defs; - v_may_def_optype v_may_defs; - v_must_def_optype v_must_defs; - size_t i; - /* Fix all the SSA_NAMEs created by *STMT_P to point to its new replacement. */ - defs = DEF_OPS (ann); - for (i = 0; i < NUM_DEFS (defs); i++) - { - tree var = DEF_OP (defs, i); - if (TREE_CODE (var) == SSA_NAME) - SSA_NAME_DEF_STMT (var) = *stmt_p; - } - - v_may_defs = V_MAY_DEF_OPS (ann); - for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++) - { - tree var = V_MAY_DEF_RESULT (v_may_defs, i); - if (TREE_CODE (var) == SSA_NAME) - SSA_NAME_DEF_STMT (var) = *stmt_p; - } - - v_must_defs = V_MUST_DEF_OPS (ann); - for (i = 0; i < NUM_V_MUST_DEFS (v_must_defs); i++) + FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_ALL_DEFS) { - tree var = V_MUST_DEF_OP (v_must_defs, i); if (TREE_CODE (var) == SSA_NAME) SSA_NAME_DEF_STMT (var) = *stmt_p; } |