static void alloc_pre_mem PROTO ((int, int));
static void free_pre_mem PROTO ((void));
static void compute_pre_data PROTO ((void));
-static int pre_expr_reaches_here_p PROTO ((int, struct expr *,
- int, int));
+static int pre_expr_reaches_here_p PROTO ((int, struct expr *, int));
static void insert_insn_end_bb PROTO ((struct expr *, int, int));
static void pre_insert_copy_insn PROTO ((struct expr *, rtx));
static void pre_insert_copies PROTO ((void));
static rtx process_insert_insn PROTO ((struct expr *));
static int pre_edge_insert PROTO ((struct edge_list *, struct expr **));
static int expr_reaches_here_p_work PROTO ((struct occr *, struct expr *, int, int, char *));
-static int pre_expr_reaches_here_p_work PROTO ((int, struct expr *, int, int, char *));
+static int pre_expr_reaches_here_p_work PROTO ((int, struct expr *,
+ int, char *));
\f
/* Entry point for global common subexpression elimination.
F is the first instruction in the function. */
VISITED is a pointer to a working buffer for tracking which BB's have
been visited. It is NULL for the top-level call.
- CHECK_PRE_COMP controls whether or not we check for a computation of
- EXPR in OCCR_BB.
-
We treat reaching expressions that go through blocks containing the same
reaching expression as "not reaching". E.g. if EXPR is generated in blocks
2 and 3, INSN is in block 4, and 2->3->4, we treat the expression in block
the closest such expression. */
static int
-pre_expr_reaches_here_p_work (occr_bb, expr, bb, check_pre_comp, visited)
+pre_expr_reaches_here_p_work (occr_bb, expr, bb, visited)
int occr_bb;
struct expr *expr;
int bb;
- int check_pre_comp;
char *visited;
{
edge pred;
/* Nothing to do. */
}
/* Does this predecessor generate this expression? */
- else if ((!check_pre_comp && occr_bb == pred_bb)
- || TEST_BIT (comp[pred_bb], expr->bitmap_index))
+ else if (TEST_BIT (comp[pred_bb], expr->bitmap_index))
{
/* Is this the occurrence we're looking for?
Note that there's only one generating occurrence per block
else
{
visited[pred_bb] = 1;
- if (pre_expr_reaches_here_p_work (occr_bb, expr, pred_bb,
- check_pre_comp, visited))
+ if (pre_expr_reaches_here_p_work (occr_bb, expr, pred_bb, visited))
return 1;
}
}
memory allocated for that function is returned. */
static int
-pre_expr_reaches_here_p (occr_bb, expr, bb, check_pre_comp)
+pre_expr_reaches_here_p (occr_bb, expr, bb)
int occr_bb;
struct expr *expr;
int bb;
- int check_pre_comp;
{
int rval;
char * visited = (char *) xcalloc (n_basic_blocks, 1);
- rval = pre_expr_reaches_here_p_work(occr_bb, expr, bb, check_pre_comp,
- visited);
+ rval = pre_expr_reaches_here_p_work(occr_bb, expr, bb, visited);
free (visited);
/* Insert this expression on this edge if if it would
reach the deleted occurence in BB. */
- if (!TEST_BIT (inserted[e], j)
- && (bb == ENTRY_BLOCK
- || pre_expr_reaches_here_p (bb, expr,
- BLOCK_NUM (occr->insn), 0)))
+ if (!TEST_BIT (inserted[e], j))
{
rtx insn;
edge eg = INDEX_EDGE (edge_list, e);
continue;
/* Or if the expression doesn't reach the deleted one. */
if (! pre_expr_reaches_here_p (BLOCK_NUM (avail->insn), expr,
- BLOCK_NUM (occr->insn),1))
+ BLOCK_NUM (occr->insn)))
continue;
/* Copy the result of avail to reaching_reg. */
of the optimistic edge. That will requeue the affected blocks. */
sbitmap_vector_ones (later, num_edges);
+ /* Note that even though we want an optimistic setting of LATER, we
+ do not want to be overly optimistic. Consider an outgoing edge from
+ the entry block. That edge should always have a LATER value the
+ same as EARLIEST for that edge. */
+ for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+ sbitmap_copy (later[(int)e->aux], earliest[(int)e->aux]);
+
/* Add all the blocks to the worklist. This prevents an early exit from
the loop given our optimistic initialization of LATER above. */
for (bb = n_basic_blocks - 1; bb >= 0; bb--)
/* We want a maximal solution. */
sbitmap_vector_ones (nearer, num_edges);
+ /* Note that even though we want an optimistic setting of NEARER, we
+ do not want to be overly optimistic. Consider an incoming edge to
+ the exit block. That edge should always have a NEARER value the
+ same as FARTHEST for that edge. */
+ for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+ sbitmap_copy (nearer[(int)e->aux], farthest[(int)e->aux]);
+
/* Add all the blocks to the worklist. This prevents an early exit
from the loop given our optimistic initialization of NEARER. */
for (bb = 0; bb < n_basic_blocks; bb++)