Commit 1b2fe7d3 by Jeff Law Committed by Jeff Law

[PATCH] avail_exprs is no longer file scoped

	* tree-ssa-dom.c (avail_exprs): No longer file scoped.  Bury
	it into the avail_exprs_stack class.
	(pass_dominator::execute): Corresponding changes to declaration
	and initialization of avail_exprs.  Pass avail_exprs to
	dump_dominator_optimization_stats.
	(record_cond): Extract avail_exprs from avail_exprs_stack.
	(lookup_avail_expr): Similarly.
	(htab_staticstics): Remove unnecessary prototype.  Move to earlier
	position in file.
	(dump_dominator_optimization_stats): Make static and prototype.
	Add argument for the hash table to dump.
	(debug_dominator_optimization_stats): Remove.
	* tree-ssa-dom.h (dump_dominator_optimization_stats): Remove
	prototype.
	(debug_dominator_optimization_stats): Similarly.
	* tree-ssa-scopedtables.h (class avail_exprs_stack): Add missing
	"void" in prototype for pop_to_marker method.  Add accessor method
	for the underlying avail_exprs table.

	* tree-ssa-threadedge.c: Remove trailing whitespace.

From-SVN: r227921
parent 5877e54e
2015-09-18 Jeff Law <law@redhat.com>
PR tree-optimization/47679
* tree-ssa-dom.c (avail_exprs): No longer file scoped. Bury
it into the avail_exprs_stack class.
(pass_dominator::execute): Corresponding changes to declaration
and initialization of avail_exprs. Pass avail_exprs to
dump_dominator_optimization_stats.
(record_cond): Extract avail_exprs from avail_exprs_stack.
(lookup_avail_expr): Similarly.
(htab_staticstics): Remove unnecessary prototype. Move to earlier
position in file.
(dump_dominator_optimization_stats): Make static and prototype.
Add argument for the hash table to dump.
(debug_dominator_optimization_stats): Remove.
* tree-ssa-dom.h (dump_dominator_optimization_stats): Remove
prototype.
(debug_dominator_optimization_stats): Similarly.
* tree-ssa-scopedtables.h (class avail_exprs_stack): Add missing
"void" in prototype for pop_to_marker method. Add accessor method
for the underlying avail_exprs table.
* tree-ssa-threadedge.c: Remove trailing whitespace.
2014-09-18 John David Anglin <danglin@gcc.gnu.org> 2014-09-18 John David Anglin <danglin@gcc.gnu.org>
* config/pa/pa-protos.h (pa_cint_ok_for_move): Change argument type to * config/pa/pa-protos.h (pa_cint_ok_for_move): Change argument type to
...@@ -78,15 +78,6 @@ struct edge_info ...@@ -78,15 +78,6 @@ struct edge_info
vec<cond_equivalence> cond_equivalences; vec<cond_equivalence> cond_equivalences;
}; };
/* Hash table with expressions made available during the renaming process.
When an assignment of the form X_i = EXPR is found, the statement is
stored in this table. If the same expression EXPR is later found on the
RHS of another statement, it is replaced with X_i (thus performing
global redundancy elimination). Similarly as we pass through conditionals
we record the conditional itself as having either a true or false value
in this table. */
static hash_table<expr_elt_hasher> *avail_exprs;
/* Unwindable equivalences, both const/copy and expression varieties. */ /* Unwindable equivalences, both const/copy and expression varieties. */
static const_and_copies *const_and_copies; static const_and_copies *const_and_copies;
static avail_exprs_stack *avail_exprs_stack; static avail_exprs_stack *avail_exprs_stack;
...@@ -114,8 +105,6 @@ static struct opt_stats_d opt_stats; ...@@ -114,8 +105,6 @@ static struct opt_stats_d opt_stats;
/* Local functions. */ /* Local functions. */
static void optimize_stmt (basic_block, gimple_stmt_iterator); static void optimize_stmt (basic_block, gimple_stmt_iterator);
static tree lookup_avail_expr (gimple, bool); static tree lookup_avail_expr (gimple, bool);
static void htab_statistics (FILE *,
const hash_table<expr_elt_hasher> &);
static void record_cond (cond_equivalence *); static void record_cond (cond_equivalence *);
static void record_equality (tree, tree); static void record_equality (tree, tree);
static void record_equivalences_from_phis (basic_block); static void record_equivalences_from_phis (basic_block);
...@@ -123,6 +112,9 @@ static void record_equivalences_from_incoming_edge (basic_block); ...@@ -123,6 +112,9 @@ static void record_equivalences_from_incoming_edge (basic_block);
static void eliminate_redundant_computations (gimple_stmt_iterator *); static void eliminate_redundant_computations (gimple_stmt_iterator *);
static void record_equivalences_from_stmt (gimple, int); static void record_equivalences_from_stmt (gimple, int);
static edge single_incoming_edge_ignoring_loop_edges (basic_block); static edge single_incoming_edge_ignoring_loop_edges (basic_block);
static void dump_dominator_optimization_stats (FILE *file,
hash_table<expr_elt_hasher> *);
/* Free the edge_info data attached to E, if it exists. */ /* Free the edge_info data attached to E, if it exists. */
...@@ -548,7 +540,8 @@ pass_dominator::execute (function *fun) ...@@ -548,7 +540,8 @@ pass_dominator::execute (function *fun)
memset (&opt_stats, 0, sizeof (opt_stats)); memset (&opt_stats, 0, sizeof (opt_stats));
/* Create our hash tables. */ /* Create our hash tables. */
avail_exprs = new hash_table<expr_elt_hasher> (1024); hash_table<expr_elt_hasher> *avail_exprs
= new hash_table<expr_elt_hasher> (1024);
avail_exprs_stack = new class avail_exprs_stack (avail_exprs); avail_exprs_stack = new class avail_exprs_stack (avail_exprs);
const_and_copies = new class const_and_copies (); const_and_copies = new class const_and_copies ();
need_eh_cleanup = BITMAP_ALLOC (NULL); need_eh_cleanup = BITMAP_ALLOC (NULL);
...@@ -671,7 +664,7 @@ pass_dominator::execute (function *fun) ...@@ -671,7 +664,7 @@ pass_dominator::execute (function *fun)
/* Debugging dumps. */ /* Debugging dumps. */
if (dump_file && (dump_flags & TDF_STATS)) if (dump_file && (dump_flags & TDF_STATS))
dump_dominator_optimization_stats (dump_file); dump_dominator_optimization_stats (dump_file, avail_exprs);
loop_optimizer_finalize (); loop_optimizer_finalize ();
...@@ -1008,10 +1001,22 @@ record_equivalences_from_incoming_edge (basic_block bb) ...@@ -1008,10 +1001,22 @@ record_equivalences_from_incoming_edge (basic_block bb)
record_temporary_equivalences (e); record_temporary_equivalences (e);
} }
/* Dump statistics for the hash table HTAB. */
static void
htab_statistics (FILE *file, const hash_table<expr_elt_hasher> &htab)
{
fprintf (file, "size %ld, %ld elements, %f collision/search ratio\n",
(long) htab.size (),
(long) htab.elements (),
htab.collisions ());
}
/* Dump SSA statistics on FILE. */ /* Dump SSA statistics on FILE. */
void static void
dump_dominator_optimization_stats (FILE *file) dump_dominator_optimization_stats (FILE *file,
hash_table<expr_elt_hasher> *avail_exprs)
{ {
fprintf (file, "Total number of statements: %6ld\n\n", fprintf (file, "Total number of statements: %6ld\n\n",
opt_stats.num_stmts); opt_stats.num_stmts);
...@@ -1025,27 +1030,6 @@ dump_dominator_optimization_stats (FILE *file) ...@@ -1025,27 +1030,6 @@ dump_dominator_optimization_stats (FILE *file)
} }
/* Dump SSA statistics on stderr. */
DEBUG_FUNCTION void
debug_dominator_optimization_stats (void)
{
dump_dominator_optimization_stats (stderr);
}
/* Dump statistics for the hash table HTAB. */
static void
htab_statistics (FILE *file, const hash_table<expr_elt_hasher> &htab)
{
fprintf (file, "size %ld, %ld elements, %f collision/search ratio\n",
(long) htab.size (),
(long) htab.elements (),
htab.collisions ());
}
/* Enter condition equivalence into the expression hash table. /* Enter condition equivalence into the expression hash table.
This indicates that a conditional expression has a known This indicates that a conditional expression has a known
boolean value. */ boolean value. */
...@@ -1056,6 +1040,7 @@ record_cond (cond_equivalence *p) ...@@ -1056,6 +1040,7 @@ record_cond (cond_equivalence *p)
class expr_hash_elt *element = new expr_hash_elt (&p->cond, p->value); class expr_hash_elt *element = new expr_hash_elt (&p->cond, p->value);
expr_hash_elt **slot; expr_hash_elt **slot;
hash_table<expr_elt_hasher> *avail_exprs = avail_exprs_stack->avail_exprs ();
slot = avail_exprs->find_slot_with_hash (element, element->hash (), INSERT); slot = avail_exprs->find_slot_with_hash (element, element->hash (), INSERT);
if (*slot == NULL) if (*slot == NULL)
{ {
...@@ -1917,6 +1902,7 @@ lookup_avail_expr (gimple stmt, bool insert) ...@@ -1917,6 +1902,7 @@ lookup_avail_expr (gimple stmt, bool insert)
return NULL_TREE; return NULL_TREE;
/* Finally try to find the expression in the main expression hash table. */ /* Finally try to find the expression in the main expression hash table. */
hash_table<expr_elt_hasher> *avail_exprs = avail_exprs_stack->avail_exprs ();
slot = avail_exprs->find_slot (&element, (insert ? INSERT : NO_INSERT)); slot = avail_exprs->find_slot (&element, (insert ? INSERT : NO_INSERT));
if (slot == NULL) if (slot == NULL)
{ {
......
...@@ -20,8 +20,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -20,8 +20,6 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_TREE_SSA_DOM_H #ifndef GCC_TREE_SSA_DOM_H
#define GCC_TREE_SSA_DOM_H #define GCC_TREE_SSA_DOM_H
extern void dump_dominator_optimization_stats (FILE *);
extern void debug_dominator_optimization_stats (void);
extern bool simple_iv_increment_p (gimple); extern bool simple_iv_increment_p (gimple);
#endif /* GCC_TREE_SSA_DOM_H */ #endif /* GCC_TREE_SSA_DOM_H */
...@@ -122,11 +122,16 @@ class avail_exprs_stack ...@@ -122,11 +122,16 @@ class avail_exprs_stack
/* Restore the AVAIL_EXPRs table to its state when the last marker /* Restore the AVAIL_EXPRs table to its state when the last marker
was pushed. */ was pushed. */
void pop_to_marker (); void pop_to_marker (void);
/* Record a single available expression that can be unwound. */ /* Record a single available expression that can be unwound. */
void record_expr (expr_hash_elt_t, expr_hash_elt_t, char); void record_expr (expr_hash_elt_t, expr_hash_elt_t, char);
/* Get the underlying hash table. Would this be better as
class inheritance? */
hash_table<expr_elt_hasher> *avail_exprs (void)
{ return m_avail_exprs; }
private: private:
vec<std::pair<expr_hash_elt_t, expr_hash_elt_t> > m_stack; vec<std::pair<expr_hash_elt_t, expr_hash_elt_t> > m_stack;
hash_table<expr_elt_hasher> *m_avail_exprs; hash_table<expr_elt_hasher> *m_avail_exprs;
......
...@@ -94,12 +94,12 @@ potentially_threadable_block (basic_block bb) ...@@ -94,12 +94,12 @@ potentially_threadable_block (basic_block bb)
/* Special case. We can get blocks that are forwarders, but are /* Special case. We can get blocks that are forwarders, but are
not optimized away because they forward from outside a loop not optimized away because they forward from outside a loop
to the loop header. We want to thread through them as we can to the loop header. We want to thread through them as we can
sometimes thread to the loop exit, which is obviously profitable. sometimes thread to the loop exit, which is obviously profitable.
the interesting case here is when the block has PHIs. */ the interesting case here is when the block has PHIs. */
if (gsi_end_p (gsi_start_nondebug_bb (bb)) if (gsi_end_p (gsi_start_nondebug_bb (bb))
&& !gsi_end_p (gsi_start_phis (bb))) && !gsi_end_p (gsi_start_phis (bb)))
return true; return true;
/* If BB has a single successor or a single predecessor, then /* If BB has a single successor or a single predecessor, then
there is no threading opportunity. */ there is no threading opportunity. */
if (single_succ_p (bb) || single_pred_p (bb)) if (single_succ_p (bb) || single_pred_p (bb))
...@@ -148,7 +148,7 @@ lhs_of_dominating_assert (tree op, basic_block bb, gimple stmt) ...@@ -148,7 +148,7 @@ lhs_of_dominating_assert (tree op, basic_block bb, gimple stmt)
edge E. Record unwind information for the equivalences onto STACK. edge E. Record unwind information for the equivalences onto STACK.
If a PHI which prevents threading is encountered, then return FALSE If a PHI which prevents threading is encountered, then return FALSE
indicating we should not thread this edge, else return TRUE. indicating we should not thread this edge, else return TRUE.
If SRC_MAP/DST_MAP exist, then mark the source and destination SSA_NAMEs If SRC_MAP/DST_MAP exist, then mark the source and destination SSA_NAMEs
of any equivalences recorded. We use this to make invalidation after of any equivalences recorded. We use this to make invalidation after
...@@ -423,10 +423,10 @@ record_temporary_equivalences_from_stmts_at_dest (edge e, ...@@ -423,10 +423,10 @@ record_temporary_equivalences_from_stmts_at_dest (edge e,
} }
/* Record the context sensitive equivalence if we were able /* Record the context sensitive equivalence if we were able
to simplify this statement. to simplify this statement.
If we have traversed a backedge at some point during threading, If we have traversed a backedge at some point during threading,
then always enter something here. Either a real equivalence, then always enter something here. Either a real equivalence,
or a NULL_TREE equivalence which is effectively invalidation of or a NULL_TREE equivalence which is effectively invalidation of
prior equivalences. */ prior equivalences. */
if (cached_lhs if (cached_lhs
...@@ -1238,7 +1238,7 @@ thread_through_normal_block (edge e, ...@@ -1238,7 +1238,7 @@ thread_through_normal_block (edge e,
/* Second case. */ /* Second case. */
return -1; return -1;
} }
/* If we stopped at a COND_EXPR or SWITCH_EXPR, see if we know which arm /* If we stopped at a COND_EXPR or SWITCH_EXPR, see if we know which arm
will be taken. */ will be taken. */
if (gimple_code (stmt) == GIMPLE_COND if (gimple_code (stmt) == GIMPLE_COND
...@@ -1285,7 +1285,7 @@ thread_through_normal_block (edge e, ...@@ -1285,7 +1285,7 @@ thread_through_normal_block (edge e,
/* See if we can thread through DEST as well, this helps capture /* See if we can thread through DEST as well, this helps capture
secondary effects of threading without having to re-run DOM or secondary effects of threading without having to re-run DOM or
VRP. VRP.
We don't want to thread back to a block we have already We don't want to thread back to a block we have already
visited. This may be overly conservative. */ visited. This may be overly conservative. */
...@@ -1445,7 +1445,7 @@ thread_across_edge (gcond *dummy_cond, ...@@ -1445,7 +1445,7 @@ thread_across_edge (gcond *dummy_cond,
const_and_copies->push_marker (); const_and_copies->push_marker ();
if (avail_exprs_stack) if (avail_exprs_stack)
avail_exprs_stack->push_marker (); avail_exprs_stack->push_marker ();
/* Avoid threading to any block we have already visited. */ /* Avoid threading to any block we have already visited. */
bitmap_clear (visited); bitmap_clear (visited);
bitmap_set_bit (visited, e->src->index); bitmap_set_bit (visited, e->src->index);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment