mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-11 21:37:53 +08:00
Put phi nodes after NOTE_INSN_BASIC_BLOCK.
* rtl.h (NOTE_INSN_BASIC_BLOCK_P): New macro. * bb-reorder.c (get_next_bb_note): Use NOTE_INSN_BASIC_BLOCK_P. (get_prev_bb_note): Likewise. (remove_scope_notes): Likewise. * flow.c (commit_one_edge_insertion): Likewise. (merge_blocks_nomove): Likewise. (verify_flow_info): Likewise. * gcse.c (insert_insn_end_bb): Likewise. * reg-stack.c (emit_swap_insn): Likewise. * ssa.c (first_insn_after_basic_block_note): New function. (insert_phi_node): Use it. (rename_block): Likewise. (eliminate_phi): Likewise. (make_regs_equivalent_over_bad_edges): Likewise. (make_equivalent_phi_alternatives_equivalent): Likewise. (for_each_successor_phi): Likewise. (convert_from_ssa): Modify phi-node deletion algorithm. From-SVN: r35296
This commit is contained in:
parent
2d97a71922
commit
589ca5cb10
@ -777,8 +777,7 @@ get_next_bb_note (x)
|
||||
{
|
||||
while (x)
|
||||
{
|
||||
if (GET_CODE (x) == NOTE
|
||||
&& NOTE_LINE_NUMBER (x) == NOTE_INSN_BASIC_BLOCK)
|
||||
if (NOTE_INSN_BASIC_BLOCK_P (x))
|
||||
return x;
|
||||
x = NEXT_INSN (x);
|
||||
}
|
||||
@ -792,8 +791,7 @@ get_prev_bb_note (x)
|
||||
{
|
||||
while (x)
|
||||
{
|
||||
if (GET_CODE (x) == NOTE
|
||||
&& NOTE_LINE_NUMBER (x) == NOTE_INSN_BASIC_BLOCK)
|
||||
if (NOTE_INSN_BASIC_BLOCK_P (x))
|
||||
return x;
|
||||
x = PREV_INSN (x);
|
||||
}
|
||||
@ -1050,8 +1048,7 @@ remove_scope_notes ()
|
||||
for (x = get_insns (); x; x = next)
|
||||
{
|
||||
next = NEXT_INSN (x);
|
||||
if (GET_CODE (x) == NOTE
|
||||
&& NOTE_LINE_NUMBER (x) == NOTE_INSN_BASIC_BLOCK)
|
||||
if (NOTE_INSN_BASIC_BLOCK_P (x))
|
||||
currbb = NOTE_BASIC_BLOCK (x);
|
||||
|
||||
if (GET_CODE (x) == NOTE
|
||||
|
16
gcc/flow.c
16
gcc/flow.c
@ -1673,8 +1673,7 @@ commit_one_edge_insertion (e)
|
||||
tmp = bb->head;
|
||||
if (GET_CODE (tmp) == CODE_LABEL)
|
||||
tmp = NEXT_INSN (tmp);
|
||||
if (GET_CODE (tmp) == NOTE
|
||||
&& NOTE_LINE_NUMBER (tmp) == NOTE_INSN_BASIC_BLOCK)
|
||||
if (NOTE_INSN_BASIC_BLOCK_P (tmp))
|
||||
tmp = NEXT_INSN (tmp);
|
||||
if (tmp == bb->head)
|
||||
before = tmp;
|
||||
@ -2164,8 +2163,7 @@ merge_blocks_nomove (a, b)
|
||||
}
|
||||
|
||||
/* Delete the basic block note. */
|
||||
if (GET_CODE (b_head) == NOTE
|
||||
&& NOTE_LINE_NUMBER (b_head) == NOTE_INSN_BASIC_BLOCK)
|
||||
if (NOTE_INSN_BASIC_BLOCK_P (b_head))
|
||||
{
|
||||
if (b_head == b_end)
|
||||
b_empty = 1;
|
||||
@ -6471,9 +6469,7 @@ verify_flow_info ()
|
||||
}
|
||||
x = NEXT_INSN (x);
|
||||
}
|
||||
if (GET_CODE (x) != NOTE
|
||||
|| NOTE_LINE_NUMBER (x) != NOTE_INSN_BASIC_BLOCK
|
||||
|| NOTE_BASIC_BLOCK (x) != bb)
|
||||
if (!NOTE_INSN_BASIC_BLOCK_P (x) || NOTE_BASIC_BLOCK (x) != bb)
|
||||
{
|
||||
error ("NOTE_INSN_BASIC_BLOCK is missing for block %d\n",
|
||||
bb->index);
|
||||
@ -6489,8 +6485,7 @@ verify_flow_info ()
|
||||
x = NEXT_INSN (x);
|
||||
while (x)
|
||||
{
|
||||
if (GET_CODE (x) == NOTE
|
||||
&& NOTE_LINE_NUMBER (x) == NOTE_INSN_BASIC_BLOCK)
|
||||
if (NOTE_INSN_BASIC_BLOCK_P (x))
|
||||
{
|
||||
error ("NOTE_INSN_BASIC_BLOCK %d in the middle of basic block %d",
|
||||
INSN_UID (x), bb->index);
|
||||
@ -6518,8 +6513,7 @@ verify_flow_info ()
|
||||
x = rtx_first;
|
||||
while (x)
|
||||
{
|
||||
if (GET_CODE (x) == NOTE
|
||||
&& NOTE_LINE_NUMBER (x) == NOTE_INSN_BASIC_BLOCK)
|
||||
if (NOTE_INSN_BASIC_BLOCK_P (x))
|
||||
{
|
||||
basic_block bb = NOTE_BASIC_BLOCK (x);
|
||||
num_bb_notes++;
|
||||
|
@ -4331,8 +4331,7 @@ insert_insn_end_bb (expr, bb, pre)
|
||||
the insn in the wrong basic block. In that case, put the insn
|
||||
after the CODE_LABEL. Also, respect NOTE_INSN_BASIC_BLOCK. */
|
||||
while (GET_CODE (insn) == CODE_LABEL
|
||||
|| (GET_CODE (insn) == NOTE
|
||||
&& NOTE_LINE_NUMBER (insn) == NOTE_INSN_BASIC_BLOCK))
|
||||
|| NOTE_INSN_BASIC_BLOCK_P (insn))
|
||||
insn = NEXT_INSN (insn);
|
||||
|
||||
new_insn = emit_block_insn_before (pat, insn, BASIC_BLOCK (bb));
|
||||
|
@ -978,8 +978,7 @@ emit_swap_insn (insn, regstack, reg)
|
||||
while (tmp != limit)
|
||||
{
|
||||
if (GET_CODE (tmp) == CODE_LABEL
|
||||
|| (GET_CODE (tmp) == NOTE
|
||||
&& NOTE_LINE_NUMBER (tmp) == NOTE_INSN_BASIC_BLOCK)
|
||||
|| NOTE_INSN_BASIC_BLOCK_P (tmp)
|
||||
|| (GET_CODE (tmp) == INSN
|
||||
&& stack_regs_mentioned (tmp)))
|
||||
{
|
||||
|
@ -565,6 +565,11 @@ extern const char * const reg_note_name[];
|
||||
Other kinds of NOTEs are identified by negative numbers here. */
|
||||
#define NOTE_LINE_NUMBER(INSN) XCINT(INSN, 4, NOTE)
|
||||
|
||||
/* Nonzero if INSN is a note marking the beginning of a basic block. */
|
||||
#define NOTE_INSN_BASIC_BLOCK_P(INSN) \
|
||||
(GET_CODE (INSN) == NOTE \
|
||||
&& NOTE_LINE_NUMBER (INSN) == NOTE_INSN_BASIC_BLOCK)
|
||||
|
||||
/* Codes that appear in the NOTE_LINE_NUMBER field
|
||||
for kinds of notes that are not line numbers.
|
||||
|
||||
|
95
gcc/ssa.c
95
gcc/ssa.c
@ -98,6 +98,8 @@ struct rename_context;
|
||||
static inline rtx * phi_alternative
|
||||
PARAMS ((rtx, int));
|
||||
|
||||
static rtx first_insn_after_basic_block_note PARAMS ((basic_block));
|
||||
|
||||
static int remove_phi_alternative
|
||||
PARAMS ((rtx, int));
|
||||
static void simplify_to_immediate_dominators
|
||||
@ -449,6 +451,28 @@ compute_iterated_dominance_frontiers (idfs, frontiers, evals, nregs)
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the INSN immediately following the NOTE_INSN_BASIC_BLOCK
|
||||
note associated with the BLOCK. */
|
||||
|
||||
static rtx
|
||||
first_insn_after_basic_block_note (block)
|
||||
basic_block block;
|
||||
{
|
||||
rtx insn;
|
||||
|
||||
/* Get the first instruction in the block. */
|
||||
insn = block->head;
|
||||
|
||||
if (insn == NULL_RTX)
|
||||
return NULL_RTX;
|
||||
if (GET_CODE (insn) == CODE_LABEL)
|
||||
insn = NEXT_INSN (insn);
|
||||
if (!NOTE_INSN_BASIC_BLOCK_P (insn))
|
||||
abort ();
|
||||
|
||||
return NEXT_INSN (insn);
|
||||
}
|
||||
|
||||
|
||||
/* Insert the phi nodes. */
|
||||
|
||||
@ -461,6 +485,8 @@ insert_phi_node (regno, bb)
|
||||
int npred, i;
|
||||
rtvec vec;
|
||||
rtx phi, reg;
|
||||
rtx insn;
|
||||
int end_p;
|
||||
|
||||
/* Find out how many predecessors there are. */
|
||||
for (e = b->pred, npred = 0; e; e = e->pred_next)
|
||||
@ -488,10 +514,11 @@ insert_phi_node (regno, bb)
|
||||
phi = gen_rtx_PHI (VOIDmode, vec);
|
||||
phi = gen_rtx_SET (VOIDmode, reg, phi);
|
||||
|
||||
if (GET_CODE (b->head) == CODE_LABEL)
|
||||
emit_insn_after (phi, b->head);
|
||||
else
|
||||
b->head = emit_insn_before (phi, b->head);
|
||||
insn = first_insn_after_basic_block_note (b);
|
||||
end_p = PREV_INSN (insn) == b->end;
|
||||
emit_insn_before (phi, insn);
|
||||
if (end_p)
|
||||
b->end = PREV_INSN (insn);
|
||||
}
|
||||
|
||||
|
||||
@ -811,9 +838,7 @@ rename_block (bb, idom)
|
||||
if (e->dest == EXIT_BLOCK_PTR)
|
||||
continue;
|
||||
|
||||
insn = e->dest->head;
|
||||
if (GET_CODE (insn) == CODE_LABEL)
|
||||
insn = NEXT_INSN (insn);
|
||||
insn = first_insn_after_basic_block_note (e->dest);
|
||||
|
||||
while (PHI_NODE_P (insn))
|
||||
{
|
||||
@ -1145,9 +1170,7 @@ eliminate_phi (e, reg_partition)
|
||||
|
||||
/* Collect an upper bound on the number of registers needing processing. */
|
||||
|
||||
insn = e->dest->head;
|
||||
if (GET_CODE (insn) == CODE_LABEL)
|
||||
insn = next_nonnote_insn (insn);
|
||||
insn = first_insn_after_basic_block_note (e->dest);
|
||||
|
||||
n_nodes = 0;
|
||||
while (PHI_NODE_P (insn))
|
||||
@ -1171,9 +1194,7 @@ eliminate_phi (e, reg_partition)
|
||||
sbitmap_vector_zero (pred, n_nodes);
|
||||
sbitmap_vector_zero (succ, n_nodes);
|
||||
|
||||
insn = e->dest->head;
|
||||
if (GET_CODE (insn) == CODE_LABEL)
|
||||
insn = next_nonnote_insn (insn);
|
||||
insn = first_insn_after_basic_block_note (e->dest);
|
||||
|
||||
n_nodes = 0;
|
||||
for (; PHI_NODE_P (insn); insn = next_nonnote_insn (insn))
|
||||
@ -1271,11 +1292,10 @@ make_regs_equivalent_over_bad_edges (bb, reg_partition)
|
||||
{
|
||||
int changed = 0;
|
||||
basic_block b = BASIC_BLOCK (bb);
|
||||
rtx phi = b->head;
|
||||
rtx phi;
|
||||
|
||||
/* Advance to the first phi node. */
|
||||
if (GET_CODE (phi) == CODE_LABEL)
|
||||
phi = next_nonnote_insn (phi);
|
||||
phi = first_insn_after_basic_block_note (b);
|
||||
|
||||
/* Scan all the phi nodes. */
|
||||
for (;
|
||||
@ -1341,12 +1361,11 @@ make_equivalent_phi_alternatives_equivalent (bb, reg_partition)
|
||||
partition reg_partition;
|
||||
{
|
||||
int changed = 0;
|
||||
rtx phi = BLOCK_HEAD (bb);
|
||||
basic_block b = BASIC_BLOCK (bb);
|
||||
rtx phi;
|
||||
|
||||
/* Advance to the first phi node. */
|
||||
if (GET_CODE (phi) == CODE_LABEL)
|
||||
phi = next_nonnote_insn (phi);
|
||||
phi = first_insn_after_basic_block_note (b);
|
||||
|
||||
/* Scan all the phi nodes. */
|
||||
for (;
|
||||
@ -1889,23 +1908,27 @@ convert_from_ssa()
|
||||
for (bb = n_basic_blocks; --bb >= 0; )
|
||||
{
|
||||
rtx insn = BLOCK_HEAD (bb);
|
||||
int start = (GET_CODE (insn) != CODE_LABEL);
|
||||
|
||||
if (! start)
|
||||
insn = next_nonnote_insn (insn);
|
||||
while (PHI_NODE_P (insn))
|
||||
while (1)
|
||||
{
|
||||
/* If a phi node is the last insn in the block, there must
|
||||
have been nothing else. Set the block end to the block
|
||||
head. */
|
||||
if (insn == BLOCK_END (bb))
|
||||
BLOCK_END (bb) = BLOCK_HEAD (bb);
|
||||
insn = delete_insn (insn);
|
||||
if (GET_CODE (insn) == NOTE)
|
||||
insn = next_nonnote_insn (insn);
|
||||
/* If this is a PHI node delete it. */
|
||||
if (PHI_NODE_P (insn))
|
||||
{
|
||||
if (insn == BLOCK_END (bb))
|
||||
BLOCK_END (bb) = PREV_INSN (insn);
|
||||
insn = delete_insn (insn);
|
||||
}
|
||||
/* Since all the phi nodes come at the beginning of the
|
||||
block, if we find an ordinary insn, we can stop looking
|
||||
for more phi nodes. */
|
||||
else if (INSN_P (insn))
|
||||
break;
|
||||
/* If we've reached the end of the block, stop. */
|
||||
else if (insn == BLOCK_END (bb))
|
||||
break;
|
||||
else
|
||||
insn = NEXT_INSN (insn);
|
||||
}
|
||||
if (start)
|
||||
BLOCK_HEAD (bb) = insn;
|
||||
}
|
||||
|
||||
/* Commit all the copy nodes needed to convert out of SSA form. */
|
||||
@ -1947,11 +1970,7 @@ for_each_successor_phi (bb, fn, data)
|
||||
continue;
|
||||
|
||||
/* Advance to the first non-label insn of the successor block. */
|
||||
insn = successor->head;
|
||||
while (insn != NULL
|
||||
&& (GET_CODE (insn) == CODE_LABEL
|
||||
|| GET_CODE (insn) == NOTE))
|
||||
insn = NEXT_INSN (insn);
|
||||
insn = first_insn_after_basic_block_note (successor);
|
||||
|
||||
if (insn == NULL)
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user