This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
more gcse.c cleanup
- To: gcc-patches at gcc dot gnu dot org
- Subject: more gcse.c cleanup
- From: Andrew Macleod <amacleod at cygnus dot com>
- Date: Tue, 3 Apr 2001 21:11:47 -0700
The following patch attempts to provide some consistancy in gcse.c and
use the basic_block structure instead of ints, especially as parameters.
When gcse was first created, the basic_block structures were not present.
Now they are available, so perhaps we should use them.
Bootstrapped and checked on an x86 linux box.
Andrew
2001-04-04 Andrew MacLeod <amacleod@redhat.com>
* gcse.c (oprs_unchanged_p): Pass basic_block to load_killed_in_block_p.
(load_killed_in_block_p): Change bb parameter from int to basic_block.
(oprs_not_set_p): Pass basic_blocks instead of ints as parameters.
(handle_rd_kill_set): Change bb parameter from int to basic_block.
(compute_kill_rd): Pass basic_blocks instead of ints as parameters.
(expr_killed_p): Change bb parameter from int to basic_block, pass
basic_blocks instead of ints as parameters.
(compute_ae_kill): Pass basic_blocks instead of ints as parameters.
(expr_reaches_here_p_work, expr_reaches_here_p): Change bb parameter
from int to basic_block, pass basic_blocks instead of ints as parms.
(pre_expr_reaches_here_p_work, pre_expr_reaches_here_p): Change bb
parameter from int to basic_block, pass basic_blocks instead of ints.
(process_insert_insn): Pass basic_blocks instead of ints as parameters.
(insert_insn_end_bb): Change bb parameter from int to basic_block,
pass basic_blocks instead of ints.
(pre_edge_insert, pre_insert_copy_insn, pre_insert_copies): Pass
basic_blocks instead of ints as parameters.
(pre_delete): Pass basic_blocks instead of ints as parameters.
(hoist_expr_reaches_here_p): Change bb parameter from int to
basic_block, pass basic_blocks instead of ints.
(hoist_code): Pass basic_blocks instead of ints as parameters.
(reg_set_info, store_ops_ok, store_killed_after, store_killed_before):
Change bb parameter from int to basic_block.
(build_store_vectors): Pass basic_blocks instead of ints as parameters.
(insert_insn_start_bb): Change bb parameter from int to basic_block,
pass basic_blocks instead of ints.
(insert_store): Pass basic_blocks instead of ints as parameters.
(replace_store_insn, delete_store): Change bb parameter from int to
basic_block, pass basic_blocks instead of ints.
(store_motion): Pass basic_blocks instead of ints as parameters.
*** gcse.c.latest Wed Mar 21 09:35:54 2001
--- gcse.c Wed Mar 21 10:57:48 2001
*************** static int cprop_jump PARAMS ((rtx, rtx
*** 623,629 ****
static int cprop_cc0_jump PARAMS ((rtx, struct reg_use *, rtx));
#endif
static void mems_conflict_for_gcse_p PARAMS ((rtx, rtx, void *));
! static int load_killed_in_block_p PARAMS ((int, int, rtx, int));
static void canon_list_insert PARAMS ((rtx, rtx, void *));
static int cprop_insn PARAMS ((rtx, int));
static int cprop PARAMS ((int));
--- 623,629 ----
static int cprop_cc0_jump PARAMS ((rtx, struct reg_use *, rtx));
#endif
static void mems_conflict_for_gcse_p PARAMS ((rtx, rtx, void *));
! static int load_killed_in_block_p PARAMS ((basic_block, int, rtx, int));
static void canon_list_insert PARAMS ((rtx, rtx, void *));
static int cprop_insn PARAMS ((rtx, int));
static int cprop PARAMS ((int));
*************** static int one_cprop_pass PARAMS ((int,
*** 631,638 ****
static void alloc_pre_mem PARAMS ((int, int));
static void free_pre_mem PARAMS ((void));
static void compute_pre_data PARAMS ((void));
! static int pre_expr_reaches_here_p PARAMS ((int, struct expr *, int));
! static void insert_insn_end_bb PARAMS ((struct expr *, int, int));
static void pre_insert_copy_insn PARAMS ((struct expr *, rtx));
static void pre_insert_copies PARAMS ((void));
static int pre_delete PARAMS ((void));
--- 631,639 ----
static void alloc_pre_mem PARAMS ((int, int));
static void free_pre_mem PARAMS ((void));
static void compute_pre_data PARAMS ((void));
! static int pre_expr_reaches_here_p PARAMS ((basic_block, struct expr *,
! basic_block));
! static void insert_insn_end_bb PARAMS ((struct expr *, basic_block, int));
static void pre_insert_copy_insn PARAMS ((struct expr *, rtx));
static void pre_insert_copies PARAMS ((void));
static int pre_delete PARAMS ((void));
*************** static void alloc_code_hoist_mem PARAMS
*** 643,663 ****
static void free_code_hoist_mem PARAMS ((void));
static void compute_code_hoist_vbeinout PARAMS ((void));
static void compute_code_hoist_data PARAMS ((void));
! static int hoist_expr_reaches_here_p PARAMS ((int, int, int, char *));
static void hoist_code PARAMS ((void));
static int one_code_hoisting_pass PARAMS ((void));
static void alloc_rd_mem PARAMS ((int, int));
static void free_rd_mem PARAMS ((void));
! static void handle_rd_kill_set PARAMS ((rtx, int, int));
static void compute_kill_rd PARAMS ((void));
static void compute_rd PARAMS ((void));
static void alloc_avail_expr_mem PARAMS ((int, int));
static void free_avail_expr_mem PARAMS ((void));
static void compute_ae_gen PARAMS ((void));
! static int expr_killed_p PARAMS ((rtx, int));
static void compute_ae_kill PARAMS ((sbitmap *, sbitmap *));
static int expr_reaches_here_p PARAMS ((struct occr *, struct expr *,
! int, int));
static rtx computing_insn PARAMS ((struct expr *, rtx));
static int def_reaches_here_p PARAMS ((rtx, rtx));
static int can_disregard_other_sets PARAMS ((struct reg_set **, rtx, int));
--- 644,665 ----
static void free_code_hoist_mem PARAMS ((void));
static void compute_code_hoist_vbeinout PARAMS ((void));
static void compute_code_hoist_data PARAMS ((void));
! static int hoist_expr_reaches_here_p PARAMS ((basic_block, int, basic_block,
! char *));
static void hoist_code PARAMS ((void));
static int one_code_hoisting_pass PARAMS ((void));
static void alloc_rd_mem PARAMS ((int, int));
static void free_rd_mem PARAMS ((void));
! static void handle_rd_kill_set PARAMS ((rtx, int, basic_block));
static void compute_kill_rd PARAMS ((void));
static void compute_rd PARAMS ((void));
static void alloc_avail_expr_mem PARAMS ((int, int));
static void free_avail_expr_mem PARAMS ((void));
static void compute_ae_gen PARAMS ((void));
! static int expr_killed_p PARAMS ((rtx, basic_block));
static void compute_ae_kill PARAMS ((sbitmap *, sbitmap *));
static int expr_reaches_here_p PARAMS ((struct occr *, struct expr *,
! basic_block, int));
static rtx computing_insn PARAMS ((struct expr *, rtx));
static int def_reaches_here_p PARAMS ((rtx, rtx));
static int can_disregard_other_sets PARAMS ((struct reg_set **, rtx, int));
*************** static void delete_null_pointer_checks_1
*** 671,679 ****
static rtx process_insert_insn PARAMS ((struct expr *));
static int pre_edge_insert PARAMS ((struct edge_list *, struct expr **));
static int expr_reaches_here_p_work PARAMS ((struct occr *, struct expr *,
! int, int, char *));
! static int pre_expr_reaches_here_p_work PARAMS ((int, struct expr *,
! int, char *));
static struct ls_expr * ldst_entry PARAMS ((rtx));
static void free_ldst_entry PARAMS ((struct ls_expr *));
static void free_ldst_mems PARAMS ((void));
--- 673,681 ----
static rtx process_insert_insn PARAMS ((struct expr *));
static int pre_edge_insert PARAMS ((struct edge_list *, struct expr **));
static int expr_reaches_here_p_work PARAMS ((struct occr *, struct expr *,
! basic_block, int, char *));
! static int pre_expr_reaches_here_p_work PARAMS ((basic_block, struct expr *,
! basic_block, char *));
static struct ls_expr * ldst_entry PARAMS ((rtx));
static void free_ldst_entry PARAMS ((struct ls_expr *));
static void free_ldst_mems PARAMS ((void));
*************** static void compute_ld_motion_mems PARAM
*** 688,706 ****
static void trim_ld_motion_mems PARAMS ((void));
static void update_ld_motion_stores PARAMS ((struct expr *));
static void reg_set_info PARAMS ((rtx, rtx, void *));
! static int store_ops_ok PARAMS ((rtx, int));
static void find_moveable_store PARAMS ((rtx));
static int compute_store_table PARAMS ((void));
static int load_kills_store PARAMS ((rtx, rtx));
static int find_loads PARAMS ((rtx, rtx));
static int store_killed_in_insn PARAMS ((rtx, rtx));
! static int store_killed_after PARAMS ((rtx, rtx, int));
! static int store_killed_before PARAMS ((rtx, rtx, int));
static void build_store_vectors PARAMS ((void));
! static void insert_insn_start_bb PARAMS ((rtx, int));
static int insert_store PARAMS ((struct ls_expr *, edge));
! static void replace_store_insn PARAMS ((rtx, rtx, int));
! static void delete_store PARAMS ((struct ls_expr *, int));
static void free_store_memory PARAMS ((void));
static void store_motion PARAMS ((void));
--- 690,709 ----
static void trim_ld_motion_mems PARAMS ((void));
static void update_ld_motion_stores PARAMS ((struct expr *));
static void reg_set_info PARAMS ((rtx, rtx, void *));
! static int store_ops_ok PARAMS ((rtx, basic_block));
static void find_moveable_store PARAMS ((rtx));
static int compute_store_table PARAMS ((void));
static int load_kills_store PARAMS ((rtx, rtx));
static int find_loads PARAMS ((rtx, rtx));
static int store_killed_in_insn PARAMS ((rtx, rtx));
! static int store_killed_after PARAMS ((rtx, rtx, basic_block));
! static int store_killed_before PARAMS ((rtx, rtx, basic_block));
static void build_store_vectors PARAMS ((void));
! static void insert_insn_start_bb PARAMS ((rtx, basic_block));
static int insert_store PARAMS ((struct ls_expr *, edge));
! static void replace_store_insn PARAMS ((rtx, rtx, basic_block));
! static void delete_store PARAMS ((struct ls_expr *,
! basic_block));
static void free_store_memory PARAMS ((void));
static void store_motion PARAMS ((void));
*************** oprs_unchanged_p (x, insn, avail_p)
*** 1392,1398 ****
|| reg_first_set[REGNO (x)] >= INSN_CUID (insn));
case MEM:
! if (load_killed_in_block_p (BLOCK_NUM (insn), INSN_CUID (insn),
x, avail_p))
return 0;
if (avail_p && mem_last_set != NEVER_SET
--- 1395,1401 ----
|| reg_first_set[REGNO (x)] >= INSN_CUID (insn));
case MEM:
! if (load_killed_in_block_p (BLOCK_FOR_INSN (insn), INSN_CUID (insn),
x, avail_p))
return 0;
if (avail_p && mem_last_set != NEVER_SET
*************** mems_conflict_for_gcse_p (dest, setter,
*** 1506,1517 ****
static int
load_killed_in_block_p (bb, uid_limit, x, avail_p)
! int bb;
int uid_limit;
rtx x;
int avail_p;
{
! rtx list_entry = modify_mem_list[bb];
while (list_entry)
{
rtx setter;
--- 1509,1520 ----
static int
load_killed_in_block_p (bb, uid_limit, x, avail_p)
! basic_block bb;
int uid_limit;
rtx x;
int avail_p;
{
! rtx list_entry = modify_mem_list[bb->index];
while (list_entry)
{
rtx setter;
*************** oprs_not_set_p (x, insn)
*** 2782,2788 ****
return 1;
case MEM:
! if (load_killed_in_block_p (BLOCK_NUM (insn), INSN_CUID (insn), x, 0))
return 0;
if (mem_last_set != 0)
return 0;
--- 2785,2792 ----
return 1;
case MEM:
! if (load_killed_in_block_p (BLOCK_FOR_INSN (insn),
! INSN_CUID (insn), x, 0))
return 0;
if (mem_last_set != 0)
return 0;
*************** free_rd_mem ()
*** 2947,2959 ****
static void
handle_rd_kill_set (insn, regno, bb)
rtx insn;
! int regno, bb;
{
struct reg_set *this_reg;
for (this_reg = reg_set_table[regno]; this_reg; this_reg = this_reg ->next)
if (BLOCK_NUM (this_reg->insn) != BLOCK_NUM (insn))
! SET_BIT (rd_kill[bb], INSN_CUID (this_reg->insn));
}
/* Compute the set of kill's for reaching definitions. */
--- 2951,2964 ----
static void
handle_rd_kill_set (insn, regno, bb)
rtx insn;
! int regno;
! basic_block bb;
{
struct reg_set *this_reg;
for (this_reg = reg_set_table[regno]; this_reg; this_reg = this_reg ->next)
if (BLOCK_NUM (this_reg->insn) != BLOCK_NUM (insn))
! SET_BIT (rd_kill[bb->index], INSN_CUID (this_reg->insn));
}
/* Compute the set of kill's for reaching definitions. */
*************** compute_kill_rd ()
*** 2998,3004 ****
#endif
&& regno != FRAME_POINTER_REGNUM)
|| global_regs[regno])
! handle_rd_kill_set (insn, regno, bb);
}
}
--- 3003,3009 ----
#endif
&& regno != FRAME_POINTER_REGNUM)
|| global_regs[regno])
! handle_rd_kill_set (insn, regno, BASIC_BLOCK (bb));
}
}
*************** compute_kill_rd ()
*** 3012,3024 ****
&& GET_CODE (XEXP (XVECEXP (pat, 0, i), 0)) == REG)
handle_rd_kill_set (insn,
REGNO (XEXP (XVECEXP (pat, 0, i), 0)),
! bb);
}
}
else if (GET_CODE (pat) == SET && GET_CODE (SET_DEST (pat)) == REG)
/* Each setting of this register outside of this block
must be marked in the set of kills in this block. */
! handle_rd_kill_set (insn, REGNO (SET_DEST (pat)), bb);
}
}
--- 3017,3029 ----
&& GET_CODE (XEXP (XVECEXP (pat, 0, i), 0)) == REG)
handle_rd_kill_set (insn,
REGNO (XEXP (XVECEXP (pat, 0, i), 0)),
! BASIC_BLOCK (bb));
}
}
else if (GET_CODE (pat) == SET && GET_CODE (SET_DEST (pat)) == REG)
/* Each setting of this register outside of this block
must be marked in the set of kills in this block. */
! handle_rd_kill_set (insn, REGNO (SET_DEST (pat)), BASIC_BLOCK (bb));
}
}
*************** compute_ae_gen ()
*** 3107,3113 ****
static int
expr_killed_p (x, bb)
rtx x;
! int bb;
{
int i, j;
enum rtx_code code;
--- 3112,3118 ----
static int
expr_killed_p (x, bb)
rtx x;
! basic_block bb;
{
int i, j;
enum rtx_code code;
*************** expr_killed_p (x, bb)
*** 3120,3131 ****
switch (code)
{
case REG:
! return TEST_BIT (reg_set_in_block[bb], REGNO (x));
case MEM:
if (load_killed_in_block_p (bb, get_max_uid () + 1, x, 0))
return 1;
! if (mem_set_in_block[bb])
return 1;
else
return expr_killed_p (XEXP (x, 0), bb);
--- 3125,3136 ----
switch (code)
{
case REG:
! return TEST_BIT (reg_set_in_block[bb->index], REGNO (x));
case MEM:
if (load_killed_in_block_p (bb, get_max_uid () + 1, x, 0))
return 1;
! if (mem_set_in_block[bb->index])
return 1;
else
return expr_killed_p (XEXP (x, 0), bb);
*************** compute_ae_kill (ae_gen, ae_kill)
*** 3184,3190 ****
if (TEST_BIT (ae_gen[bb], expr->bitmap_index))
continue;
! if (expr_killed_p (expr->expr, bb))
SET_BIT (ae_kill[bb], expr->bitmap_index);
}
}
--- 3189,3195 ----
if (TEST_BIT (ae_gen[bb], expr->bitmap_index))
continue;
! if (expr_killed_p (expr->expr, BASIC_BLOCK (bb)))
SET_BIT (ae_kill[bb], expr->bitmap_index);
}
}
*************** static int
*** 3211,3260 ****
expr_reaches_here_p_work (occr, expr, bb, check_self_loop, visited)
struct occr *occr;
struct expr *expr;
! int bb;
int check_self_loop;
char *visited;
{
edge pred;
! for (pred = BASIC_BLOCK(bb)->pred; pred != NULL; pred = pred->pred_next)
{
! int pred_bb = pred->src->index;
! if (visited[pred_bb])
/* This predecessor has already been visited. Nothing to do. */
;
else if (pred_bb == bb)
{
/* BB loops on itself. */
if (check_self_loop
! && TEST_BIT (ae_gen[pred_bb], expr->bitmap_index)
! && BLOCK_NUM (occr->insn) == pred_bb)
return 1;
! visited[pred_bb] = 1;
}
/* Ignore this predecessor if it kills the expression. */
! else if (TEST_BIT (ae_kill[pred_bb], expr->bitmap_index))
! visited[pred_bb] = 1;
/* Does this predecessor generate this expression? */
! else if (TEST_BIT (ae_gen[pred_bb], expr->bitmap_index))
{
/* Is this the occurrence we're looking for?
Note that there's only one generating occurrence per block
so we just need to check the block number. */
! if (BLOCK_NUM (occr->insn) == pred_bb)
return 1;
! visited[pred_bb] = 1;
}
/* Neither gen nor kill. */
else
{
! visited[pred_bb] = 1;
if (expr_reaches_here_p_work (occr, expr, pred_bb, check_self_loop,
visited))
--- 3216,3265 ----
expr_reaches_here_p_work (occr, expr, bb, check_self_loop, visited)
struct occr *occr;
struct expr *expr;
! basic_block bb;
int check_self_loop;
char *visited;
{
edge pred;
! for (pred = bb->pred; pred != NULL; pred = pred->pred_next)
{
! basic_block pred_bb = pred->src;
! if (visited[pred_bb->index])
/* This predecessor has already been visited. Nothing to do. */
;
else if (pred_bb == bb)
{
/* BB loops on itself. */
if (check_self_loop
! && TEST_BIT (ae_gen[pred_bb->index], expr->bitmap_index)
! && BLOCK_NUM (occr->insn) == pred_bb->index)
return 1;
! visited[pred_bb->index] = 1;
}
/* Ignore this predecessor if it kills the expression. */
! else if (TEST_BIT (ae_kill[pred_bb->index], expr->bitmap_index))
! visited[pred_bb->index] = 1;
/* Does this predecessor generate this expression? */
! else if (TEST_BIT (ae_gen[pred_bb->index], expr->bitmap_index))
{
/* Is this the occurrence we're looking for?
Note that there's only one generating occurrence per block
so we just need to check the block number. */
! if (BLOCK_NUM (occr->insn) == pred_bb->index)
return 1;
! visited[pred_bb->index] = 1;
}
/* Neither gen nor kill. */
else
{
! visited[pred_bb->index] = 1;
if (expr_reaches_here_p_work (occr, expr, pred_bb, check_self_loop,
visited))
*************** static int
*** 3273,3279 ****
expr_reaches_here_p (occr, expr, bb, check_self_loop)
struct occr *occr;
struct expr *expr;
! int bb;
int check_self_loop;
{
int rval;
--- 3278,3284 ----
expr_reaches_here_p (occr, expr, bb, check_self_loop)
struct occr *occr;
struct expr *expr;
! basic_block bb;
int check_self_loop;
{
int rval;
*************** computing_insn (expr, insn)
*** 3295,3305 ****
struct expr *expr;
rtx insn;
{
! int bb = BLOCK_NUM (insn);
if (expr->avail_occr->next == NULL)
{
! if (BLOCK_NUM (expr->avail_occr->insn) == bb)
/* The available expression is actually itself
(i.e. a loop in the flow graph) so do nothing. */
return NULL;
--- 3300,3310 ----
struct expr *expr;
rtx insn;
{
! basic_block bb = BLOCK_FOR_INSN (insn);
if (expr->avail_occr->next == NULL)
{
! if (BLOCK_FOR_INSN (expr->avail_occr->insn) == bb)
/* The available expression is actually itself
(i.e. a loop in the flow graph) so do nothing. */
return NULL;
*************** computing_insn (expr, insn)
*** 3319,3325 ****
for (occr = expr->avail_occr; occr != NULL; occr = occr->next)
{
! if (BLOCK_NUM (occr->insn) == bb)
{
/* The expression is generated in this block.
The only time we care about this is when the expression
--- 3324,3330 ----
for (occr = expr->avail_occr; occr != NULL; occr = occr->next)
{
! if (BLOCK_FOR_INSN (occr->insn) == bb)
{
/* The expression is generated in this block.
The only time we care about this is when the expression
*************** compute_pre_data ()
*** 4574,4597 ****
static int
pre_expr_reaches_here_p_work (occr_bb, expr, bb, visited)
! int occr_bb;
struct expr *expr;
! int bb;
char *visited;
{
edge pred;
! for (pred = BASIC_BLOCK (bb)->pred; pred != NULL; pred = pred->pred_next)
{
! int pred_bb = pred->src->index;
if (pred->src == ENTRY_BLOCK_PTR
/* Has predecessor has already been visited? */
! || visited[pred_bb])
;/* Nothing to do. */
/* Does this predecessor generate this expression? */
! 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
--- 4579,4602 ----
static int
pre_expr_reaches_here_p_work (occr_bb, expr, bb, visited)
! basic_block occr_bb;
struct expr *expr;
! basic_block bb;
char *visited;
{
edge pred;
! for (pred = bb->pred; pred != NULL; pred = pred->pred_next)
{
! basic_block pred_bb = pred->src;
if (pred->src == ENTRY_BLOCK_PTR
/* Has predecessor has already been visited? */
! || visited[pred_bb->index])
;/* Nothing to do. */
/* Does this predecessor generate this expression? */
! else if (TEST_BIT (comp[pred_bb->index], expr->bitmap_index))
{
/* Is this the occurrence we're looking for?
Note that there's only one generating occurrence per block
*************** pre_expr_reaches_here_p_work (occr_bb, e
*** 4599,4614 ****
if (occr_bb == pred_bb)
return 1;
! visited[pred_bb] = 1;
}
/* Ignore this predecessor if it kills the expression. */
! else if (! TEST_BIT (transp[pred_bb], expr->bitmap_index))
! visited[pred_bb] = 1;
/* Neither gen nor kill. */
else
{
! visited[pred_bb] = 1;
if (pre_expr_reaches_here_p_work (occr_bb, expr, pred_bb, visited))
return 1;
}
--- 4604,4619 ----
if (occr_bb == pred_bb)
return 1;
! visited[pred_bb->index] = 1;
}
/* Ignore this predecessor if it kills the expression. */
! else if (! TEST_BIT (transp[pred_bb->index], expr->bitmap_index))
! visited[pred_bb->index] = 1;
/* Neither gen nor kill. */
else
{
! visited[pred_bb->index] = 1;
if (pre_expr_reaches_here_p_work (occr_bb, expr, pred_bb, visited))
return 1;
}
*************** pre_expr_reaches_here_p_work (occr_bb, e
*** 4623,4631 ****
static int
pre_expr_reaches_here_p (occr_bb, expr, bb)
! int occr_bb;
struct expr *expr;
! int bb;
{
int rval;
char *visited = (char *) xcalloc (n_basic_blocks, 1);
--- 4628,4636 ----
static int
pre_expr_reaches_here_p (occr_bb, expr, bb)
! basic_block occr_bb;
struct expr *expr;
! basic_block bb;
{
int rval;
char *visited = (char *) xcalloc (n_basic_blocks, 1);
*************** process_insert_insn (expr)
*** 4679,4688 ****
static void
insert_insn_end_bb (expr, bb, pre)
struct expr *expr;
! int bb;
int pre;
{
! rtx insn = BLOCK_END (bb);
rtx new_insn;
rtx reg = expr->reaching_reg;
int regno = REGNO (reg);
--- 4684,4693 ----
static void
insert_insn_end_bb (expr, bb, pre)
struct expr *expr;
! basic_block bb;
int pre;
{
! rtx insn = bb->end;
rtx new_insn;
rtx reg = expr->reaching_reg;
int regno = REGNO (reg);
*************** insert_insn_end_bb (expr, bb, pre)
*** 4723,4729 ****
}
#endif
/* FIXME: What if something in cc0/jump uses value set in new insn? */
! new_insn = emit_block_insn_before (pat, insn, BASIC_BLOCK (bb));
}
/* Likewise if the last insn is a call, as will happen in the presence
--- 4728,4734 ----
}
#endif
/* FIXME: What if something in cc0/jump uses value set in new insn? */
! new_insn = emit_block_insn_before (pat, insn, bb);
}
/* Likewise if the last insn is a call, as will happen in the presence
*************** insert_insn_end_bb (expr, bb, pre)
*** 4744,4751 ****
Check this. */
if (pre
! && !TEST_BIT (antloc[bb], expr->bitmap_index)
! && !TEST_BIT (transp[bb], expr->bitmap_index))
abort ();
/* Since different machines initialize their parameter registers
--- 4749,4756 ----
Check this. */
if (pre
! && !TEST_BIT (antloc[bb->index], expr->bitmap_index)
! && !TEST_BIT (transp[bb->index], expr->bitmap_index))
abort ();
/* Since different machines initialize their parameter registers
*************** insert_insn_end_bb (expr, bb, pre)
*** 4765,4771 ****
}
/* Search backward for the first set of a register in this set. */
! while (nparm_regs && BLOCK_HEAD (bb) != insn)
{
insn = PREV_INSN (insn);
p = single_set (insn);
--- 4770,4776 ----
}
/* Search backward for the first set of a register in this set. */
! while (nparm_regs && bb->head != insn)
{
insn = PREV_INSN (insn);
p = single_set (insn);
*************** insert_insn_end_bb (expr, bb, pre)
*** 4790,4801 ****
|| NOTE_INSN_BASIC_BLOCK_P (insn))
insn = NEXT_INSN (insn);
! new_insn = emit_block_insn_before (pat, insn, BASIC_BLOCK (bb));
}
else
{
new_insn = emit_insn_after (pat, insn);
! BLOCK_END (bb) = new_insn;
}
/* Keep block number table up to date.
--- 4795,4806 ----
|| NOTE_INSN_BASIC_BLOCK_P (insn))
insn = NEXT_INSN (insn);
! new_insn = emit_block_insn_before (pat, insn, bb);
}
else
{
new_insn = emit_insn_after (pat, insn);
! bb->end = new_insn;
}
/* Keep block number table up to date.
*************** insert_insn_end_bb (expr, bb, pre)
*** 4807,4813 ****
{
rtx insn = XVECEXP (pat, 0, i);
! set_block_for_insn (insn, BASIC_BLOCK (bb));
if (INSN_P (insn))
add_label_notes (PATTERN (insn), new_insn);
--- 4812,4818 ----
{
rtx insn = XVECEXP (pat, 0, i);
! set_block_for_insn (insn, bb);
if (INSN_P (insn))
add_label_notes (PATTERN (insn), new_insn);
*************** insert_insn_end_bb (expr, bb, pre)
*** 4817,4823 ****
else
{
add_label_notes (SET_SRC (pat), new_insn);
! set_block_for_new_insns (new_insn, BASIC_BLOCK (bb));
/* Keep register set table up to date. */
record_one_set (regno, new_insn);
--- 4822,4828 ----
else
{
add_label_notes (SET_SRC (pat), new_insn);
! set_block_for_new_insns (new_insn, bb);
/* Keep register set table up to date. */
record_one_set (regno, new_insn);
*************** insert_insn_end_bb (expr, bb, pre)
*** 4828,4834 ****
if (gcse_file)
{
fprintf (gcse_file, "PRE/HOIST: end of bb %d, insn %d, ",
! bb, INSN_UID (new_insn));
fprintf (gcse_file, "copying expression %d to reg %d\n",
expr->bitmap_index, regno);
}
--- 4833,4839 ----
if (gcse_file)
{
fprintf (gcse_file, "PRE/HOIST: end of bb %d, insn %d, ",
! bb->index, INSN_UID (new_insn));
fprintf (gcse_file, "copying expression %d to reg %d\n",
expr->bitmap_index, regno);
}
*************** pre_edge_insert (edge_list, index_map)
*** 4856,4863 ****
for (e = 0; e < num_edges; e++)
{
int indx;
! basic_block pred = INDEX_EDGE_PRED_BB (edge_list, e);
! int bb = pred->index;
for (i = indx = 0; i < set_size; i++, indx += SBITMAP_ELT_BITS)
{
--- 4861,4867 ----
for (e = 0; e < num_edges; e++)
{
int indx;
! basic_block bb = INDEX_EDGE_PRED_BB (edge_list, e);
for (i = indx = 0; i < set_size; i++, indx += SBITMAP_ELT_BITS)
{
*************** pre_edge_insert (edge_list, index_map)
*** 4900,4906 ****
if (gcse_file)
{
fprintf (gcse_file, "PRE/HOIST: edge (%d,%d), ",
! bb,
INDEX_EDGE_SUCC_BB (edge_list, e)->index);
fprintf (gcse_file, "copy expression %d\n",
expr->bitmap_index);
--- 4904,4910 ----
if (gcse_file)
{
fprintf (gcse_file, "PRE/HOIST: edge (%d,%d), ",
! bb->index,
INDEX_EDGE_SUCC_BB (edge_list, e)->index);
fprintf (gcse_file, "copy expression %d\n",
expr->bitmap_index);
*************** pre_insert_copy_insn (expr, insn)
*** 4932,4938 ****
int indx = expr->bitmap_index;
rtx set = single_set (insn);
rtx new_insn;
! int bb = BLOCK_NUM (insn);
if (!set)
abort ();
--- 4936,4942 ----
int indx = expr->bitmap_index;
rtx set = single_set (insn);
rtx new_insn;
! basic_block bb = BLOCK_FOR_INSN (insn);
if (!set)
abort ();
*************** pre_insert_copy_insn (expr, insn)
*** 4941,4952 ****
insn);
/* Keep block number table up to date. */
! set_block_for_new_insns (new_insn, BASIC_BLOCK (bb));
/* Keep register set table up to date. */
record_one_set (regno, new_insn);
! if (insn == BLOCK_END (bb))
! BLOCK_END (bb) = new_insn;
gcse_create_count++;
--- 4945,4956 ----
insn);
/* Keep block number table up to date. */
! set_block_for_new_insns (new_insn, bb);
/* Keep register set table up to date. */
record_one_set (regno, new_insn);
! if (insn == bb->end)
! bb->end = new_insn;
gcse_create_count++;
*************** pre_insert_copies ()
*** 5003,5010 ****
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)))
continue;
/* Copy the result of avail to reaching_reg. */
--- 5007,5015 ----
continue;
/* Or if the expression doesn't reach the deleted one. */
! if (! pre_expr_reaches_here_p (BLOCK_FOR_INSN (avail->insn),
! expr,
! BLOCK_FOR_INSN (occr->insn)))
continue;
/* Copy the result of avail to reaching_reg. */
*************** pre_delete ()
*** 5043,5051 ****
{
rtx insn = occr->insn;
rtx set;
! int bb = BLOCK_NUM (insn);
! if (TEST_BIT (pre_delete_map[bb], indx))
{
set = single_set (insn);
if (! set)
--- 5048,5056 ----
{
rtx insn = occr->insn;
rtx set;
! basic_block bb = BLOCK_FOR_INSN (insn);
! if (TEST_BIT (pre_delete_map[bb->index], indx))
{
set = single_set (insn);
if (! set)
*************** pre_delete ()
*** 5080,5086 ****
"PRE: redundant insn %d (expression %d) in ",
INSN_UID (insn), indx);
fprintf (gcse_file, "bb %d, reaching reg is %d\n",
! bb, REGNO (expr->reaching_reg));
}
}
}
--- 5085,5091 ----
"PRE: redundant insn %d (expression %d) in ",
INSN_UID (insn), indx);
fprintf (gcse_file, "bb %d, reaching reg is %d\n",
! bb->index, REGNO (expr->reaching_reg));
}
}
}
*************** compute_code_hoist_data ()
*** 5705,5713 ****
static int
hoist_expr_reaches_here_p (expr_bb, expr_index, bb, visited)
! int expr_bb;
int expr_index;
! int bb;
char *visited;
{
edge pred;
--- 5710,5718 ----
static int
hoist_expr_reaches_here_p (expr_bb, expr_index, bb, visited)
! basic_block expr_bb;
int expr_index;
! basic_block bb;
char *visited;
{
edge pred;
*************** hoist_expr_reaches_here_p (expr_bb, expr
*** 5720,5744 ****
visited = xcalloc (n_basic_blocks, 1);
}
! for (pred = BASIC_BLOCK (bb)->pred; pred != NULL; pred = pred->pred_next)
{
! int pred_bb = pred->src->index;
if (pred->src == ENTRY_BLOCK_PTR)
break;
! else if (visited[pred_bb])
continue;
/* Does this predecessor generate this expression? */
! else if (TEST_BIT (comp[pred_bb], expr_index))
break;
! else if (! TEST_BIT (transp[pred_bb], expr_index))
break;
/* Not killed. */
else
{
! visited[pred_bb] = 1;
if (! hoist_expr_reaches_here_p (expr_bb, expr_index,
pred_bb, visited))
break;
--- 5725,5749 ----
visited = xcalloc (n_basic_blocks, 1);
}
! for (pred = bb->pred; pred != NULL; pred = pred->pred_next)
{
! basic_block pred_bb = pred->src;
if (pred->src == ENTRY_BLOCK_PTR)
break;
! else if (visited[pred_bb->index])
continue;
/* Does this predecessor generate this expression? */
! else if (TEST_BIT (comp[pred_bb->index], expr_index))
break;
! else if (! TEST_BIT (transp[pred_bb->index], expr_index))
break;
/* Not killed. */
else
{
! visited[pred_bb->index] = 1;
if (! hoist_expr_reaches_here_p (expr_bb, expr_index,
pred_bb, visited))
break;
*************** hoist_code ()
*** 5806,5812 ****
Keep track of how many times this expression is hoistable
from a dominated block into BB. */
! if (hoist_expr_reaches_here_p (bb, i, dominated, NULL))
hoistable++;
}
--- 5811,5818 ----
Keep track of how many times this expression is hoistable
from a dominated block into BB. */
! if (hoist_expr_reaches_here_p (BASIC_BLOCK (bb), i,
! BASIC_BLOCK (dominated), NULL))
hoistable++;
}
*************** hoist_code ()
*** 5863,5869 ****
dominated block. Now we have to determine if the
expresion would reach the dominated block if it was
placed at the end of BB. */
! if (hoist_expr_reaches_here_p (bb, i, dominated, NULL))
{
struct expr *expr = index_map[i];
struct occr *occr = expr->antic_occr;
--- 5869,5876 ----
dominated block. Now we have to determine if the
expresion would reach the dominated block if it was
placed at the end of BB. */
! if (hoist_expr_reaches_here_p (BASIC_BLOCK (bb), i,
! BASIC_BLOCK (dominated), NULL))
{
struct expr *expr = index_map[i];
struct occr *occr = expr->antic_occr;
*************** hoist_code ()
*** 5905,5911 ****
occr->deleted_p = 1;
if (!insn_inserted_p)
{
! insert_insn_end_bb (index_map[i], bb, 0);
insn_inserted_p = 1;
}
}
--- 5912,5919 ----
occr->deleted_p = 1;
if (!insn_inserted_p)
{
! insert_insn_end_bb (index_map[i],
! BASIC_BLOCK (bb), 0);
insn_inserted_p = 1;
}
}
*************** reg_set_info (dest, setter, data)
*** 6393,6399 ****
static int
store_ops_ok (x, bb)
rtx x;
! int bb;
{
int i;
enum rtx_code code;
--- 6401,6407 ----
static int
store_ops_ok (x, bb)
rtx x;
! basic_block bb;
{
int i;
enum rtx_code code;
*************** store_ops_ok (x, bb)
*** 6411,6417 ****
case REG:
/* If a reg has changed after us in this
block, the operand has been killed. */
! return TEST_BIT (reg_set_in_block[bb], REGNO (x));
case MEM:
x = XEXP (x, 0);
--- 6419,6425 ----
case REG:
/* If a reg has changed after us in this
block, the operand has been killed. */
! return TEST_BIT (reg_set_in_block[bb->index], REGNO (x));
case MEM:
x = XEXP (x, 0);
*************** store_killed_in_insn (x, insn)
*** 6663,6671 ****
static int
store_killed_after (x, insn, bb)
rtx x, insn;
! int bb;
{
! rtx last = BLOCK_END (bb);
if (insn == last)
return 0;
--- 6671,6679 ----
static int
store_killed_after (x, insn, bb)
rtx x, insn;
! basic_block bb;
{
! rtx last = bb->end;
if (insn == last)
return 0;
*************** store_killed_after (x, insn, bb)
*** 6690,6698 ****
static int
store_killed_before (x, insn, bb)
rtx x, insn;
! int bb;
{
! rtx first = BLOCK_HEAD (bb);
if (insn == first)
return store_killed_in_insn (x, insn);
--- 6698,6706 ----
static int
store_killed_before (x, insn, bb)
rtx x, insn;
! basic_block bb;
{
! rtx first = bb->head;
if (insn == first)
return store_killed_in_insn (x, insn);
*************** store_killed_before (x, insn, bb)
*** 6721,6727 ****
static void
build_store_vectors ()
{
! int bb;
rtx insn, st;
struct ls_expr * ptr;
--- 6729,6736 ----
static void
build_store_vectors ()
{
! basic_block bb;
! int b;
rtx insn, st;
struct ls_expr * ptr;
*************** build_store_vectors ()
*** 6743,6749 ****
for (st = store_list; st != NULL; st = XEXP (st, 1))
{
insn = XEXP (st, 0);
! bb = BLOCK_NUM (insn);
if (!store_killed_after (ptr->pattern, insn, bb))
{
--- 6752,6758 ----
for (st = store_list; st != NULL; st = XEXP (st, 1))
{
insn = XEXP (st, 0);
! bb = BLOCK_FOR_INSN (insn);
if (!store_killed_after (ptr->pattern, insn, bb))
{
*************** build_store_vectors ()
*** 6752,6763 ****
the block), and replace it with this one). We'll copy the
old SRC expression to an unused register in case there
are any side effects. */
! if (TEST_BIT (ae_gen[bb], ptr->index))
{
/* Find previous store. */
rtx st;
for (st = AVAIL_STORE_LIST (ptr); st ; st = XEXP (st, 1))
! if (BLOCK_NUM (XEXP (st, 0)) == bb)
break;
if (st)
{
--- 6761,6772 ----
the block), and replace it with this one). We'll copy the
old SRC expression to an unused register in case there
are any side effects. */
! if (TEST_BIT (ae_gen[bb->index], ptr->index))
{
/* Find previous store. */
rtx st;
for (st = AVAIL_STORE_LIST (ptr); st ; st = XEXP (st, 1))
! if (BLOCK_FOR_INSN (XEXP (st, 0)) == bb)
break;
if (st)
{
*************** build_store_vectors ()
*** 6769,6775 ****
continue;
}
}
! SET_BIT (ae_gen[bb], ptr->index);
AVAIL_STORE_LIST (ptr) = alloc_INSN_LIST (insn,
AVAIL_STORE_LIST (ptr));
}
--- 6778,6784 ----
continue;
}
}
! SET_BIT (ae_gen[bb->index], ptr->index);
AVAIL_STORE_LIST (ptr) = alloc_INSN_LIST (insn,
AVAIL_STORE_LIST (ptr));
}
*************** build_store_vectors ()
*** 6793,6801 ****
sbitmap_vector_zero (transp, n_basic_blocks);
for (ptr = first_ls_expr (); ptr != NULL; ptr = next_ls_expr (ptr))
! for (bb = 0; bb < n_basic_blocks; bb++)
{
! if (store_killed_after (ptr->pattern, BLOCK_HEAD (bb), bb))
{
/* The anticipatable expression is not killed if it's gen'd. */
/*
--- 6802,6810 ----
sbitmap_vector_zero (transp, n_basic_blocks);
for (ptr = first_ls_expr (); ptr != NULL; ptr = next_ls_expr (ptr))
! for (b = 0; b < n_basic_blocks; b++)
{
! if (store_killed_after (ptr->pattern, BLOCK_HEAD (b), BASIC_BLOCK (b)))
{
/* The anticipatable expression is not killed if it's gen'd. */
/*
*************** build_store_vectors ()
*** 6812,6822 ****
gcc.c-torture/execute/960311-1.c with -O3
If we always kill it in this case, we'll sometimes do
uneccessary work, but it shouldn't actually hurt anything.
! if (!TEST_BIT (ae_gen[bb], ptr->index)). */
! SET_BIT (ae_kill[bb], ptr->index);
}
else
! SET_BIT (transp[bb], ptr->index);
}
/* Any block with no exits calls some non-returning function, so
--- 6821,6831 ----
gcc.c-torture/execute/960311-1.c with -O3
If we always kill it in this case, we'll sometimes do
uneccessary work, but it shouldn't actually hurt anything.
! if (!TEST_BIT (ae_gen[b], ptr->index)). */
! SET_BIT (ae_kill[b], ptr->index);
}
else
! SET_BIT (transp[b], ptr->index);
}
/* Any block with no exits calls some non-returning function, so
*************** build_store_vectors ()
*** 6840,6850 ****
static void
insert_insn_start_bb (insn, bb)
rtx insn;
! int bb;
{
/* Insert at start of successor block. */
! rtx prev = PREV_INSN (BLOCK_HEAD (bb));
! rtx before = BLOCK_HEAD (bb);
while (before != 0)
{
if (GET_CODE (before) != CODE_LABEL
--- 6849,6859 ----
static void
insert_insn_start_bb (insn, bb)
rtx insn;
! basic_block bb;
{
/* Insert at start of successor block. */
! rtx prev = PREV_INSN (bb->head);
! rtx before = bb->head;
while (before != 0)
{
if (GET_CODE (before) != CODE_LABEL
*************** insert_insn_start_bb (insn, bb)
*** 6852,6873 ****
|| NOTE_LINE_NUMBER (before) != NOTE_INSN_BASIC_BLOCK))
break;
prev = before;
! if (prev == BLOCK_END (bb))
break;
before = NEXT_INSN (before);
}
insn = emit_insn_after (insn, prev);
! if (prev == BLOCK_END (bb))
! BLOCK_END (bb) = insn;
! set_block_for_new_insns (insn, BASIC_BLOCK (bb));
if (gcse_file)
{
fprintf (gcse_file, "STORE_MOTION insert store at start of BB %d:\n",
! bb);
print_inline_rtx (gcse_file, insn, 6);
fprintf (gcse_file, "\n");
}
--- 6861,6882 ----
|| NOTE_LINE_NUMBER (before) != NOTE_INSN_BASIC_BLOCK))
break;
prev = before;
! if (prev == bb->end)
break;
before = NEXT_INSN (before);
}
insn = emit_insn_after (insn, prev);
! if (prev == bb->end)
! bb->end = insn;
! set_block_for_new_insns (insn, bb);
if (gcse_file)
{
fprintf (gcse_file, "STORE_MOTION insert store at start of BB %d:\n",
! bb->index);
print_inline_rtx (gcse_file, insn, 6);
fprintf (gcse_file, "\n");
}
*************** insert_store (expr, e)
*** 6883,6889 ****
edge e;
{
rtx reg, insn;
! int bb;
edge tmp;
/* We did all the deleted before this insert, so if we didn't delete a
--- 6892,6898 ----
edge e;
{
rtx reg, insn;
! basic_block bb;
edge tmp;
/* We did all the deleted before this insert, so if we didn't delete a
*************** insert_store (expr, e)
*** 6897,6903 ****
/* If we are inserting this expression on ALL predecessor edges of a BB,
insert it at the start of the BB, and reset the insert bits on the other
edges so we don;t try to insert it on the other edges. */
! bb = e->dest->index;
for (tmp = e->dest->pred; tmp ; tmp = tmp->pred_next)
{
int index = EDGE_INDEX (edge_list, tmp->src, tmp->dest);
--- 6906,6912 ----
/* If we are inserting this expression on ALL predecessor edges of a BB,
insert it at the start of the BB, and reset the insert bits on the other
edges so we don;t try to insert it on the other edges. */
! bb = e->dest;
for (tmp = e->dest->pred; tmp ; tmp = tmp->pred_next)
{
int index = EDGE_INDEX (edge_list, tmp->src, tmp->dest);
*************** insert_store (expr, e)
*** 6909,6915 ****
/* If tmp is NULL, we found an insertion on every edge, blank the
insertion vector for these edges, and insert at the start of the BB. */
! if (!tmp && bb != EXIT_BLOCK)
{
for (tmp = e->dest->pred; tmp ; tmp = tmp->pred_next)
{
--- 6918,6924 ----
/* If tmp is NULL, we found an insertion on every edge, blank the
insertion vector for these edges, and insert at the start of the BB. */
! if (!tmp && bb != EXIT_BLOCK_PTR)
{
for (tmp = e->dest->pred; tmp ; tmp = tmp->pred_next)
{
*************** insert_store (expr, e)
*** 6946,6974 ****
static void
replace_store_insn (reg, del, bb)
rtx reg, del;
! int bb;
{
rtx insn;
insn = gen_move_insn (reg, SET_SRC (PATTERN (del)));
insn = emit_insn_after (insn, del);
! set_block_for_new_insns (insn, BASIC_BLOCK (bb));
if (gcse_file)
{
fprintf (gcse_file,
! "STORE_MOTION delete insn in BB %d:\n ", bb);
print_inline_rtx (gcse_file, del, 6);
fprintf(gcse_file, "\nSTORE MOTION replaced with insn:\n ");
print_inline_rtx (gcse_file, insn, 6);
fprintf(gcse_file, "\n");
}
! if (BLOCK_END (bb) == del)
! BLOCK_END (bb) = insn;
! if (BLOCK_HEAD (bb) == del)
! BLOCK_HEAD (bb) = insn;
delete_insn (del);
}
--- 6955,6983 ----
static void
replace_store_insn (reg, del, bb)
rtx reg, del;
! basic_block bb;
{
rtx insn;
insn = gen_move_insn (reg, SET_SRC (PATTERN (del)));
insn = emit_insn_after (insn, del);
! set_block_for_new_insns (insn, bb);
if (gcse_file)
{
fprintf (gcse_file,
! "STORE_MOTION delete insn in BB %d:\n ", bb->index);
print_inline_rtx (gcse_file, del, 6);
fprintf(gcse_file, "\nSTORE MOTION replaced with insn:\n ");
print_inline_rtx (gcse_file, insn, 6);
fprintf(gcse_file, "\n");
}
! if (bb->end == del)
! bb->end = insn;
! if (bb->head == del)
! bb->head = insn;
delete_insn (del);
}
*************** replace_store_insn (reg, del, bb)
*** 6980,6986 ****
static void
delete_store (expr, bb)
struct ls_expr * expr;
! int bb;
{
rtx reg, i, del;
--- 6989,6995 ----
static void
delete_store (expr, bb)
struct ls_expr * expr;
! basic_block bb;
{
rtx reg, i, del;
*************** delete_store (expr, bb)
*** 6995,7001 ****
for (i = AVAIL_STORE_LIST (expr); i; i = XEXP (i, 1))
{
del = XEXP (i, 0);
! if (BLOCK_NUM (del) == bb)
{
/* We know there is only one since we deleted redundant
ones during the available computation. */
--- 7004,7010 ----
for (i = AVAIL_STORE_LIST (expr); i; i = XEXP (i, 1))
{
del = XEXP (i, 0);
! if (BLOCK_FOR_INSN (del) == bb)
{
/* We know there is only one since we deleted redundant
ones during the available computation. */
*************** store_motion ()
*** 7072,7078 ****
{
for (x = 0; x < n_basic_blocks; x++)
if (TEST_BIT (pre_delete_map[x], ptr->index))
! delete_store (ptr, x);
for (x = 0; x < NUM_EDGES (edge_list); x++)
if (TEST_BIT (pre_insert_map[x], ptr->index))
--- 7081,7087 ----
{
for (x = 0; x < n_basic_blocks; x++)
if (TEST_BIT (pre_delete_map[x], ptr->index))
! delete_store (ptr, BASIC_BLOCK (x));
for (x = 0; x < NUM_EDGES (edge_list); x++)
if (TEST_BIT (pre_insert_map[x], ptr->index))