summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-21 21:02:34 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-21 21:02:34 +0000
commitc093ac49fcb3f639905b55c25217fcf2d905189f (patch)
treedb7f3c0f53d71518c200853007e36b9008ea6916
parentc6e40a4340707f803a1f5ffcd048677c309f7278 (diff)
downloadgcc-c093ac49fcb3f639905b55c25217fcf2d905189f.tar.gz
cfgcleanup.c: Use rtx_insn (also touches basic-block.h and ifcvt.c)
gcc/ 2014-08-21 David Malcolm <dmalcolm@redhat.com> * basic-block.h (flow_find_cross_jump): Strengthen params 3 and 4 "f1" and "f2" from rtx * to rtx_insn **. (flow_find_head_matching_sequence): Likewise. * cfgcleanup.c (try_simplify_condjump): Strengthen local "cbranch_insn" from rtx to rtx_insn *. (thread_jump): Likewise for local "insn". (try_forward_edges): Likewise for local "last". (merge_blocks_move_predecessor_nojumps): Likewise for local "barrier". (merge_blocks_move_successor_nojumps): Likewise for locals "barrier", "real_b_end". (can_replace_by): Likewise for params "i1", "i2". (old_insns_match_p): Likewise. (merge_notes): Likewise. (walk_to_nondebug_insn): Likewise for param "i1". (flow_find_cross_jump): Strengthen params "f1" and "f2" from rtx * to rtx_insn **. Strengthen locals "i1", "i2", "last1", "last2", "afterlast1", "afterlast2" from rtx to rtx_insn *. (flow_find_head_matching_sequence): Strengthen params "f1" and "f2" from rtx * to rtx_insn **. Strengthen locals "i1", "i2", "last1", "last2", "beforelast1", "beforelast2" from rtx to rtx_insn *. (outgoing_edges_match): Likewise for locals "last1", "last2". (try_crossjump_to_edge): Likewise for local "insn". Replace call to for_each_rtx with for_each_rtx_in_insn. (try_crossjump_to_edge): Likewise for locals "newpos1", "newpos2". (try_head_merge_bb): Likewise for locals "e0_last_head_, "jump", "e0_last", "e_last", "head", "curr", "insn". Strengthen locals "headptr", "currptr", "nextptr" from rtx * to rtx_insn **. (try_optimize_cfg): Strengthen local "last" from rtx to rtx_insn *. (delete_dead_jumptables): Likewise for locals "insn", "next", "label". * ifcvt.c (cond_exec_process_if_block): Likewise for locals "rtx then_last_head", "rtx else_last_head", "rtx then_first_tail", "rtx else_first_tail", to reflect the basic-block.h changes above. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@214292 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog41
-rw-r--r--gcc/basic-block.h6
-rw-r--r--gcc/cfgcleanup.c82
-rw-r--r--gcc/ifcvt.c8
4 files changed, 90 insertions, 47 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 374d7187997..5fd1b9cf15f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,46 @@
2014-08-21 David Malcolm <dmalcolm@redhat.com>
+ * basic-block.h (flow_find_cross_jump): Strengthen params 3 and 4
+ "f1" and "f2" from rtx * to rtx_insn **.
+ (flow_find_head_matching_sequence): Likewise.
+
+ * cfgcleanup.c (try_simplify_condjump): Strengthen local
+ "cbranch_insn" from rtx to rtx_insn *.
+ (thread_jump): Likewise for local "insn".
+ (try_forward_edges): Likewise for local "last".
+ (merge_blocks_move_predecessor_nojumps): Likewise for local "barrier".
+ (merge_blocks_move_successor_nojumps): Likewise for locals "barrier",
+ "real_b_end".
+ (can_replace_by): Likewise for params "i1", "i2".
+ (old_insns_match_p): Likewise.
+ (merge_notes): Likewise.
+ (walk_to_nondebug_insn): Likewise for param "i1".
+ (flow_find_cross_jump): Strengthen params "f1" and "f2" from rtx *
+ to rtx_insn **. Strengthen locals "i1", "i2", "last1", "last2",
+ "afterlast1", "afterlast2" from rtx to rtx_insn *.
+ (flow_find_head_matching_sequence): Strengthen params "f1" and
+ "f2" from rtx * to rtx_insn **. Strengthen locals "i1", "i2",
+ "last1", "last2", "beforelast1", "beforelast2" from rtx to
+ rtx_insn *.
+ (outgoing_edges_match): Likewise for locals "last1", "last2".
+ (try_crossjump_to_edge): Likewise for local "insn".
+ Replace call to for_each_rtx with for_each_rtx_in_insn.
+
+ (try_crossjump_to_edge): Likewise for locals "newpos1", "newpos2".
+ (try_head_merge_bb): Likewise for locals "e0_last_head_, "jump",
+ "e0_last", "e_last", "head", "curr", "insn". Strengthen locals
+ "headptr", "currptr", "nextptr" from rtx * to rtx_insn **.
+ (try_optimize_cfg): Strengthen local "last" from rtx to
+ rtx_insn *.
+ (delete_dead_jumptables): Likewise for locals "insn", "next",
+ "label".
+
+ * ifcvt.c (cond_exec_process_if_block): Likewise for locals
+ "rtx then_last_head", "rtx else_last_head", "rtx then_first_tail",
+ "rtx else_first_tail", to reflect the basic-block.h changes above.
+
+2014-08-21 David Malcolm <dmalcolm@redhat.com>
+
* cfgbuild.c (make_edges): Strengthen local "insn" from rtx to
rtx_insn *.
(purge_dead_tablejump_edges): Likewise.
diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index e3011da8fe3..fc931f128bb 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -821,10 +821,10 @@ enum replace_direction { dir_none, dir_forward, dir_backward, dir_both };
/* In cfgcleanup.c. */
extern bool cleanup_cfg (int);
-extern int flow_find_cross_jump (basic_block, basic_block, rtx *, rtx *,
- enum replace_direction*);
+extern int flow_find_cross_jump (basic_block, basic_block, rtx_insn **,
+ rtx_insn **, enum replace_direction*);
extern int flow_find_head_matching_sequence (basic_block, basic_block,
- rtx *, rtx *, int);
+ rtx_insn **, rtx_insn **, int);
extern bool delete_unreachable_blocks (void);
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 9f43912320d..17426cc5591 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -70,7 +70,7 @@ static bool block_was_dirty;
static bool try_crossjump_to_edge (int, edge, edge, enum replace_direction);
static bool try_crossjump_bb (int, basic_block);
static bool outgoing_edges_match (int, basic_block, basic_block);
-static enum replace_direction old_insns_match_p (int, rtx, rtx);
+static enum replace_direction old_insns_match_p (int, rtx_insn *, rtx_insn *);
static void merge_blocks_move_predecessor_nojumps (basic_block, basic_block);
static void merge_blocks_move_successor_nojumps (basic_block, basic_block);
@@ -115,7 +115,7 @@ try_simplify_condjump (basic_block cbranch_block)
{
basic_block jump_block, jump_dest_block, cbranch_dest_block;
edge cbranch_jump_edge, cbranch_fallthru_edge;
- rtx cbranch_insn;
+ rtx_insn *cbranch_insn;
/* Verify that there are exactly two successors. */
if (EDGE_COUNT (cbranch_block->succs) != 2)
@@ -265,7 +265,8 @@ mentions_nonequal_regs (rtx *x, void *data)
static edge
thread_jump (edge e, basic_block b)
{
- rtx set1, set2, cond1, cond2, insn;
+ rtx set1, set2, cond1, cond2;
+ rtx_insn *insn;
enum rtx_code code1, code2, reversed_code2;
bool reverse1 = false;
unsigned i;
@@ -492,7 +493,7 @@ try_forward_edges (int mode, basic_block b)
if (LOCATION_LOCUS (new_locus) != UNKNOWN_LOCATION)
locus = new_locus;
- rtx last = BB_END (target);
+ rtx_insn *last = BB_END (target);
if (DEBUG_INSN_P (last))
last = prev_nondebug_insn (last);
if (last && INSN_P (last))
@@ -659,7 +660,7 @@ try_forward_edges (int mode, basic_block b)
static void
merge_blocks_move_predecessor_nojumps (basic_block a, basic_block b)
{
- rtx barrier;
+ rtx_insn *barrier;
/* If we are partitioning hot/cold basic blocks, we don't want to
mess up unconditional or indirect jumps that cross between hot
@@ -703,7 +704,7 @@ merge_blocks_move_predecessor_nojumps (basic_block a, basic_block b)
static void
merge_blocks_move_successor_nojumps (basic_block a, basic_block b)
{
- rtx barrier, real_b_end;
+ rtx_insn *barrier, *real_b_end;
rtx label;
rtx_jump_table_data *table;
@@ -1014,7 +1015,7 @@ equal_different_set_p (rtx p1, rtx s1, rtx p2, rtx s2)
- dir_both if both are the case. */
static enum replace_direction
-can_replace_by (rtx i1, rtx i2)
+can_replace_by (rtx_insn *i1, rtx_insn *i2)
{
rtx s1, s2, d1, d2, src1, src2, note1, note2;
bool c1, c2;
@@ -1093,7 +1094,7 @@ merge_dir (enum replace_direction a, enum replace_direction b)
- dir_both if both are the case. */
static enum replace_direction
-old_insns_match_p (int mode ATTRIBUTE_UNUSED, rtx i1, rtx i2)
+old_insns_match_p (int mode ATTRIBUTE_UNUSED, rtx_insn *i1, rtx_insn *i2)
{
rtx p1, p2;
@@ -1224,7 +1225,7 @@ old_insns_match_p (int mode ATTRIBUTE_UNUSED, rtx i1, rtx i2)
flow_find_head_matching_sequence, ensure the notes match. */
static void
-merge_notes (rtx i1, rtx i2)
+merge_notes (rtx_insn *i1, rtx_insn *i2)
{
/* If the merged insns have different REG_EQUAL notes, then
remove them. */
@@ -1250,7 +1251,7 @@ merge_notes (rtx i1, rtx i2)
DID_FALLTHRU. Otherwise, stops at the head of the bb. */
static void
-walk_to_nondebug_insn (rtx *i1, basic_block *bb1, bool follow_fallthru,
+walk_to_nondebug_insn (rtx_insn **i1, basic_block *bb1, bool follow_fallthru,
bool *did_fallthru)
{
edge fallthru;
@@ -1293,10 +1294,10 @@ walk_to_nondebug_insn (rtx *i1, basic_block *bb1, bool follow_fallthru,
store the head of the blocks in *F1 and *F2. */
int
-flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2,
- enum replace_direction *dir_p)
+flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx_insn **f1,
+ rtx_insn **f2, enum replace_direction *dir_p)
{
- rtx i1, i2, last1, last2, afterlast1, afterlast2;
+ rtx_insn *i1, *i2, *last1, *last2, *afterlast1, *afterlast2;
int ninsns = 0;
enum replace_direction dir, last_dir, afterlast_dir;
bool follow_fallthru, did_fallthru;
@@ -1312,7 +1313,7 @@ flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2,
need to be compared for equivalence, which we'll do below. */
i1 = BB_END (bb1);
- last1 = afterlast1 = last2 = afterlast2 = NULL_RTX;
+ last1 = afterlast1 = last2 = afterlast2 = NULL;
if (onlyjump_p (i1)
|| (returnjump_p (i1) && !side_effects_p (PATTERN (i1))))
{
@@ -1428,10 +1429,10 @@ flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2,
non-zero, only count active insns. */
int
-flow_find_head_matching_sequence (basic_block bb1, basic_block bb2, rtx *f1,
- rtx *f2, int stop_after)
+flow_find_head_matching_sequence (basic_block bb1, basic_block bb2, rtx_insn **f1,
+ rtx_insn **f2, int stop_after)
{
- rtx i1, i2, last1, last2, beforelast1, beforelast2;
+ rtx_insn *i1, *i2, *last1, *last2, *beforelast1, *beforelast2;
int ninsns = 0;
edge e;
edge_iterator ei;
@@ -1446,7 +1447,7 @@ flow_find_head_matching_sequence (basic_block bb1, basic_block bb2, rtx *f1,
i1 = BB_HEAD (bb1);
i2 = BB_HEAD (bb2);
- last1 = beforelast1 = last2 = beforelast2 = NULL_RTX;
+ last1 = beforelast1 = last2 = beforelast2 = NULL;
while (true)
{
@@ -1751,8 +1752,8 @@ outgoing_edges_match (int mode, basic_block bb1, basic_block bb2)
stop when we see the NOTE_INSN_BASIC_BLOCK, as old_insns_match_p
handles that case specially. old_insns_match_p does not handle
other types of instruction notes. */
- rtx last1 = BB_END (bb1);
- rtx last2 = BB_END (bb2);
+ rtx_insn *last1 = BB_END (bb1);
+ rtx_insn *last2 = BB_END (bb2);
while (!NOTE_INSN_BASIC_BLOCK_P (last1) &&
(DEBUG_INSN_P (last1) || NOTE_P (last1)))
last1 = PREV_INSN (last1);
@@ -1884,11 +1885,11 @@ try_crossjump_to_edge (int mode, edge e1, edge e2,
basic_block src1 = e1->src, src2 = e2->src;
basic_block redirect_to, redirect_from, to_remove;
basic_block osrc1, osrc2, redirect_edges_to, tmp;
- rtx newpos1, newpos2;
+ rtx_insn *newpos1, *newpos2;
edge s;
edge_iterator ei;
- newpos1 = newpos2 = NULL_RTX;
+ newpos1 = newpos2 = NULL;
/* If we have partitioned hot/cold basic blocks, it is a bad idea
to try this optimization.
@@ -1955,7 +1956,7 @@ try_crossjump_to_edge (int mode, edge e1, edge e2,
SWAP (basic_block, osrc1, osrc2);
SWAP (basic_block, src1, src2);
SWAP (edge, e1, e2);
- SWAP (rtx, newpos1, newpos2);
+ SWAP (rtx_insn *, newpos1, newpos2);
#undef SWAP
}
@@ -1986,7 +1987,7 @@ try_crossjump_to_edge (int mode, edge e1, edge e2,
&& label1 != label2)
{
replace_label_data rr;
- rtx insn;
+ rtx_insn *insn;
/* Replace references to LABEL1 with LABEL2. */
rr.r1 = label1;
@@ -1998,7 +1999,7 @@ try_crossjump_to_edge (int mode, edge e1, edge e2,
a block whose end is a tablejump, the tablejump referenced
from the instruction is deleted too. */
if (insn != BB_END (osrc1))
- for_each_rtx (&insn, replace_label, &rr);
+ for_each_rtx_in_insn (&insn, replace_label, &rr);
}
}
}
@@ -2286,12 +2287,13 @@ try_head_merge_bb (basic_block bb)
basic_block final_dest_bb = NULL;
int max_match = INT_MAX;
edge e0;
- rtx *headptr, *currptr, *nextptr;
+ rtx_insn **headptr, **currptr, **nextptr;
bool changed, moveall;
unsigned ix;
- rtx e0_last_head, cond, move_before;
+ rtx_insn *e0_last_head;
+ rtx cond, move_before;
unsigned nedges = EDGE_COUNT (bb->succs);
- rtx jump = BB_END (bb);
+ rtx_insn *jump = BB_END (bb);
regset live, live_union;
/* Nothing to do if there is not at least two outgoing edges. */
@@ -2381,13 +2383,13 @@ try_head_merge_bb (basic_block bb)
}
e0 = EDGE_SUCC (bb, 0);
- e0_last_head = NULL_RTX;
+ e0_last_head = NULL;
changed = false;
for (ix = 1; ix < nedges; ix++)
{
edge e = EDGE_SUCC (bb, ix);
- rtx e0_last, e_last;
+ rtx_insn *e0_last, *e_last;
int nmatch;
nmatch = flow_find_head_matching_sequence (e0->dest, e->dest,
@@ -2424,15 +2426,15 @@ try_head_merge_bb (basic_block bb)
live = BITMAP_ALLOC (NULL);
live_union = BITMAP_ALLOC (NULL);
- currptr = XNEWVEC (rtx, nedges);
- headptr = XNEWVEC (rtx, nedges);
- nextptr = XNEWVEC (rtx, nedges);
+ currptr = XNEWVEC (rtx_insn *, nedges);
+ headptr = XNEWVEC (rtx_insn *, nedges);
+ nextptr = XNEWVEC (rtx_insn *, nedges);
for (ix = 0; ix < nedges; ix++)
{
int j;
basic_block merge_bb = EDGE_SUCC (bb, ix)->dest;
- rtx head = BB_HEAD (merge_bb);
+ rtx_insn *head = BB_HEAD (merge_bb);
while (!NONDEBUG_INSN_P (head))
head = NEXT_INSN (head);
@@ -2522,7 +2524,7 @@ try_head_merge_bb (basic_block bb)
break;
for (ix = 0; ix < nedges; ix++)
{
- rtx curr = currptr[ix];
+ rtx_insn *curr = currptr[ix];
do
curr = NEXT_INSN (curr);
while (!NONDEBUG_INSN_P (curr));
@@ -2535,7 +2537,7 @@ try_head_merge_bb (basic_block bb)
if (!moveall)
for (ix = 0; ix < nedges; ix++)
{
- rtx curr = currptr[ix];
+ rtx_insn *curr = currptr[ix];
do
curr = NEXT_INSN (curr);
while (!NONDEBUG_INSN_P (curr));
@@ -2589,7 +2591,7 @@ try_head_merge_bb (basic_block bb)
static bool
trivially_empty_bb_p (basic_block bb)
{
- rtx insn = BB_END (bb);
+ rtx_insn *insn = BB_END (bb);
while (1)
{
@@ -2687,7 +2689,7 @@ try_optimize_cfg (int mode)
}
else
{
- rtx last = get_last_bb_insn (b);
+ rtx_insn *last = get_last_bb_insn (b);
if (last && BARRIER_P (last))
FOR_EACH_EDGE (e, ei, b->preds)
if ((e->flags & EDGE_FALLTHRU))
@@ -2961,7 +2963,7 @@ delete_dead_jumptables (void)
between two adjacent basic blocks. */
FOR_EACH_BB_FN (bb, cfun)
{
- rtx insn, next;
+ rtx_insn *insn, *next;
for (insn = NEXT_INSN (BB_END (bb));
insn && !NOTE_INSN_BASIC_BLOCK_P (insn);
@@ -2972,7 +2974,7 @@ delete_dead_jumptables (void)
&& LABEL_NUSES (insn) == LABEL_PRESERVE_P (insn)
&& JUMP_TABLE_DATA_P (next))
{
- rtx label = insn, jump = next;
+ rtx_insn *label = insn, *jump = next;
if (dump_file)
fprintf (dump_file, "Dead jumptable %i removed\n",
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 8e0f3bd63c6..c1894bb5c6f 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -476,10 +476,10 @@ cond_exec_process_if_block (ce_if_block * ce_info,
rtx false_expr; /* test for then block insns */
int true_prob_val; /* probability of else block */
int false_prob_val; /* probability of then block */
- rtx then_last_head = NULL_RTX; /* Last match at the head of THEN */
- rtx else_last_head = NULL_RTX; /* Last match at the head of ELSE */
- rtx then_first_tail = NULL_RTX; /* First match at the tail of THEN */
- rtx else_first_tail = NULL_RTX; /* First match at the tail of ELSE */
+ rtx_insn *then_last_head = NULL; /* Last match at the head of THEN */
+ rtx_insn *else_last_head = NULL; /* Last match at the head of ELSE */
+ rtx_insn *then_first_tail = NULL; /* First match at the tail of THEN */
+ rtx_insn *else_first_tail = NULL; /* First match at the tail of ELSE */
int then_n_insns, else_n_insns, n_insns;
enum rtx_code false_code;
rtx note;