aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-operands.c
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2006-04-27 20:22:17 +0000
committerAndrew Macleod <amacleod@gcc.gnu.org>2006-04-27 20:22:17 +0000
commit6c00f606c162459e5cc17a9c3f2474314df7071b (patch)
tree39c9b1002df8b0cd95dd8e90404343ea80786b25 /gcc/tree-ssa-operands.c
parent8fcd79cbcdf931c4875a6863fe47482224b1f03d (diff)
downloadgcc-6c00f606c162459e5cc17a9c3f2474314df7071b.zip
gcc-6c00f606c162459e5cc17a9c3f2474314df7071b.tar.gz
gcc-6c00f606c162459e5cc17a9c3f2474314df7071b.tar.bz2
Implement new immediate use iterators.
2006-04-27 Andrew MacLeod <amacleod@redhat.com> PR tree-optimization/26854 * tree-vrp.c (remove_range_assertions): Use new Immuse iterator. * doc/tree-ssa.texi: Update immuse iterator documentation. * tree-ssa-math-opts.c (execute_cse_reciprocals_1): Use new iterator. * tree-ssa-dom.c (propagate_rhs_into_lhs): Use new iterator. * tree-flow-inline.h (end_safe_imm_use_traverse, end_safe_imm_use_p, first_safe_imm_use, next_safe_imm_use): Remove. (end_imm_use_stmt_p): New. Check for end of immuse stmt traversal. (end_imm_use_stmt_traverse): New. Terminate immuse stmt traversal. (move_use_after_head): New. Helper function to sort immuses in a stmt. (link_use_stmts_after): New. Link all immuses in a stmt consescutively. (first_imm_use_stmt): New. Get first stmt in an immuse list. (next_imm_use_stmt): New. Get next stmt in an immuse list. (first_imm_use_on_stmt): New. Get first immuse on a stmt. (end_imm_use_on_stmt_p): New. Check for end of immuses on a stmt. (next_imm_use_on_stmt): New. Move to next immuse on a stmt. * tree-ssa-forwprop.c (forward_propagate_addr_expr): Use new iterator. * lambda-code.c (lambda_loopnest_to_gcc_loopnest): Use new iterator. (perfect_nestify): Use new iterator. * tree-vect-transform.c (vect_create_epilog_for_reduction): Use new iterator. * tree-flow.h (struct immediate_use_iterator_d): Add comments. (next_imm_name): New field in struct immediate_use_iterator_d. (FOR_EACH_IMM_USE_SAFE, BREAK_FROM_SAFE_IMM_USE): Remove. (FOR_EACH_IMM_USE_STMT, BREAK_FROM_IMM_USE_STMT, FOR_EACH_IMM_USE_ON_STMT): New immediate use iterator macros. * tree-cfg.c (replace_uses_by): Use new iterator. * tree-ssa-threadedge.c (lhs_of_dominating_assert): Use new iterator. * tree-ssa-operands.c (correct_use_link): Remove. (finalize_ssa_use_ops): No longer call correct_use_link. From-SVN: r113321
Diffstat (limited to 'gcc/tree-ssa-operands.c')
-rw-r--r--gcc/tree-ssa-operands.c86
1 files changed, 8 insertions, 78 deletions
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index 7ef0647..e979b4c 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -325,49 +325,9 @@ ssa_operand_alloc (unsigned size)
}
-/* Make sure PTR is in the correct immediate use list. Since uses are simply
- pointers into the stmt TREE, there is no way of telling if anyone has
- changed what this pointer points to via TREE_OPERANDS (exp, 0) = <...>.
- The contents are different, but the pointer is still the same. This
- routine will check to make sure PTR is in the correct list, and if it isn't
- put it in the correct list. We cannot simply check the previous node
- because all nodes in the same stmt might have be changed. */
-
-static inline void
-correct_use_link (use_operand_p ptr, tree stmt)
-{
- use_operand_p prev;
- tree root;
-
- /* fold_stmt may have changed the stmt pointers. */
- if (ptr->stmt != stmt)
- ptr->stmt = stmt;
-
- prev = ptr->prev;
- if (prev)
- {
- /* Find the root element, making sure we skip any safe iterators. */
- while (prev->use != NULL || prev->stmt == NULL)
- prev = prev->prev;
-
- /* Get the SSA_NAME of the list the node is in. */
- root = prev->stmt;
-
- /* If it's the right list, simply return. */
- if (root == *(ptr->use))
- return;
- }
-
- /* It is in the wrong list if we reach here. */
- delink_imm_use (ptr);
- link_imm_use (ptr, *(ptr->use));
-}
-
/* This routine makes sure that PTR is in an immediate use list, and makes
- sure the stmt pointer is set to the current stmt. Virtual uses do not need
- the overhead of correct_use_link since they cannot be directly manipulated
- like a real use can be. (They don't exist in the TREE_OPERAND nodes.) */
+ sure the stmt pointer is set to the current stmt. */
static inline void
set_virtual_use_link (use_operand_p ptr, tree stmt)
@@ -579,9 +539,7 @@ finalize_ssa_defs (tree stmt)
}
/* Takes elements from build_uses and turns them into use operands of STMT.
- TODO -- Given that use operands list is not necessarily sorted, merging
- the operands this way does not make much sense.
- -- Make build_uses VEC of tree *. */
+ TODO -- Make build_uses VEC of tree *. */
static inline void
finalize_ssa_use_ops (tree stmt)
@@ -589,46 +547,12 @@ finalize_ssa_use_ops (tree stmt)
unsigned new_i;
struct use_optype_d new_list;
use_optype_p old_ops, ptr, last;
- tree *old_base, *new_base;
new_list.next = NULL;
last = &new_list;
old_ops = USE_OPS (stmt);
- new_i = 0;
- while (old_ops && new_i < VEC_length (tree, build_uses))
- {
- new_base = (tree *) VEC_index (tree, build_uses, new_i);
- old_base = USE_OP_PTR (old_ops)->use;
-
- if (old_base == new_base)
- {
- /* if variables are the same, reuse this node. */
- MOVE_HEAD_AFTER (old_ops, last);
- correct_use_link (USE_OP_PTR (last), stmt);
- new_i++;
- }
- else if (old_base < new_base)
- {
- /* if old is less than new, old goes to the free list. */
- delink_imm_use (USE_OP_PTR (old_ops));
- MOVE_HEAD_TO_FREELIST (old_ops, use);
- }
- else
- {
- /* This is a new operand. */
- add_use_op (stmt, new_base, &last);
- new_i++;
- }
- }
-
- /* If there is anything remaining in the build_uses list, simply emit it. */
- for ( ; new_i < VEC_length (tree, build_uses); new_i++)
- add_use_op (stmt, (tree *) VEC_index (tree, build_uses, new_i), &last);
-
- last->next = NULL;
-
/* If there is anything in the old list, free it. */
if (old_ops)
{
@@ -638,6 +562,12 @@ finalize_ssa_use_ops (tree stmt)
free_uses = old_ops;
}
+ /* Now create nodes for all the new nodes. */
+ for (new_i = 0; new_i < VEC_length (tree, build_uses); new_i++)
+ add_use_op (stmt, (tree *) VEC_index (tree, build_uses, new_i), &last);
+
+ last->next = NULL;
+
/* Now set the stmt's operands. */
USE_OPS (stmt) = new_list.next;