This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
minor tree-ssa-propagate cleanup
- From: Steven Bosscher <stevenb at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dnovillo at redhat dot com
- Date: Sun, 26 Sep 2004 22:25:07 +0200
- Subject: minor tree-ssa-propagate cleanup
- Organization: SUSE Labs
This patch turns two varrays into VEC(tree)'s, and one redundant
runtime check into an assert.
Bootstrapped on {powerpc,x86_64}-unknown-linux-gnu. OK?
Gr.
Steven
* Makefile.in (tree-ssa-propagate.o): Depend on vec.h.
* tree-ssa-propagate.c: Include vec.h.
(interesting_ssa_edges, varying_ssa_edges): Make these VECs
instead of varrays.
(cfg_blocks_add): Assert the block is not already in the worklist.
Update uses of interesting_ssa_edges and varying_ssa_edges.
(process_ssa_edge_worklist, ssa_prop_init, ssa_prop_fini,
ssa_propagate): Likewise.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1401
diff -c -3 -p -r1.1401 Makefile.in
*** Makefile.in 24 Sep 2004 00:37:01 -0000 1.1401
--- Makefile.in 26 Sep 2004 20:16:50 -0000
*************** tree-ssa-propagate.o : tree-ssa-propagat
*** 1632,1638 ****
$(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) tree-pass.h langhooks.h \
! tree-ssa-propagate.h
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) \
--- 1632,1638 ----
$(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) tree-pass.h langhooks.h \
! tree-ssa-propagate.h vec.h
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) \
Index: tree-ssa-propagate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-propagate.c,v
retrieving revision 2.6
diff -c -3 -p -r2.6 tree-ssa-propagate.c
*** tree-ssa-propagate.c 23 Sep 2004 21:03:04 -0000 2.6
--- tree-ssa-propagate.c 26 Sep 2004 20:16:50 -0000
***************
*** 40,46 ****
#include "tree-pass.h"
#include "tree-ssa-propagate.h"
#include "langhooks.h"
!
/* This file implements a generic value propagation engine based on
the same propagation used by the SSA-CCP algorithm [1].
--- 40,47 ----
#include "tree-pass.h"
#include "tree-ssa-propagate.h"
#include "langhooks.h"
! #include "varray.h"
! #include "vec.h"
/* This file implements a generic value propagation engine based on
the same propagation used by the SSA-CCP algorithm [1].
*************** static sbitmap bb_in_list;
*** 142,148 ****
definition has changed. SSA edges are def-use edges in the SSA
web. For each D-U edge, we store the target statement or PHI node
U. */
! static GTY(()) varray_type interesting_ssa_edges;
/* Identical to INTERESTING_SSA_EDGES. For performance reasons, the
list of SSA edges is split into two. One contains all SSA edges
--- 143,149 ----
definition has changed. SSA edges are def-use edges in the SSA
web. For each D-U edge, we store the target statement or PHI node
U. */
! static GTY(()) VEC(tree) *interesting_ssa_edges;
/* Identical to INTERESTING_SSA_EDGES. For performance reasons, the
list of SSA edges is split into two. One contains all SSA edges
*************** static GTY(()) varray_type interesting_s
*** 158,164 ****
don't use a separate worklist for VARYING edges, we end up with
situations where lattice values move from
UNDEFINED->INTERESTING->VARYING instead of UNDEFINED->VARYING. */
! static GTY(()) varray_type varying_ssa_edges;
/* Return true if the block worklist empty. */
--- 159,165 ----
don't use a separate worklist for VARYING edges, we end up with
situations where lattice values move from
UNDEFINED->INTERESTING->VARYING instead of UNDEFINED->VARYING. */
! static GTY(()) VEC(tree) *varying_ssa_edges;
/* Return true if the block worklist empty. */
*************** cfg_blocks_empty_p (void)
*** 170,176 ****
}
! /* Add a basic block to the worklist. */
static void
cfg_blocks_add (basic_block bb)
--- 171,178 ----
}
! /* Add a basic block to the worklist. The block must not be already
! in the worklist. */
static void
cfg_blocks_add (basic_block bb)
*************** cfg_blocks_add (basic_block bb)
*** 178,185 ****
if (bb == ENTRY_BLOCK_PTR || bb == EXIT_BLOCK_PTR)
return;
! if (TEST_BIT (bb_in_list, bb->index))
! return;
if (cfg_blocks_empty_p ())
{
--- 180,186 ----
if (bb == ENTRY_BLOCK_PTR || bb == EXIT_BLOCK_PTR)
return;
! gcc_assert (!TEST_BIT (bb_in_list, bb->index));
if (cfg_blocks_empty_p ())
{
*************** add_ssa_edge (tree var, bool is_varying)
*** 247,255 ****
{
STMT_IN_SSA_EDGE_WORKLIST (use_stmt) = 1;
if (is_varying)
! VARRAY_PUSH_TREE (varying_ssa_edges, use_stmt);
else
! VARRAY_PUSH_TREE (interesting_ssa_edges, use_stmt);
}
}
}
--- 248,256 ----
{
STMT_IN_SSA_EDGE_WORKLIST (use_stmt) = 1;
if (is_varying)
! VEC_safe_push (tree, varying_ssa_edges, use_stmt);
else
! VEC_safe_push (tree, interesting_ssa_edges, use_stmt);
}
}
}
*************** simulate_stmt (tree stmt)
*** 339,357 ****
/* Process an SSA edge worklist. WORKLIST is the SSA edge worklist to
drain. This pops statements off the given WORKLIST and processes
! them until there are no more statements on WORKLIST. */
static void
! process_ssa_edge_worklist (varray_type *worklist)
{
/* Drain the entire worklist. */
! while (VARRAY_ACTIVE_SIZE (*worklist) > 0)
{
basic_block bb;
/* Pull the statement to simulate off the worklist. */
! tree stmt = VARRAY_TOP_TREE (*worklist);
! VARRAY_POP (*worklist);
/* If this statement was already visited by simulate_block, then
we don't need to visit it again here. */
--- 340,359 ----
/* Process an SSA edge worklist. WORKLIST is the SSA edge worklist to
drain. This pops statements off the given WORKLIST and processes
! them until there are no more statements on WORKLIST.
! We take a pointer to WORKLIST because it may be reallocated when an
! SSA edge is added to it in simulate_stmt. */
static void
! process_ssa_edge_worklist (VEC(tree) **worklist)
{
/* Drain the entire worklist. */
! while (VEC_length (tree, *worklist) > 0)
{
basic_block bb;
/* Pull the statement to simulate off the worklist. */
! tree stmt = VEC_pop (tree, *worklist);
/* If this statement was already visited by simulate_block, then
we don't need to visit it again here. */
*************** ssa_prop_init (void)
*** 460,467 ****
basic_block bb;
/* Worklists of SSA edges. */
! VARRAY_TREE_INIT (interesting_ssa_edges, 20, "interesting_ssa_edges");
! VARRAY_TREE_INIT (varying_ssa_edges, 20, "varying_ssa_edges");
executable_blocks = sbitmap_alloc (last_basic_block);
sbitmap_zero (executable_blocks);
--- 462,469 ----
basic_block bb;
/* Worklists of SSA edges. */
! interesting_ssa_edges = VEC_alloc (tree, 20);
! varying_ssa_edges = VEC_alloc (tree, 20);
executable_blocks = sbitmap_alloc (last_basic_block);
sbitmap_zero (executable_blocks);
*************** ssa_prop_init (void)
*** 504,511 ****
static void
ssa_prop_fini (void)
{
! interesting_ssa_edges = NULL;
! varying_ssa_edges = NULL;
cfg_blocks = NULL;
sbitmap_free (bb_in_list);
sbitmap_free (executable_blocks);
--- 506,513 ----
static void
ssa_prop_fini (void)
{
! VEC_free (tree, interesting_ssa_edges);
! VEC_free (tree, varying_ssa_edges);
cfg_blocks = NULL;
sbitmap_free (bb_in_list);
sbitmap_free (executable_blocks);
*************** ssa_propagate (ssa_prop_visit_stmt_fn vi
*** 650,657 ****
/* Iterate until the worklists are empty. */
while (!cfg_blocks_empty_p ()
! || VARRAY_ACTIVE_SIZE (interesting_ssa_edges) > 0
! || VARRAY_ACTIVE_SIZE (varying_ssa_edges) > 0)
{
if (!cfg_blocks_empty_p ())
{
--- 652,659 ----
/* Iterate until the worklists are empty. */
while (!cfg_blocks_empty_p ()
! || VEC_length (tree, interesting_ssa_edges) > 0
! || VEC_length (tree, varying_ssa_edges) > 0)
{
if (!cfg_blocks_empty_p ())
{