minor operand cleanup
Andrew MacLeod
amacleod@redhat.com
Wed May 4 20:32:00 GMT 2005
Just a minor cleanup. Shorten/generify num_ssa_operands and add asserts
to the FOR_EACH_SSA_USE_OPERAND and FOR_EACH_SSA_DEF_OPERAND routines to
check for flags which are bogus. (ie, you can't iterate over
SSA_OP_USES in a DEF loop).
Also fix the one place in the compiler which currently triggers this
assert.
Bootstrapped on i686-pc-linux-gnu with no new regressions.
Checked in.
Andrew
2005-05-04 Andrew MacLeod <amacleod@redhat.com>
* tree-flow-inline.h (op_iter_init_use, op_iter_init_def): Assert that
the flags are of appropriate types.
(num_ssa_operands): Generalize using the generic interface.
* tree-ssa-dce.c (remove_dead_stmt): Don't ask for kills on a DEF
iterator.
Index: tree-flow-inline.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow-inline.h,v
retrieving revision 2.44
diff -c -p -r2.44 tree-flow-inline.h
*** tree-flow-inline.h 3 May 2005 12:19:37 -0000 2.44
--- tree-flow-inline.h 4 May 2005 15:32:18 -0000
*************** op_iter_init (ssa_op_iter *ptr, tree stm
*** 1005,1010 ****
--- 1005,1011 ----
static inline use_operand_p
op_iter_init_use (ssa_op_iter *ptr, tree stmt, int flags)
{
+ gcc_assert ((flags & SSA_OP_ALL_DEFS) == 0);
op_iter_init (ptr, stmt, flags);
ptr->iter_type = ssa_op_iter_use;
return op_iter_next_use (ptr);
*************** op_iter_init_use (ssa_op_iter *ptr, tree
*** 1015,1020 ****
--- 1016,1022 ----
static inline def_operand_p
op_iter_init_def (ssa_op_iter *ptr, tree stmt, int flags)
{
+ gcc_assert ((flags & (SSA_OP_ALL_USES | SSA_OP_VIRTUAL_KILLS)) == 0);
op_iter_init (ptr, stmt, flags);
ptr->iter_type = ssa_op_iter_def;
return op_iter_next_def (ptr);
*************** static inline int
*** 1175,1198 ****
num_ssa_operands (tree stmt, int flags)
{
ssa_op_iter iter;
int num = 0;
! op_iter_init (&iter, stmt, flags);
! for ( ; iter.defs; iter.defs = iter.defs->next)
num++;
- for ( ; iter.uses; iter.uses = iter.uses->next)
- num++;
- for ( ; iter.vuses; iter.vuses = iter.vuses->next)
- num++;
- for ( ; iter.maydefs; iter.maydefs = iter.maydefs->next)
- num++;
- for ( ; iter.mayuses; iter.mayuses = iter.mayuses->next)
- num++;
- for ( ; iter.mustdefs; iter.mustdefs = iter.mustdefs->next)
- num++;
- for ( ; iter.mustkills; iter.mustkills = iter.mustkills->next)
- num++;
-
return num;
}
--- 1177,1187 ----
num_ssa_operands (tree stmt, int flags)
{
ssa_op_iter iter;
+ tree t;
int num = 0;
! FOR_EACH_SSA_TREE_OPERAND (t, stmt, iter, flags)
num++;
return num;
}
Index: tree-ssa-dce.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dce.c,v
retrieving revision 2.42
diff -c -p -r2.42 tree-ssa-dce.c
*** tree-ssa-dce.c 27 Apr 2005 18:00:55 -0000 2.42
--- tree-ssa-dce.c 4 May 2005 15:32:18 -0000
*************** remove_dead_stmt (block_stmt_iterator *i
*** 769,776 ****
remove_edge (EDGE_SUCC (bb, 1));
}
! FOR_EACH_SSA_DEF_OPERAND (def_p, t, iter,
! SSA_OP_VIRTUAL_DEFS | SSA_OP_VIRTUAL_KILLS)
{
tree def = DEF_FROM_PTR (def_p);
mark_sym_for_renaming (SSA_NAME_VAR (def));
--- 769,775 ----
remove_edge (EDGE_SUCC (bb, 1));
}
! FOR_EACH_SSA_DEF_OPERAND (def_p, t, iter, SSA_OP_VIRTUAL_DEFS)
{
tree def = DEF_FROM_PTR (def_p);
mark_sym_for_renaming (SSA_NAME_VAR (def));
More information about the Gcc-patches
mailing list