+2005-03-11 Zdenek Dvorak <dvorakz@suse.cz>
+
+ * basic-block.h (single_succ_p, single_pred_p, single_succ_edge,
+ single_pred_edge, single_succ, single_pred): New inline functions.
+ * bb-reorder.c (rotate_loop, find_traces_1_round,
+ add_labels_and_missing_jumps, fix_up_fall_thru_edges,
+ duplicate_computed_gotos): Use the single_succ/pred functions.
+ * cfganal.c (forwarder_block_p): Ditto.
+ * cfgbuild.c (compute_outgoing_frequencies): Ditto.
+ * cfgcleanup.c (try_simplify_condjump, try_forward_edges,
+ outgoing_edges_match, try_crossjump_to_edge, try_optimize_cfg,
+ merge_seq_blocks): Ditto.
+ * cfghooks.c (split_edge, tidy_fallthru_edges): Ditto.
+ * cfglayout.c (fixup_reorder_chain): Ditto.
+ * cfgloop.c (mark_single_exit_loops, update_latch_info,
+ canonicalize_loop_headers, verify_loop_structure): Ditto.
+ * cfgloopmanip.c (remove_path, unloop, loop_delete_branch_edge,
+ mfb_update_loops, create_preheader, force_single_succ_latches,
+ create_loop_notes): Ditto.
+ * cfgrtl.c (rtl_can_merge_blocks, try_redirect_by_replacing_jump,
+ force_nonfallthru_and_redirect, rtl_tidy_fallthru_edge,
+ commit_one_edge_insertion, purge_dead_edges,
+ cfg_layout_can_merge_blocks_p): Ditto.
+ * except.c (sjlj_emit_function_enter): Ditto.
+ * flow.c (init_propagate_block_info): Ditto.
+ * function.c (thread_prologue_and_epilogue_insns): Ditto.
+ * gcse.c (find_implicit_sets, bypass_conditional_jumps,
+ insert_insn_end_bb): Ditto.
+ * ifcvt.c (merge_if_block, find_if_block, find_if_case_1,
+ find_if_case_2): Ditto.
+ * lambda-code.c (perfect_nestify): Ditto.
+ * lcm.c (optimize_mode_switching): Ditto.
+ * loop-doloop.c (doloop_modify): Ditto.
+ * loop-init.c (loop_optimizer_init): Ditto.
+ * loop-iv.c (simplify_using_initial_values): Ditto.
+ * loop-unroll.c (unroll_loop_runtime_iterations): Ditto.
+ * loop-unswitch.c (unswitch_loop): Ditto.
+ * modulo-sched.c (generate_prolog_epilog): Ditto.
+ * predict.c (combine_predictions_for_insn, estimate_probability,
+ tree_estimate_probability, last_basic_block_p,
+ estimate_bb_frequencies): Ditto.
+ * profile.c (branch_prob): Ditto.
+ * regrename.c (copyprop_hardreg_forward): Ditto.
+ * sched-rgn.c (is_cfg_nonregular, find_rgns, update_live): Ditto.
+ * tracer.c (layout_superblocks): Ditto.
+ * tree-cfg.c (tree_can_merge_blocks_p, tree_merge_blocks,
+ cfg_remove_useless_stmts_bb, cleanup_control_flow,
+ cleanup_control_expr_graph, disband_implicit_edges,
+ tree_find_edge_insert_loc, bsi_commit_edge_inserts,
+ tree_verify_flow_info, tree_make_forwarder_block,
+ tree_forwarder_block_p, remove_forwarder_block,
+ remove_forwarder_block_with_phi, merge_phi_nodes): Ditto.
+ * tree-if-conv.c (tree_if_conversion): Ditto.
+ * tree-mudflap.c (mf_build_check_statement_for): Ditto.
+ * tree-ssa-dce.c (remove_dead_stmt): Ditto.
+ * tree-ssa-dom.c (dom_opt_finalize_block): Ditto.
+ * tree-ssa-loop-ch.c (should_duplicate_loop_header_p,
+ copy_loop_headers): Ditto.
+ * tree-ssa-loop-im.c (loop_commit_inserts): Ditto.
+ * tree-ssa-loop-ivopts.c (compute_phi_arg_on_exit): Ditto.
+ * tree-ssa-loop-manip.c (split_loop_exit_edge, ip_normal_pos,
+ lv_adjust_loop_entry_edge, tree_ssa_loop_version): Ditto.
+ * tree-ssa-loop-niter.c (simplify_using_initial_conditions): Ditto.
+ * tree-ssa-loop-unswitch.c (simplify_using_entry_checks): Ditto.
+ * tree-ssa-phiopt.c (tree_ssa_phiopt, value_replacement): Ditto.
+ * tree-ssa-pre.c (compute_antic_aux, insert_aux, init_pre): Ditto.
+ * tree-ssa-threadupdate.c (redirect_edges): Ditto.
+ * tree-tailcall.c (independent_of_stmt_p, find_tail_calls,
+ eliminate_tail_call, tree_optimize_tail_calls_1): Ditto.
+ * tree-vect-analyze.c (vect_analyze_loop_form): Ditto.
+ * tree-vect-transform.c (vect_update_ivs_after_vectorizer): Ditto.
+ * tree-vectorizer.c (slpeel_update_phi_nodes_for_guard,
+ slpeel_add_loop_guard): Ditto.
+
2005-03-11 James A. Morrison <phython@gcc.gnu.org>
PR tree-optimization/15784
#define EDGE_PRED(bb,i) VEC_index (edge, (bb)->preds, (i))
#define EDGE_SUCC(bb,i) VEC_index (edge, (bb)->succs, (i))
+/* Returns true if BB has precisely one successor. */
+
+static inline bool
+single_succ_p (basic_block bb)
+{
+ return EDGE_COUNT (bb->succs) == 1;
+}
+
+/* Returns true if BB has precisely one predecessor. */
+
+static inline bool
+single_pred_p (basic_block bb)
+{
+ return EDGE_COUNT (bb->preds) == 1;
+}
+
+/* Returns the single successor edge of basic block BB. */
+
+static inline edge
+single_succ_edge (basic_block bb)
+{
+ gcc_assert (single_succ_p (bb));
+ return EDGE_SUCC (bb, 0);
+}
+
+/* Returns the single predecessor edge of basic block BB. */
+
+static inline edge
+single_pred_edge (basic_block bb)
+{
+ gcc_assert (single_pred_p (bb));
+ return EDGE_PRED (bb, 0);
+}
+
+/* Returns the single successor block of basic block BB. */
+
+static inline basic_block
+single_succ (basic_block bb)
+{
+ return single_succ_edge (bb)->dest;
+}
+
+/* Returns the single predecessor block of basic block BB. */
+
+static inline basic_block
+single_pred (basic_block bb)
+{
+ return single_pred_edge (bb)->src;
+}
+
/* Iterator object for edges. */
typedef struct {
prev_bb->rbi->next = best_bb->rbi->next;
/* Try to get rid of uncond jump to cond jump. */
- if (EDGE_COUNT (prev_bb->succs) == 1)
+ if (single_succ_p (prev_bb))
{
- basic_block header = EDGE_SUCC (prev_bb, 0)->dest;
+ basic_block header = single_succ (prev_bb);
/* Duplicate HEADER if it is a small block containing cond jump
in the end. */
if (any_condjump_p (BB_END (header)) && copy_bb_p (header, 0)
&& !find_reg_note (BB_END (header), REG_CROSSING_JUMP,
NULL_RTX))
- {
- copy_bb (header, EDGE_SUCC (prev_bb, 0), prev_bb, trace_n);
- }
+ copy_bb (header, single_succ_edge (prev_bb), prev_bb, trace_n);
}
}
}
{
/* The loop has less than 4 iterations. */
- if (EDGE_COUNT (bb->succs) == 1
+ if (single_succ_p (bb)
&& copy_bb_p (best_edge->dest, !optimize_size))
{
bb = copy_bb (best_edge->dest, best_edge, bb,
&& (e->flags & EDGE_CAN_FALLTHRU)
&& !(e->flags & EDGE_COMPLEX)
&& !e->dest->rbi->visited
- && EDGE_COUNT (e->dest->preds) == 1
+ && single_pred_p (e->dest)
&& !(e->flags & EDGE_CROSSING)
- && EDGE_COUNT (e->dest->succs) == 1
- && (EDGE_SUCC (e->dest, 0)->flags & EDGE_CAN_FALLTHRU)
- && !(EDGE_SUCC (e->dest, 0)->flags & EDGE_COMPLEX)
- && EDGE_SUCC (e->dest, 0)->dest == best_edge->dest
+ && single_succ_p (e->dest) == 1
+ && (single_succ_edge (e->dest)->flags
+ & EDGE_CAN_FALLTHRU)
+ && !(single_succ_edge (e->dest)->flags & EDGE_COMPLEX)
+ && single_succ (e->dest) == best_edge->dest
&& 2 * e->dest->frequency >= EDGE_FREQUENCY (best_edge))
{
best_edge = e;
/* bb just falls through. */
{
/* make sure there's only one successor */
- gcc_assert (EDGE_COUNT (src->succs) == 1);
+ gcc_assert (single_succ_p (src));
/* Find label in dest block. */
label = block_label (dest);
partition as bb it's falling through from. */
BB_COPY_PARTITION (new_bb, cur_bb);
- EDGE_SUCC (new_bb, 0)->flags |= EDGE_CROSSING;
+ single_succ_edge (new_bb)->flags |= EDGE_CROSSING;
}
/* Add barrier after new jump */
/* BB must have one outgoing edge. That edge must not lead to
the exit block or the next block.
The destination must have more than one predecessor. */
- if (EDGE_COUNT(bb->succs) != 1
- || EDGE_SUCC(bb,0)->dest == EXIT_BLOCK_PTR
- || EDGE_SUCC(bb,0)->dest == bb->next_bb
- || EDGE_COUNT(EDGE_SUCC(bb,0)->dest->preds) <= 1)
+ if (!single_succ_p (bb)
+ || single_succ (bb) == EXIT_BLOCK_PTR
+ || single_succ (bb) == bb->next_bb
+ || single_pred_p (single_succ (bb)))
continue;
/* The successor block has to be a duplication candidate. */
- if (!bitmap_bit_p (candidates, EDGE_SUCC(bb,0)->dest->index))
+ if (!bitmap_bit_p (candidates, single_succ (bb)->index))
continue;
- new_bb = duplicate_block (EDGE_SUCC(bb,0)->dest, EDGE_SUCC(bb,0));
+ new_bb = duplicate_block (single_succ (bb), single_succ_edge (bb));
new_bb->rbi->next = bb->rbi->next;
bb->rbi->next = new_bb;
new_bb->rbi->visited = 1;
rtx insn;
if (bb == EXIT_BLOCK_PTR || bb == ENTRY_BLOCK_PTR
- || EDGE_COUNT (bb->succs) != 1)
+ || !single_succ_p (bb))
return false;
for (insn = BB_HEAD (bb); insn != BB_END (bb); insn = NEXT_INSN (insn))
}
}
- if (EDGE_COUNT (b->succs) == 1)
+ if (single_succ_p (b))
{
- e = EDGE_SUCC (b, 0);
+ e = single_succ_edge (b);
e->probability = REG_BR_PROB_BASE;
e->count = b->count;
return;
be the last block in the function, and must contain just the
unconditional jump. */
jump_block = cbranch_fallthru_edge->dest;
- if (EDGE_COUNT (jump_block->preds) >= 2
+ if (!single_pred_p (jump_block)
|| jump_block->next_bb == EXIT_BLOCK_PTR
|| !FORWARDER_BLOCK_P (jump_block))
return false;
- jump_dest_block = EDGE_SUCC (jump_block, 0)->dest;
+ jump_dest_block = single_succ (jump_block);
/* If we are partitioning hot/cold basic blocks, we don't want to
mess up unconditional or indirect jumps that cross between hot
may_thread |= target->flags & BB_DIRTY;
if (FORWARDER_BLOCK_P (target)
- && !(EDGE_SUCC (target, 0)->flags & EDGE_CROSSING)
- && EDGE_SUCC (target, 0)->dest != EXIT_BLOCK_PTR)
+ && !(single_succ_edge (target)->flags & EDGE_CROSSING)
+ && single_succ (target) != EXIT_BLOCK_PTR)
{
/* Bypass trivial infinite loops. */
- if (target == EDGE_SUCC (target, 0)->dest)
+ new_target = single_succ (target);
+ if (target == new_target)
counter = n_basic_blocks;
- new_target = EDGE_SUCC (target, 0)->dest;
}
/* Allow to thread only over one edge at time to simplify updating
{
edge t;
- if (EDGE_COUNT (first->succs) > 1)
+ if (!single_succ_p (first))
{
gcc_assert (n < nthreaded_edges);
t = threaded_edges [n++];
if (n < nthreaded_edges
&& first == threaded_edges [n]->src)
n++;
- t = EDGE_SUCC (first, 0);
+ t = single_succ_edge (first);
}
t->count -= edge_count;
/* If BB1 has only one successor, we may be looking at either an
unconditional jump, or a fake edge to exit. */
- if (EDGE_COUNT (bb1->succs) == 1
- && (EDGE_SUCC (bb1, 0)->flags & (EDGE_COMPLEX | EDGE_FAKE)) == 0
+ if (single_succ_p (bb1)
+ && (single_succ_edge (bb1)->flags & (EDGE_COMPLEX | EDGE_FAKE)) == 0
&& (!JUMP_P (BB_END (bb1)) || simplejump_p (BB_END (bb1))))
- return (EDGE_COUNT (bb2->succs) == 1
- && (EDGE_SUCC (bb2, 0)->flags & (EDGE_COMPLEX | EDGE_FAKE)) == 0
+ return (single_succ_p (bb2)
+ && (single_succ_edge (bb2)->flags
+ & (EDGE_COMPLEX | EDGE_FAKE)) == 0
&& (!JUMP_P (BB_END (bb2)) || simplejump_p (BB_END (bb2))));
/* Match conditional jumps - this may get tricky when fallthru and branch
/* Get around possible forwarders on fallthru edges. Other cases
should be optimized out already. */
if (FORWARDER_BLOCK_P (f1->dest))
- f1 = EDGE_SUCC (f1->dest, 0);
+ f1 = single_succ_edge (f1->dest);
if (FORWARDER_BLOCK_P (f2->dest))
- f2 = EDGE_SUCC (f2->dest, 0);
+ f2 = single_succ_edge (f2->dest);
/* To simplify use of this function, return false if there are
unneeded forwarder blocks. These will get eliminated later
if (fallthru1)
{
basic_block d1 = (forwarder_block_p (fallthru1->dest)
- ? EDGE_SUCC (fallthru1->dest, 0)->dest: fallthru1->dest);
+ ? single_succ (fallthru1->dest): fallthru1->dest);
basic_block d2 = (forwarder_block_p (fallthru2->dest)
- ? EDGE_SUCC (fallthru2->dest, 0)->dest: fallthru2->dest);
+ ? single_succ (fallthru2->dest): fallthru2->dest);
if (d1 != d2)
return false;
about multiple entry or chained forwarders, as they will be optimized
away. We do this to look past the unconditional jump following a
conditional jump that is required due to the current CFG shape. */
- if (EDGE_COUNT (src1->preds) == 1
+ if (single_pred_p (src1)
&& FORWARDER_BLOCK_P (src1))
- e1 = EDGE_PRED (src1, 0), src1 = e1->src;
+ e1 = single_pred_edge (src1), src1 = e1->src;
- if (EDGE_COUNT (src2->preds) == 1
+ if (single_pred_p (src2)
&& FORWARDER_BLOCK_P (src2))
- e2 = EDGE_PRED (src2, 0), src2 = e2->src;
+ e2 = single_pred_edge (src2), src2 = e2->src;
/* Nothing to do if we reach ENTRY, or a common source block. */
if (src1 == ENTRY_BLOCK_PTR || src2 == ENTRY_BLOCK_PTR)
/* Seeing more than 1 forwarder blocks would confuse us later... */
if (FORWARDER_BLOCK_P (e1->dest)
- && FORWARDER_BLOCK_P (EDGE_SUCC (e1->dest, 0)->dest))
+ && FORWARDER_BLOCK_P (single_succ (e1->dest)))
return false;
if (FORWARDER_BLOCK_P (e2->dest)
- && FORWARDER_BLOCK_P (EDGE_SUCC (e2->dest, 0)->dest))
+ && FORWARDER_BLOCK_P (single_succ (e2->dest)))
return false;
/* Likewise with dead code (possibly newly created by the other optimizations
basic_block d = s->dest;
if (FORWARDER_BLOCK_P (d))
- d = EDGE_SUCC (d, 0)->dest;
+ d = single_succ (d);
FOR_EACH_EDGE (s2, ei, src1->succs)
{
basic_block d2 = s2->dest;
if (FORWARDER_BLOCK_P (d2))
- d2 = EDGE_SUCC (d2, 0)->dest;
+ d2 = single_succ (d2);
if (d == d2)
break;
}
into infinite loop. */
if (FORWARDER_BLOCK_P (s->dest))
{
- EDGE_SUCC (s->dest, 0)->count += s2->count;
+ single_succ_edge (s->dest)->count += s2->count;
s->dest->count += s2->count;
s->dest->frequency += EDGE_FREQUENCY (s);
}
if (FORWARDER_BLOCK_P (s2->dest))
{
- EDGE_SUCC (s2->dest, 0)->count -= s2->count;
- if (EDGE_SUCC (s2->dest, 0)->count < 0)
- EDGE_SUCC (s2->dest, 0)->count = 0;
+ single_succ_edge (s2->dest)->count -= s2->count;
+ if (single_succ_edge (s2->dest)->count < 0)
+ single_succ_edge (s2->dest)->count = 0;
s2->dest->count -= s2->count;
s2->dest->frequency -= EDGE_FREQUENCY (s);
if (s2->dest->frequency < 0)
newpos1 = NEXT_INSN (newpos1);
redirect_from = split_block (src1, PREV_INSN (newpos1))->src;
- to_remove = EDGE_SUCC (redirect_from, 0)->dest;
+ to_remove = single_succ (redirect_from);
- redirect_edge_and_branch_force (EDGE_SUCC (redirect_from, 0), redirect_to);
+ redirect_edge_and_branch_force (single_succ_edge (redirect_from), redirect_to);
delete_basic_block (to_remove);
update_forwarder_flag (redirect_from);
}
/* Remove code labels no longer used. */
- if (EDGE_COUNT (b->preds) == 1
- && (EDGE_PRED (b, 0)->flags & EDGE_FALLTHRU)
- && !(EDGE_PRED (b, 0)->flags & EDGE_COMPLEX)
+ if (single_pred_p (b)
+ && (single_pred_edge (b)->flags & EDGE_FALLTHRU)
+ && !(single_pred_edge (b)->flags & EDGE_COMPLEX)
&& LABEL_P (BB_HEAD (b))
/* If the previous block ends with a branch to this
block, we can't delete the label. Normally this
if CASE_DROPS_THRU, this can be a tablejump with
some element going to the same place as the
default (fallthru). */
- && (EDGE_PRED (b, 0)->src == ENTRY_BLOCK_PTR
- || !JUMP_P (BB_END (EDGE_PRED (b, 0)->src))
+ && (single_pred (b) == ENTRY_BLOCK_PTR
+ || !JUMP_P (BB_END (single_pred (b)))
|| ! label_is_jump_target_p (BB_HEAD (b),
- BB_END (EDGE_PRED (b, 0)->src))))
+ BB_END (single_pred (b)))))
{
rtx label = BB_HEAD (b);
/* If we fall through an empty block, we can remove it. */
if (!(mode & CLEANUP_CFGLAYOUT)
- && EDGE_COUNT (b->preds) == 1
- && (EDGE_PRED (b, 0)->flags & EDGE_FALLTHRU)
+ && single_pred_p (b)
+ && (single_pred_edge (b)->flags & EDGE_FALLTHRU)
&& !LABEL_P (BB_HEAD (b))
&& FORWARDER_BLOCK_P (b)
/* Note that forwarder_block_p true ensures that
there is a successor for this block. */
- && (EDGE_SUCC (b, 0)->flags & EDGE_FALLTHRU)
+ && (single_succ_edge (b)->flags & EDGE_FALLTHRU)
&& n_basic_blocks > 1)
{
if (dump_file)
b->index);
c = b->prev_bb == ENTRY_BLOCK_PTR ? b->next_bb : b->prev_bb;
- redirect_edge_succ_nodup (EDGE_PRED (b, 0), EDGE_SUCC (b, 0)->dest);
+ redirect_edge_succ_nodup (single_pred_edge (b),
+ single_succ (b));
delete_basic_block (b);
changed = true;
b = c;
}
- if (EDGE_COUNT (b->succs) == 1
- && (s = EDGE_SUCC (b, 0))
+ if (single_succ_p (b)
+ && (s = single_succ_edge (b))
&& !(s->flags & EDGE_COMPLEX)
&& (c = s->dest) != EXIT_BLOCK_PTR
- && EDGE_COUNT (c->preds) == 1
+ && single_pred_p (c)
&& b != c)
{
/* When not in cfg_layout mode use code aware of reordering
non-trivial jump instruction without side-effects, we
can either delete the jump entirely, or replace it
with a simple unconditional jump. */
- if (EDGE_COUNT (b->succs) == 1
- && EDGE_SUCC (b, 0)->dest != EXIT_BLOCK_PTR
+ if (single_succ_p (b)
+ && single_succ (b) != EXIT_BLOCK_PTR
&& onlyjump_p (BB_END (b))
&& !find_reg_note (BB_END (b), REG_CROSSING_JUMP, NULL_RTX)
- && try_redirect_by_replacing_jump (EDGE_SUCC (b, 0), EDGE_SUCC (b, 0)->dest,
+ && try_redirect_by_replacing_jump (single_succ_edge (b),
+ single_succ (b),
(mode & CLEANUP_CFGLAYOUT) != 0))
{
update_forwarder_flag (b);
for (bb = ENTRY_BLOCK_PTR->next_bb; bb != EXIT_BLOCK_PTR; )
{
- if (EDGE_COUNT (bb->succs) == 1
- && can_merge_blocks_p (bb, EDGE_SUCC (bb, 0)->dest))
+ if (single_succ_p (bb)
+ && can_merge_blocks_p (bb, single_succ (bb)))
{
/* Merge the blocks and retry. */
- merge_blocks (bb, EDGE_SUCC (bb, 0)->dest);
+ merge_blocks (bb, single_succ (bb));
changed = true;
continue;
}
ret = cfg_hooks->split_edge (e);
ret->count = count;
ret->frequency = freq;
- EDGE_SUCC (ret, 0)->probability = REG_BR_PROB_BASE;
- EDGE_SUCC (ret, 0)->count = count;
+ single_succ_edge (ret)->probability = REG_BR_PROB_BASE;
+ single_succ_edge (ret)->count = count;
if (irr)
{
ret->flags |= BB_IRREDUCIBLE_LOOP;
- EDGE_PRED (ret, 0)->flags |= EDGE_IRREDUCIBLE_LOOP;
- EDGE_SUCC (ret, 0)->flags |= EDGE_IRREDUCIBLE_LOOP;
+ single_pred_edge (ret)->flags |= EDGE_IRREDUCIBLE_LOOP;
+ single_succ_edge (ret)->flags |= EDGE_IRREDUCIBLE_LOOP;
}
if (dom_computed[CDI_DOMINATORS])
- set_immediate_dominator (CDI_DOMINATORS, ret, EDGE_PRED (ret, 0)->src);
+ set_immediate_dominator (CDI_DOMINATORS, ret, single_pred (ret));
if (dom_computed[CDI_DOMINATORS] >= DOM_NO_FAST_QUERY)
{
ret, provided that all other predecessors of e->dest are
dominated by e->dest. */
- if (get_immediate_dominator (CDI_DOMINATORS, EDGE_SUCC (ret, 0)->dest)
- == EDGE_PRED (ret, 0)->src)
+ if (get_immediate_dominator (CDI_DOMINATORS, single_succ (ret))
+ == single_pred (ret))
{
edge_iterator ei;
- FOR_EACH_EDGE (f, ei, EDGE_SUCC (ret, 0)->dest->preds)
+ FOR_EACH_EDGE (f, ei, single_succ (ret)->preds)
{
- if (f == EDGE_SUCC (ret, 0))
+ if (f == single_succ_edge (ret))
continue;
if (!dominated_by_p (CDI_DOMINATORS, f->src,
- EDGE_SUCC (ret, 0)->dest))
+ single_succ (ret)))
break;
}
if (!f)
- set_immediate_dominator (CDI_DOMINATORS, EDGE_SUCC (ret, 0)->dest, ret);
+ set_immediate_dominator (CDI_DOMINATORS, single_succ (ret), ret);
}
};
merge the flags for the duplicate edges. So we do not want to
check that the edge is not a FALLTHRU edge. */
- if (EDGE_COUNT (b->succs) == 1)
+ if (single_succ_p (b))
{
- s = EDGE_SUCC (b, 0);
+ s = single_succ_edge (b);
if (! (s->flags & EDGE_COMPLEX)
&& s->dest == c
&& !find_reg_note (BB_END (b), REG_CROSSING_JUMP, NULL_RTX))
/* Make sure new bb is tagged for correct section (same as
fall-thru source, since you cannot fall-throu across
section boundaries). */
- BB_COPY_PARTITION (e_fall->src, EDGE_PRED (bb, 0)->src);
+ BB_COPY_PARTITION (e_fall->src, single_pred (bb));
if (flag_reorder_blocks_and_partition
&& targetm.have_named_sections)
{
- if (BB_PARTITION (EDGE_PRED (bb, 0)->src) == BB_COLD_PARTITION)
+ if (BB_PARTITION (single_pred (bb)) == BB_COLD_PARTITION)
{
rtx new_note;
rtx note = BB_HEAD (e_fall->src);
}
if (JUMP_P (BB_END (bb))
&& !any_condjump_p (BB_END (bb))
- && (EDGE_SUCC (bb, 0)->flags & EDGE_CROSSING))
+ && (single_succ_edge (bb)->flags & EDGE_CROSSING))
REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST
(REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
}
/* If we have already seen an exit, mark this by the edge that
surely does not occur as any exit. */
if (loop->single_exit)
- loop->single_exit = EDGE_SUCC (ENTRY_BLOCK_PTR, 0);
+ loop->single_exit = single_succ_edge (ENTRY_BLOCK_PTR);
else
loop->single_exit = e;
}
if (!loop)
continue;
- if (loop->single_exit == EDGE_SUCC (ENTRY_BLOCK_PTR, 0))
+ if (loop->single_exit == single_succ_edge (ENTRY_BLOCK_PTR))
loop->single_exit = NULL;
}
{
alloc_aux_for_block (jump, sizeof (int));
HEADER_BLOCK (jump) = 0;
- alloc_aux_for_edge (EDGE_PRED (jump, 0), sizeof (int));
- LATCH_EDGE (EDGE_PRED (jump, 0)) = 0;
- set_immediate_dominator (CDI_DOMINATORS, jump, EDGE_PRED (jump, 0)->src);
+ alloc_aux_for_edge (single_pred_edge (jump), sizeof (int));
+ LATCH_EDGE (single_pred_edge (jump)) = 0;
+ set_immediate_dominator (CDI_DOMINATORS, jump, single_pred (jump));
}
/* A callback for make_forwarder block, to redirect all edges except for
HEADER_BLOCK (header) = num_latches;
}
- if (HEADER_BLOCK (EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest))
+ if (HEADER_BLOCK (single_succ (ENTRY_BLOCK_PTR)))
{
basic_block bb;
/* We could not redirect edges freely here. On the other hand,
we can simply split the edge from entry block. */
- bb = split_edge (EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
+ bb = split_edge (single_succ_edge (ENTRY_BLOCK_PTR));
- alloc_aux_for_edge (EDGE_SUCC (bb, 0), sizeof (int));
- LATCH_EDGE (EDGE_SUCC (bb, 0)) = 0;
+ alloc_aux_for_edge (single_succ_edge (bb), sizeof (int));
+ LATCH_EDGE (single_succ_edge (bb)) = 0;
alloc_aux_for_block (bb, sizeof (int));
HEADER_BLOCK (bb) = 0;
}
}
if (loops->state & LOOPS_HAVE_SIMPLE_LATCHES)
{
- if (EDGE_COUNT (loop->latch->succs) != 1)
+ if (!single_succ_p (loop->latch))
{
error ("Loop %d's latch does not have exactly 1 successor.", i);
err = 1;
}
- if (EDGE_SUCC (loop->latch, 0)->dest != loop->header)
+ if (single_succ (loop->latch) != loop->header)
{
error ("Loop %d's latch does not have header as successor.", i);
err = 1;
e, but we only have basic block dominators. This is easy to
fix -- when e->dest has exactly one predecessor, this corresponds
to blocks dominated by e->dest, if not, split the edge. */
- if (EDGE_COUNT (e->dest->preds) > 1)
- e = EDGE_PRED (loop_split_edge_with (e, NULL_RTX), 0);
+ if (!single_pred_p (e->dest))
+ e = single_pred_edge (loop_split_edge_with (e, NULL_RTX));
/* It may happen that by removing path we remove one or more loops
we belong to. In this case first unloop the loops, then proceed
loops->parray[loop->num] = NULL;
flow_loop_free (loop);
- remove_edge (EDGE_SUCC (latch, 0));
+ remove_edge (single_succ_edge (latch));
fix_bb_placements (loops, latch);
/* If the loop was inside an irreducible region, we would have to somehow
if (!redirect_edge_and_branch (e, newdest))
return false;
- EDGE_SUCC (src, 0)->flags &= ~EDGE_IRREDUCIBLE_LOOP;
- EDGE_SUCC (src, 0)->flags |= irr;
+ single_succ_edge (src)->flags &= ~EDGE_IRREDUCIBLE_LOOP;
+ single_succ_edge (src)->flags |= irr;
return true;
}
static void
mfb_update_loops (basic_block jump)
{
- struct loop *loop = EDGE_SUCC (jump, 0)->dest->loop_father;
+ struct loop *loop = single_succ (jump)->loop_father;
if (dom_computed[CDI_DOMINATORS])
- set_immediate_dominator (CDI_DOMINATORS, jump, EDGE_PRED (jump, 0)->src);
+ set_immediate_dominator (CDI_DOMINATORS, jump, single_pred (jump));
add_bb_to_loop (jump, loop);
loop->latch = jump;
}
continue;
irred |= (e->flags & EDGE_IRREDUCIBLE_LOOP) != 0;
nentry++;
- if (EDGE_COUNT (e->src->succs) == 1)
+ if (single_succ_p (e->src))
one_succ_pred = e;
}
gcc_assert (nentry);
e = EDGE_PRED (loop->header,
EDGE_PRED (loop->header, 0)->src == loop->latch);
- if (!(flags & CP_SIMPLE_PREHEADERS) || EDGE_COUNT (e->src->succs) == 1)
+ if (!(flags & CP_SIMPLE_PREHEADERS) || single_succ_p (e->src))
return NULL;
}
if (irred)
{
dummy->flags |= BB_IRREDUCIBLE_LOOP;
- EDGE_SUCC (dummy, 0)->flags |= EDGE_IRREDUCIBLE_LOOP;
+ single_succ_edge (dummy)->flags |= EDGE_IRREDUCIBLE_LOOP;
}
if (dump_file)
for (i = 1; i < loops->num; i++)
{
loop = loops->parray[i];
- if (loop->latch != loop->header && EDGE_COUNT (loop->latch->succs) == 1)
+ if (loop->latch != loop->header && single_succ_p (loop->latch))
continue;
e = find_edge (loop->latch, loop->header);
&& onlyjump_p (insn))
{
pbb = BLOCK_FOR_INSN (insn);
- gcc_assert (pbb && EDGE_COUNT (pbb->succs) == 1);
+ gcc_assert (pbb && single_succ_p (pbb));
- if (!flow_bb_inside_loop_p (loop, EDGE_SUCC (pbb, 0)->dest))
+ if (!flow_bb_inside_loop_p (loop, single_succ (pbb)))
insn = BB_HEAD (first[loop->num]);
}
else
return false;
/* There must be exactly one edge in between the blocks. */
- return (EDGE_COUNT (a->succs) == 1
- && EDGE_SUCC (a, 0)->dest == b
- && EDGE_COUNT (b->preds) == 1
+ return (single_succ_p (a)
+ && single_succ (a) == b
+ && single_pred_p (b)
&& a != b
/* Must be simple edge. */
- && !(EDGE_SUCC (a, 0)->flags & EDGE_COMPLEX)
+ && !(single_succ_edge (a)->flags & EDGE_COMPLEX)
&& a->next_bb == b
&& a != ENTRY_BLOCK_PTR && b != EXIT_BLOCK_PTR
/* If the jump insn has side effects,
}
/* Keep only one edge out and set proper flags. */
- while (EDGE_COUNT (src->succs) > 1)
+ if (!single_succ_p (src))
remove_edge (e);
+ gcc_assert (single_succ_p (src));
- e = EDGE_SUCC (src, 0);
+ e = single_succ_edge (src);
if (fallthru)
e->flags = EDGE_FALLTHRU;
else
}
if (JUMP_P (BB_END (jump_block))
&& !any_condjump_p (BB_END (jump_block))
- && (EDGE_SUCC (jump_block, 0)->flags & EDGE_CROSSING))
+ && (single_succ_edge (jump_block)->flags & EDGE_CROSSING))
REG_NOTES (BB_END (jump_block)) = gen_rtx_EXPR_LIST
(REG_CROSSING_JUMP, NULL_RTX,
REG_NOTES (BB_END (jump_block)));
if (JUMP_P (q)
&& onlyjump_p (q)
&& (any_uncondjump_p (q)
- || EDGE_COUNT (b->succs) == 1))
+ || single_succ_p (b)))
{
#ifdef HAVE_cc0
/* If this was a conditional jump, we need to also delete
/* Special case -- avoid inserting code between call and storing
its return value. */
if (watch_calls && (e->flags & EDGE_FALLTHRU)
- && EDGE_COUNT (e->dest->preds) == 1
+ && single_pred_p (e->dest)
&& e->src != ENTRY_BLOCK_PTR
&& CALL_P (BB_END (e->src)))
{
{
/* Figure out where to put these things. If the destination has
one predecessor, insert there. Except for the exit block. */
- if (EDGE_COUNT (e->dest->preds) == 1 && e->dest != EXIT_BLOCK_PTR)
+ if (single_pred_p (e->dest) && e->dest != EXIT_BLOCK_PTR)
{
bb = e->dest;
/* If the source has one successor and the edge is not abnormal,
insert there. Except for the entry block. */
else if ((e->flags & EDGE_ABNORMAL) == 0
- && EDGE_COUNT (e->src->succs) == 1
+ && single_succ_p (e->src)
&& e->src != ENTRY_BLOCK_PTR)
{
bb = e->src;
NOTE_BASIC_BLOCK (new_note) = bb;
if (JUMP_P (BB_END (bb))
&& !any_condjump_p (BB_END (bb))
- && (EDGE_SUCC (bb, 0)->flags & EDGE_CROSSING))
+ && (single_succ_edge (bb)->flags & EDGE_CROSSING))
REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST
(REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
if (after == bb_note)
for the (single) epilogue, which already has a fallthru edge
to EXIT. */
- e = EDGE_SUCC (bb, 0);
+ e = single_succ_edge (bb);
gcc_assert (e->dest == EXIT_BLOCK_PTR
- && EDGE_COUNT (bb->succs) == 1 && (e->flags & EDGE_FALLTHRU));
+ && single_succ_p (bb) && (e->flags & EDGE_FALLTHRU));
e->flags &= ~EDGE_FALLTHRU;
emit_barrier_after (last);
return purged;
/* Redistribute probabilities. */
- if (EDGE_COUNT (bb->succs) == 1)
+ if (single_succ_p (bb))
{
- EDGE_SUCC (bb, 0)->probability = REG_BR_PROB_BASE;
- EDGE_SUCC (bb, 0)->count = bb->count;
+ single_succ_edge (bb)->probability = REG_BR_PROB_BASE;
+ single_succ_edge (bb)->count = bb->count;
}
else
{
from non-local gotos and the like. If there were, we shouldn't
have created the sibcall in the first place. Second, there
should of course never have been a fallthru edge. */
- gcc_assert (EDGE_COUNT (bb->succs) == 1);
- gcc_assert (EDGE_SUCC (bb, 0)->flags == (EDGE_SIBCALL | EDGE_ABNORMAL));
+ gcc_assert (single_succ_p (bb));
+ gcc_assert (single_succ_edge (bb)->flags
+ == (EDGE_SIBCALL | EDGE_ABNORMAL));
return 0;
}
ei_next (&ei);
}
- gcc_assert (EDGE_COUNT (bb->succs) == 1);
+ gcc_assert (single_succ_p (bb));
- EDGE_SUCC (bb, 0)->probability = REG_BR_PROB_BASE;
- EDGE_SUCC (bb, 0)->count = bb->count;
+ single_succ_edge (bb)->probability = REG_BR_PROB_BASE;
+ single_succ_edge (bb)->count = bb->count;
if (dump_file)
fprintf (dump_file, "Purged non-fallthru edges from bb %i\n",
return false;
/* There must be exactly one edge in between the blocks. */
- return (EDGE_COUNT (a->succs) == 1
- && EDGE_SUCC (a, 0)->dest == b
- && EDGE_COUNT (b->preds) == 1
+ return (single_succ_p (a)
+ && single_succ (a) == b
+ && single_pred_p (b) == 1
&& a != b
/* Must be simple edge. */
- && !(EDGE_SUCC (a, 0)->flags & EDGE_COMPLEX)
+ && !(single_succ_edge (a)->flags & EDGE_COMPLEX)
&& a != ENTRY_BLOCK_PTR && b != EXIT_BLOCK_PTR
/* If the jump insn has side effects,
we can't kill the edge. */
|| NOTE_LINE_NUMBER (fn_begin) == NOTE_INSN_BASIC_BLOCK))
break;
if (NOTE_LINE_NUMBER (fn_begin) == NOTE_INSN_FUNCTION_BEG)
- insert_insn_on_edge (seq, EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
+ insert_insn_on_edge (seq, single_succ_edge (ENTRY_BLOCK_PTR));
else
{
- rtx last = BB_END (EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest);
+ rtx last = BB_END (single_succ (ENTRY_BLOCK_PTR));
for (; ; fn_begin = NEXT_INSN (fn_begin))
if ((NOTE_P (fn_begin)
&& NOTE_LINE_NUMBER (fn_begin) == NOTE_INSN_FUNCTION_BEG)
/* Identify the successor blocks. */
bb_true = EDGE_SUCC (bb, 0)->dest;
- if (EDGE_COUNT (bb->succs) > 1)
+ if (!single_succ_p (bb))
{
bb_false = EDGE_SUCC (bb, 1)->dest;
(TREE_TYPE (current_function_decl))))
&& (flags & PROP_SCAN_DEAD_STORES)
&& (EDGE_COUNT (bb->succs) == 0
- || (EDGE_COUNT (bb->succs) == 1
- && EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR
+ || (single_succ_p (bb)
+ && single_succ (bb) == EXIT_BLOCK_PTR
&& ! current_function_calls_eh_return)))
{
rtx insn, set;
/* Can't deal with multiple successors of the entry block
at the moment. Function should always have at least one
entry point. */
- gcc_assert (EDGE_COUNT (ENTRY_BLOCK_PTR->succs) == 1);
+ gcc_assert (single_succ_p (ENTRY_BLOCK_PTR));
- insert_insn_on_edge (seq, EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
+ insert_insn_on_edge (seq, single_succ_edge (ENTRY_BLOCK_PTR));
inserted = 1;
}
#endif
/* If this block has only one successor, it both jumps
and falls through to the fallthru block, so we can't
delete the edge. */
- if (EDGE_COUNT (bb->succs) == 1)
+ if (single_succ_p (bb))
{
ei_next (&ei2);
continue;
emit_barrier_after (BB_END (last));
emit_return_into_block (last, epilogue_line_note);
epilogue_end = BB_END (last);
- EDGE_SUCC (last, 0)->flags &= ~EDGE_FALLTHRU;
+ single_succ_edge (last)->flags &= ~EDGE_FALLTHRU;
goto epilogue_done;
}
}
dest = GET_CODE (cond) == EQ ? BRANCH_EDGE (bb)->dest
: FALLTHRU_EDGE (bb)->dest;
- if (dest && EDGE_COUNT (dest->preds) == 1
+ if (dest && single_pred_p (dest)
&& dest != EXIT_BLOCK_PTR)
{
new = gen_rtx_SET (VOIDmode, XEXP (cond, 0),
EXIT_BLOCK_PTR, next_bb)
{
/* Check for more than one predecessor. */
- if (EDGE_COUNT (bb->preds) > 1)
+ if (!single_pred_p (bb))
{
setcc = NULL_RTX;
for (insn = BB_HEAD (bb);
if (JUMP_P (insn)
|| (NONJUMP_INSN_P (insn)
- && (EDGE_COUNT (bb->succs) > 1
- || EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL)))
+ && (!single_succ_p (bb)
+ || single_succ_edge (bb)->flags & EDGE_ABNORMAL)))
{
#ifdef HAVE_cc0
rtx note;
/* Likewise if the last insn is a call, as will happen in the presence
of exception handling. */
else if (CALL_P (insn)
- && (EDGE_COUNT (bb->succs) > 1 || EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL))
+ && (!single_succ_p (bb)
+ || single_succ_edge (bb)->flags & EDGE_ABNORMAL))
{
/* Keeping in mind SMALL_REGISTER_CLASSES and parameters in registers,
we search backward and place the instructions before the first
/* The outgoing edge for the current COMBO block should already
be correct. Verify this. */
- if (EDGE_COUNT (combo_bb->succs) > 1
- || EDGE_SUCC (combo_bb, 0)->dest != join_bb)
- abort ();
+ gcc_assert (single_succ_p (combo_bb)
+ && single_succ (combo_bb) == join_bb);
/* Remove the jump and cruft from the end of the COMBO block. */
if (join_bb != EXIT_BLOCK_PTR)
- tidy_fallthru_edge (EDGE_SUCC (combo_bb, 0));
+ tidy_fallthru_edge (single_succ_edge (combo_bb));
}
num_updated_if_blocks++;
were && tests (which jump to the else block) or || tests (which jump to
the then block). */
if (HAVE_conditional_execution && reload_completed
- && EDGE_COUNT (test_bb->preds) == 1
- && EDGE_PRED (test_bb, 0)->flags == EDGE_FALLTHRU)
+ && single_pred_p (test_bb)
+ && single_pred_edge (test_bb)->flags == EDGE_FALLTHRU)
{
- basic_block bb = EDGE_PRED (test_bb, 0)->src;
+ basic_block bb = single_pred (test_bb);
basic_block target_bb;
int max_insns = MAX_CONDITIONAL_EXECUTE;
int n_insns;
total_insns += n_insns;
blocks++;
- if (EDGE_COUNT (bb->preds) != 1)
+ if (!single_pred_p (bb))
break;
- bb = EDGE_PRED (bb, 0)->src;
+ bb = single_pred (bb);
n_insns = block_jumps_and_fallthru_p (bb, target_bb);
}
while (n_insns >= 0 && (total_insns + n_insns) <= max_insns);
/* The THEN block of an IF-THEN combo must have zero or one successors. */
if (EDGE_COUNT (then_bb->succs) > 0
- && (EDGE_COUNT (then_bb->succs) > 1
- || (EDGE_SUCC (then_bb, 0)->flags & EDGE_COMPLEX)
+ && (!single_succ_p (then_bb)
+ || (single_succ_edge (then_bb)->flags & EDGE_COMPLEX)
|| (flow2_completed && tablejump_p (BB_END (then_bb), NULL, NULL))))
return FALSE;
code processing. ??? we should fix this in the future. */
if (EDGE_COUNT (then_bb->succs) == 0)
{
- if (EDGE_COUNT (else_bb->preds) == 1)
+ if (single_pred_p (else_bb))
{
rtx last_insn = BB_END (then_bb);
/* If the THEN block's successor is the other edge out of the TEST block,
then we have an IF-THEN combo without an ELSE. */
- else if (EDGE_SUCC (then_bb, 0)->dest == else_bb)
+ else if (single_succ (then_bb) == else_bb)
{
join_bb = else_bb;
else_bb = NULL_BLOCK;
/* If the THEN and ELSE block meet in a subsequent block, and the ELSE
has exactly one predecessor and one successor, and the outgoing edge
is not complex, then we have an IF-THEN-ELSE combo. */
- else if (EDGE_COUNT (else_bb->succs) == 1
- && EDGE_SUCC (then_bb, 0)->dest == EDGE_SUCC (else_bb, 0)->dest
- && EDGE_COUNT (else_bb->preds) == 1
- && ! (EDGE_SUCC (else_bb, 0)->flags & EDGE_COMPLEX)
+ else if (single_succ_p (else_bb)
+ && single_succ (then_bb) == single_succ (else_bb)
+ && single_pred_p (else_bb)
+ && ! (single_succ_edge (else_bb)->flags & EDGE_COMPLEX)
&& ! (flow2_completed && tablejump_p (BB_END (else_bb), NULL, NULL)))
- join_bb = EDGE_SUCC (else_bb, 0)->dest;
+ join_bb = single_succ (else_bb);
/* Otherwise it is not an IF-THEN or IF-THEN-ELSE combination. */
else
return FALSE;
/* THEN has one successor. */
- if (EDGE_COUNT (then_bb->succs) != 1)
+ if (!single_succ_p (then_bb))
return FALSE;
/* THEN does not fall through, but is not strange either. */
- if (EDGE_SUCC (then_bb, 0)->flags & (EDGE_COMPLEX | EDGE_FALLTHRU))
+ if (single_succ_edge (then_bb)->flags & (EDGE_COMPLEX | EDGE_FALLTHRU))
return FALSE;
/* THEN has one predecessor. */
- if (EDGE_COUNT (then_bb->preds) != 1)
+ if (!single_pred_p (then_bb))
return FALSE;
/* THEN must do something. */
/* Registers set are dead, or are predicable. */
if (! dead_or_predicable (test_bb, then_bb, else_bb,
- EDGE_SUCC (then_bb, 0)->dest, 1))
+ single_succ (then_bb), 1))
return FALSE;
/* Conversion went ok, including moving the insns and fixing up the
return FALSE;
/* ELSE has one successor. */
- if (EDGE_COUNT (else_bb->succs) != 1)
+ if (!single_succ_p (else_bb))
return FALSE;
else
- else_succ = EDGE_SUCC (else_bb, 0);
+ else_succ = single_succ_edge (else_bb);
/* ELSE outgoing edge is not complex. */
if (else_succ->flags & EDGE_COMPLEX)
return FALSE;
/* ELSE has one predecessor. */
- if (EDGE_COUNT (else_bb->preds) != 1)
+ if (!single_pred_p (else_bb))
return FALSE;
/* THEN is not EXIT. */
VEC_safe_push (tree, phis, PHI_RESULT (phi));
VEC_safe_push (tree, phis, PHI_ARG_DEF (phi, 0));
}
- e = redirect_edge_and_branch (EDGE_SUCC (preheaderbb, 0), headerbb);
+ e = redirect_edge_and_branch (single_succ_edge (preheaderbb), headerbb);
/* Remove the exit phis from the old basic block. Make sure to set
PHI_RESULT to null so it doesn't get released. */
def = VEC_pop (tree, phis);
phiname = VEC_pop (tree, phis);
phi = create_phi_node (phiname, preheaderbb);
- add_phi_arg (phi, def, EDGE_PRED (preheaderbb, 0));
+ add_phi_arg (phi, def, single_pred_edge (preheaderbb));
}
flush_pending_stmts (e);
#if defined (MODE_ENTRY) && defined (MODE_EXIT)
/* Split the edge from the entry block, so that we can note that
there NORMAL_MODE is supplied. */
- post_entry = split_edge (EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
+ post_entry = split_edge (single_succ_edge (ENTRY_BLOCK_PTR));
pre_exit = create_pre_exit (n_entities, entity_map, num_modes);
#endif
/* Expand the condition testing the assumptions and if it does not pass,
reset the count register to 0. */
add_test (XEXP (ass, 0), preheader, set_zero);
- EDGE_SUCC (preheader, 0)->flags &= ~EDGE_FALLTHRU;
- cnt = EDGE_SUCC (preheader, 0)->count;
- EDGE_SUCC (preheader, 0)->probability = 0;
- EDGE_SUCC (preheader, 0)->count = 0;
- irr = EDGE_SUCC (preheader, 0)->flags & EDGE_IRREDUCIBLE_LOOP;
+ single_succ_edge (preheader)->flags &= ~EDGE_FALLTHRU;
+ cnt = single_succ_edge (preheader)->count;
+ single_succ_edge (preheader)->probability = 0;
+ single_succ_edge (preheader)->count = 0;
+ irr = single_succ_edge (preheader)->flags & EDGE_IRREDUCIBLE_LOOP;
te = make_edge (preheader, new_preheader, EDGE_FALLTHRU | irr);
te->probability = REG_BR_PROB_BASE;
te->count = cnt;
for (ass = XEXP (ass, 1); ass; ass = XEXP (ass, 1))
{
bb = loop_split_edge_with (te, NULL_RTX);
- te = EDGE_SUCC (bb, 0);
+ te = single_succ_edge (bb);
add_test (XEXP (ass, 0), bb, set_zero);
make_edge (bb, set_zero, irr);
}
block. */
for (ei = ei_start (EXIT_BLOCK_PTR->preds); (e = ei_safe_edge (ei)); )
- if ((e->flags & EDGE_FALLTHRU) && EDGE_COUNT (e->src->succs) > 1)
+ if ((e->flags & EDGE_FALLTHRU) && !single_succ_p (e->src))
split_edge (e);
else
ei_next (&ei);
while (1)
{
- basic_block tmp_bb;
-
insn = BB_END (e->src);
if (any_condjump_p (insn))
{
}
}
- /* This is a bit subtle. Store away e->src in tmp_bb, since we
- modify `e' and this can invalidate the subsequent count of
- e->src's predecessors by looking at the wrong block. */
- tmp_bb = e->src;
- e = EDGE_PRED (tmp_bb, 0);
- if (EDGE_COUNT (tmp_bb->preds) > 1
- || e->src == ENTRY_BLOCK_PTR)
+ if (!single_pred_p (e->src)
+ || single_pred (e->src) == ENTRY_BLOCK_PTR)
break;
+ e = single_pred_edge (e->src);
}
FREE_REG_SET (altered);
branch_code = compare_and_jump_seq (copy_rtx (niter), GEN_INT (j), EQ,
block_label (preheader), p, NULL_RTX);
- swtch = loop_split_edge_with (EDGE_PRED (swtch, 0), branch_code);
+ swtch = loop_split_edge_with (single_pred_edge (swtch), branch_code);
set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);
- EDGE_SUCC (swtch, 0)->probability = REG_BR_PROB_BASE - p;
+ single_pred_edge (swtch)->probability = REG_BR_PROB_BASE - p;
e = make_edge (swtch, preheader,
- EDGE_SUCC (swtch, 0)->flags & EDGE_IRREDUCIBLE_LOOP);
+ single_succ_edge (swtch)->flags & EDGE_IRREDUCIBLE_LOOP);
e->probability = p;
}
branch_code = compare_and_jump_seq (copy_rtx (niter), const0_rtx, EQ,
block_label (preheader), p, NULL_RTX);
- swtch = loop_split_edge_with (EDGE_SUCC (swtch, 0), branch_code);
+ swtch = loop_split_edge_with (single_succ_edge (swtch), branch_code);
set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);
- EDGE_SUCC (swtch, 0)->probability = REG_BR_PROB_BASE - p;
+ single_succ_edge (swtch)->probability = REG_BR_PROB_BASE - p;
e = make_edge (swtch, preheader,
- EDGE_SUCC (swtch, 0)->flags & EDGE_IRREDUCIBLE_LOOP);
+ single_succ_edge (swtch)->flags & EDGE_IRREDUCIBLE_LOOP);
e->probability = p;
}
unswitch_on_alt = unswitch_on->rbi->copy;
true_edge = BRANCH_EDGE (unswitch_on_alt);
false_edge = FALLTHRU_EDGE (unswitch_on);
- latch_edge = EDGE_SUCC (loop->latch->rbi->copy, 0);
+ latch_edge = single_succ_edge (loop->latch->rbi->copy);
/* Create a block with the condition. */
prob = true_edge->probability;
/* Loopify from the copy of LOOP body, constructing the new loop. */
nloop = loopify (loops, latch_edge,
- EDGE_PRED (loop->header->rbi->copy, 0), switch_bb,
+ single_pred_edge (loop->header->rbi->copy), switch_bb,
BRANCH_EDGE (switch_bb), FALLTHRU_EDGE (switch_bb), true);
/* Remove branches that are now unreachable in new loops. */
basic_block epilog_bb = BLOCK_FOR_INSN (last_epilog_insn);
basic_block precond_bb = BLOCK_FOR_INSN (precond_jump);
basic_block orig_loop_bb = BLOCK_FOR_INSN (precond_exit_label_insn);
- edge epilog_exit_edge = EDGE_SUCC (epilog_bb, 0);
+ edge epilog_exit_edge = single_succ_edge (epilog_bb);
/* Do loop preconditioning to take care of cases were the loop count is
less than the stage count. Update the CFG properly. */
/* Save the prediction into CFG in case we are seeing non-degenerated
conditional jump. */
- if (EDGE_COUNT (bb->succs) > 1)
+ if (!single_succ_p (bb))
{
BRANCH_EDGE (bb)->probability = combined_probability;
FALLTHRU_EDGE (bb)->probability
= REG_BR_PROB_BASE - combined_probability;
}
}
- else if (EDGE_COUNT (bb->succs) > 1)
+ else if (!single_succ_p (bb))
{
int prob = INTVAL (XEXP (prob_note, 0));
FALLTHRU_EDGE (bb)->probability = REG_BR_PROB_BASE - prob;
}
else
- EDGE_SUCC (bb, 0)->probability = REG_BR_PROB_BASE;
+ single_succ_edge (bb)->probability = REG_BR_PROB_BASE;
}
/* Combine predictions into single probability and store them into CFG.
care for error returns and other are often used for fast paths
trought function. */
if ((e->dest == EXIT_BLOCK_PTR
- || (EDGE_COUNT (e->dest->succs) == 1
- && EDGE_SUCC (e->dest, 0)->dest == EXIT_BLOCK_PTR))
+ || (single_succ_p (e->dest)
+ && single_succ (e->dest) == EXIT_BLOCK_PTR))
&& !predicted_by_p (bb, PRED_NULL_RETURN)
&& !predicted_by_p (bb, PRED_CONST_RETURN)
&& !predicted_by_p (bb, PRED_NEGATIVE_RETURN)
fast paths trought function. */
if (e->dest == EXIT_BLOCK_PTR
&& TREE_CODE (last_stmt (bb)) == RETURN_EXPR
- && EDGE_COUNT (bb->preds) > 1)
+ && !single_pred_p (bb))
{
edge e1;
edge_iterator ei1;
return (bb->next_bb == EXIT_BLOCK_PTR
|| (bb->next_bb->next_bb == EXIT_BLOCK_PTR
- && EDGE_COUNT (bb->succs) == 1
- && EDGE_SUCC (bb, 0)->dest->next_bb == EXIT_BLOCK_PTR));
+ && single_succ_p (bb)
+ && single_succ (bb)->next_bb == EXIT_BLOCK_PTR));
}
/* Sets branch probabilities according to PREDiction and
mark_dfs_back_edges ();
- EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->probability = REG_BR_PROB_BASE;
+ single_succ_edge (ENTRY_BLOCK_PTR)->probability = REG_BR_PROB_BASE;
/* Set up block info for each basic block. */
tovisit = BITMAP_ALLOC (NULL);
/* Notice GOTO expressions we eliminated while constructing the
CFG. */
- if (EDGE_COUNT (bb->succs) == 1 && EDGE_SUCC (bb, 0)->goto_locus)
+ if (single_succ_p (bb) && single_succ_edge (bb)->goto_locus)
{
/* ??? source_locus type is marked deprecated in input.h. */
- source_locus curr_location = EDGE_SUCC (bb, 0)->goto_locus;
+ source_locus curr_location = single_succ_edge (bb)->goto_locus;
/* ??? The FILE/LINE API is inconsistent for these cases. */
#ifdef USE_MAPPED_LOCATION
output_location (LOCATION_FILE (curr_location),
processed, begin with the value data that was live at
the end of the predecessor block. */
/* ??? Ought to use more intelligent queuing of blocks. */
- if (EDGE_COUNT (bb->preds) == 1
+ if (single_pred_p (bb)
&& TEST_BIT (visited,
- EDGE_PRED (bb, 0)->src->index - (INVALID_BLOCK + 1))
- && ! (EDGE_PRED (bb, 0)->flags & (EDGE_ABNORMAL_CALL | EDGE_EH)))
- all_vd[bb->index] = all_vd[EDGE_PRED (bb, 0)->src->index];
+ single_pred (bb)->index - (INVALID_BLOCK + 1))
+ && ! (single_pred_edge (bb)->flags & (EDGE_ABNORMAL_CALL | EDGE_EH)))
+ all_vd[bb->index] = all_vd[single_pred (bb)->index];
else
init_value_data (all_vd + bb->index);
FOR_EACH_BB (b)
{
if (EDGE_COUNT (b->preds) == 0
- || (EDGE_PRED (b, 0)->src == b
- && EDGE_COUNT (b->preds) == 1))
+ || (single_pred_p (b)
+ && single_pred (b) == b))
return 1;
}
/* DFS traversal to find inner loops in the cfg. */
- current_edge = ei_start (EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest->succs);
+ current_edge = ei_start (single_succ (ENTRY_BLOCK_PTR)->succs);
sp = -1;
while (1)
FOR_EACH_BB (jbb)
/* Leaf nodes have only a single successor which must
be EXIT_BLOCK. */
- if (EDGE_COUNT (jbb->succs) == 1
- && EDGE_SUCC (jbb, 0)->dest == EXIT_BLOCK_PTR)
+ if (single_succ_p (jbb)
+ && single_succ (jbb) == EXIT_BLOCK_PTR)
{
queue[++tail] = jbb->index;
SET_BIT (in_queue, jbb->index);
(bb_from == bb_to \
|| IS_RGN_ENTRY (bb_from) \
|| (TEST_BIT (ancestor_edges[bb_to], \
- EDGE_TO_BIT (EDGE_PRED (BASIC_BLOCK (BB_TO_BLOCK (bb_from)), 0)))))
+ EDGE_TO_BIT (single_pred_edge (BASIC_BLOCK (BB_TO_BLOCK (bb_from)))))))
/* Turns on the fed_by_spec_load flag for insns fed by load_insn. */
static void
layout_superblocks (void)
{
- basic_block end = EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest;
- basic_block bb = EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest->next_bb;
+ basic_block end = single_succ (ENTRY_BLOCK_PTR);
+ basic_block bb = end->next_bb;
while (bb != EXIT_BLOCK_PTR)
{
FOR_EACH_EDGE (e, ei, end->succs)
if (e->dest != EXIT_BLOCK_PTR
- && e->dest != EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest
+ && e->dest != single_succ (ENTRY_BLOCK_PTR)
&& !e->dest->rbi->visited
&& (!best || EDGE_FREQUENCY (e) > EDGE_FREQUENCY (best)))
best = e;
tree stmt;
block_stmt_iterator bsi;
- if (EDGE_COUNT (a->succs) != 1)
+ if (!single_succ_p (a))
return false;
- if (EDGE_SUCC (a, 0)->flags & EDGE_ABNORMAL)
+ if (single_succ_edge (a)->flags & EDGE_ABNORMAL)
return false;
- if (EDGE_SUCC (a, 0)->dest != b)
+ if (single_succ (a) != b)
return false;
- if (EDGE_COUNT (b->preds) > 1)
+ if (!single_pred_p (b))
return false;
if (b == EXIT_BLOCK_PTR)
/* Ensure that B follows A. */
move_block_after (b, a);
- gcc_assert (EDGE_SUCC (a, 0)->flags & EDGE_FALLTHRU);
+ gcc_assert (single_succ_edge (a)->flags & EDGE_FALLTHRU);
gcc_assert (!last_stmt (a) || !stmt_ends_bb_p (last_stmt (a)));
/* Remove labels from B and set bb_for_stmt to A for other statements. */
/* Check whether we come here from a condition, and if so, get the
condition. */
- if (EDGE_COUNT (bb->preds) != 1
- || !(EDGE_PRED (bb, 0)->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
+ if (!single_pred_p (bb)
+ || !(single_pred_edge (bb)->flags
+ & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
return;
- cond = COND_EXPR_COND (last_stmt (EDGE_PRED (bb, 0)->src));
+ cond = COND_EXPR_COND (last_stmt (single_pred (bb)));
if (TREE_CODE (cond) == VAR_DECL || TREE_CODE (cond) == PARM_DECL)
{
var = cond;
- val = (EDGE_PRED (bb, 0)->flags & EDGE_FALSE_VALUE
+ val = (single_pred_edge (bb)->flags & EDGE_FALSE_VALUE
? boolean_false_node : boolean_true_node);
}
else if (TREE_CODE (cond) == TRUTH_NOT_EXPR
|| TREE_CODE (TREE_OPERAND (cond, 0)) == PARM_DECL))
{
var = TREE_OPERAND (cond, 0);
- val = (EDGE_PRED (bb, 0)->flags & EDGE_FALSE_VALUE
+ val = (single_pred_edge (bb)->flags & EDGE_FALSE_VALUE
? boolean_true_node : boolean_false_node);
}
else
{
- if (EDGE_PRED (bb, 0)->flags & EDGE_FALSE_VALUE)
+ if (single_pred_edge (bb)->flags & EDGE_FALSE_VALUE)
cond = invert_truthvalue (cond);
if (TREE_CODE (cond) == EQ_EXPR
&& (TREE_CODE (TREE_OPERAND (cond, 0)) == VAR_DECL
else
{
/* Turn off the EDGE_ABNORMAL flag. */
- EDGE_SUCC (bb, 0)->flags &= ~EDGE_ABNORMAL;
+ e->flags &= ~EDGE_ABNORMAL;
/* And set EDGE_FALLTHRU. */
- EDGE_SUCC (bb, 0)->flags |= EDGE_FALLTHRU;
+ e->flags |= EDGE_FALLTHRU;
ei_next (&ei);
}
}
bool retval = false;
tree expr = bsi_stmt (bsi), val;
- if (EDGE_COUNT (bb->succs) > 1)
+ if (!single_succ_p (bb))
{
edge e;
edge_iterator ei;
taken_edge->probability = REG_BR_PROB_BASE;
}
else
- taken_edge = EDGE_SUCC (bb, 0);
+ taken_edge = single_succ_edge (bb);
bsi_remove (&bsi);
taken_edge->flags = EDGE_FALLTHRU;
{
/* Remove the RETURN_EXPR if we may fall though to the exit
instead. */
- gcc_assert (EDGE_COUNT (bb->succs) == 1);
- gcc_assert (EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR);
+ gcc_assert (single_succ_p (bb));
+ gcc_assert (single_succ (bb) == EXIT_BLOCK_PTR);
if (bb->next_bb == EXIT_BLOCK_PTR
&& !TREE_OPERAND (stmt, 0))
{
bsi_remove (&last);
- EDGE_SUCC (bb, 0)->flags |= EDGE_FALLTHRU;
+ single_succ_edge (bb)->flags |= EDGE_FALLTHRU;
}
continue;
}
would have to examine the PHIs to prove that none of them used
the value set by the statement we want to insert on E. That
hardly seems worth the effort. */
- if (EDGE_COUNT (dest->preds) == 1
+ if (single_pred_p (dest)
&& ! phi_nodes (dest)
&& dest != EXIT_BLOCK_PTR)
{
Except for the entry block. */
src = e->src;
if ((e->flags & EDGE_ABNORMAL) == 0
- && EDGE_COUNT (src->succs) == 1
+ && single_succ_p (src)
&& src != ENTRY_BLOCK_PTR)
{
*bsi = bsi_last (src);
dest = split_edge (e);
if (new_bb)
*new_bb = dest;
- e = EDGE_PRED (dest, 0);
+ e = single_pred_edge (dest);
goto restart;
}
edge e;
edge_iterator ei;
- bsi_commit_one_edge_insert (EDGE_SUCC (ENTRY_BLOCK_PTR, 0), NULL);
+ bsi_commit_one_edge_insert (single_succ_edge (ENTRY_BLOCK_PTR), NULL);
FOR_EACH_BB (bb)
FOR_EACH_EDGE (e, ei, bb->succs)
break;
case RETURN_EXPR:
- if (EDGE_COUNT (bb->succs) != 1
- || (EDGE_SUCC (bb, 0)->flags & (EDGE_FALLTHRU | EDGE_ABNORMAL
- | EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
+ if (!single_succ_p (bb)
+ || (single_succ_edge (bb)->flags
+ & (EDGE_FALLTHRU | EDGE_ABNORMAL
+ | EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
{
error ("Wrong outgoing edge flags at end of bb %d\n", bb->index);
err = 1;
}
- if (EDGE_SUCC (bb, 0)->dest != EXIT_BLOCK_PTR)
+ if (single_succ (bb) != EXIT_BLOCK_PTR)
{
error ("Return edge does not point to exit in bb %d\n",
bb->index);
dummy = fallthru->src;
bb = fallthru->dest;
- if (EDGE_COUNT (bb->preds) == 1)
+ if (single_pred_p (bb))
return;
/* If we redirected a branch we must create new phi nodes at the
block_stmt_iterator bsi;
/* BB must have a single outgoing edge. */
- if (EDGE_COUNT (bb->succs) != 1
+ if (single_succ_p (bb) != 1
/* If PHI_WANTED is false, BB must not have any PHI nodes.
Otherwise, BB must have PHI nodes. */
|| (phi_nodes (bb) != NULL_TREE) != phi_wanted
/* BB may not be a predecessor of EXIT_BLOCK_PTR. */
- || EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR
+ || single_succ (bb) == EXIT_BLOCK_PTR
/* Nor should this be an infinite loop. */
- || EDGE_SUCC (bb, 0)->dest == bb
+ || single_succ (bb) == bb
/* BB may not have an abnormal outgoing edge. */
- || (EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL))
+ || (single_succ_edge (bb)->flags & EDGE_ABNORMAL))
return false;
#if ENABLE_CHECKING
static bool
remove_forwarder_block (basic_block bb, basic_block **worklist)
{
- edge succ = EDGE_SUCC (bb, 0), e, s;
+ edge succ = single_succ_edge (bb), e, s;
basic_block dest = succ->dest;
tree label;
tree phi;
static void
remove_forwarder_block_with_phi (basic_block bb)
{
- edge succ = EDGE_SUCC (bb, 0);
+ edge succ = single_succ_edge (bb);
basic_block dest = succ->dest;
tree label;
basic_block dombb, domdest, dom;
/* PHI arguments are different. Create a forwarder block by
splitting E so that we can merge PHI arguments on E to
DEST. */
- e = EDGE_SUCC (split_edge (e), 0);
+ e = single_succ_edge (split_edge (e));
}
s = redirect_edge_and_branch (e, dest);
if (!tree_forwarder_block_p (bb, true))
continue;
- dest = EDGE_SUCC (bb, 0)->dest;
+ dest = single_succ (bb);
/* We have to feed into another basic block with PHI
nodes. */
/* If current bb has only one successor, then consider it as an
unconditional goto. */
- if (EDGE_COUNT (bb->succs) == 1)
+ if (single_succ_p (bb))
{
- basic_block bb_n = EDGE_SUCC (bb, 0)->dest;
+ basic_block bb_n = single_succ (bb);
if (cond != NULL_TREE)
add_to_predicate_list (bb_n, cond);
cond = NULL_TREE;
/* We expect that the conditional jump we will construct will not
be taken very often as it basically is an exception condition. */
- predict_edge_def (EDGE_PRED (then_bb, 0), PRED_MUDFLAP, NOT_TAKEN);
+ predict_edge_def (single_pred_edge (then_bb), PRED_MUDFLAP, NOT_TAKEN);
/* Mark the pseudo-fallthrough edge from cond_bb to join_bb. */
e = find_edge (cond_bb, join_bb);
EDGE_SUCC (bb, 0)->flags &= ~EDGE_FALLTHRU;
/* Remove the remaining the outgoing edges. */
- while (EDGE_COUNT (bb->succs) != 1)
+ while (!single_succ_p (bb))
remove_edge (EDGE_SUCC (bb, 1));
}
the edge from BB through its successor.
Do this before we remove entries from our equivalence tables. */
- if (EDGE_COUNT (bb->succs) == 1
- && (EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL) == 0
- && (get_immediate_dominator (CDI_DOMINATORS, EDGE_SUCC (bb, 0)->dest) != bb
- || phi_nodes (EDGE_SUCC (bb, 0)->dest)))
+ if (single_succ_p (bb)
+ && (single_succ_edge (bb)->flags & EDGE_ABNORMAL) == 0
+ && (get_immediate_dominator (CDI_DOMINATORS, single_succ (bb)) != bb
+ || phi_nodes (single_succ (bb))))
{
- thread_across_edge (walk_data, EDGE_SUCC (bb, 0));
+ thread_across_edge (walk_data, single_succ_edge (bb));
}
else if ((last = last_stmt (bb))
&& TREE_CODE (last) == GOTO_EXPR
return false;
gcc_assert (EDGE_COUNT (header->succs) > 0);
- if (EDGE_COUNT (header->succs) == 1)
+ if (single_succ_p (header))
return false;
if (flow_bb_inside_loop_p (loop, EDGE_SUCC (header, 0)->dest)
&& flow_bb_inside_loop_p (loop, EDGE_SUCC (header, 1)->dest))
/* If this is not the original loop header, we want it to have just
one predecessor in order to match the && pattern. */
- if (header != loop->header && EDGE_COUNT (header->preds) >= 2)
+ if (header != loop->header && !single_pred_p (header))
return false;
last = last_stmt (header);
/* Ensure that the header will have just the latch as a predecessor
inside the loop. */
- if (EDGE_COUNT (exit->dest->preds) > 1)
- exit = EDGE_SUCC (loop_split_edge_with (exit, NULL), 0);
+ if (!single_pred_p (exit->dest))
+ exit = single_succ_edge (loop_split_edge_with (exit, NULL));
if (!tree_duplicate_sese_region (loop_preheader_edge (loop), exit,
bbs, n_bbs, NULL))
{
bb = BASIC_BLOCK (i);
add_bb_to_loop (bb,
- find_common_loop (EDGE_SUCC (bb, 0)->dest->loop_father,
- EDGE_PRED (bb, 0)->src->loop_father));
+ find_common_loop (single_pred (bb)->loop_father,
+ single_succ (bb)->loop_father));
}
}
block_stmt_iterator bsi;
tree phi, stmt, def, next;
- if (EDGE_COUNT (exit->dest->preds) > 1)
+ if (!single_pred_p (exit->dest))
split_loop_exit_edge (exit);
if (TREE_CODE (stmts) == STATEMENT_LIST)
for (phi = phi_nodes (dest); phi; phi = PHI_CHAIN (phi))
{
- op_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, EDGE_SUCC (bb, 0));
+ op_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, single_succ_edge (bb));
name = USE_FROM_PTR (op_p);
basic_block bb;
edge exit;
- if (EDGE_COUNT (loop->latch->preds) > 1)
+ if (!single_pred_p (loop->latch))
return NULL;
- bb = EDGE_PRED (loop->latch, 0)->src;
+ bb = single_pred (loop->latch);
last = last_stmt (bb);
if (TREE_CODE (last) != COND_EXPR)
return NULL;
/* Adjust edges appropriately to connect new head with first head
as well as second head. */
- e0 = EDGE_SUCC (new_head, 0);
+ e0 = single_succ_edge (new_head);
e0->flags &= ~EDGE_FALLTHRU;
e0->flags |= EDGE_FALSE_VALUE;
e1 = make_edge (new_head, first_head, EDGE_TRUE_VALUE);
*condition_bb = lv_adjust_loop_entry_edge (first_head, second_head, entry,
cond_expr);
- latch_edge = EDGE_SUCC (loop->latch->rbi->copy, 0);
+ latch_edge = single_succ_edge (loop->latch->rbi->copy);
extract_true_false_edges_from_block (*condition_bb, &true_edge, &false_edge);
nloop = loopify (loops,
latch_edge,
- EDGE_PRED (loop->header->rbi->copy, 0),
+ single_pred_edge (loop->header->rbi->copy),
*condition_bb, true_edge, false_edge,
false /* Do not redirect all edges. */);
(*condition_bb)->flags |= BB_IRREDUCIBLE_LOOP;
loop_preheader_edge (loop)->flags |= EDGE_IRREDUCIBLE_LOOP;
loop_preheader_edge (nloop)->flags |= EDGE_IRREDUCIBLE_LOOP;
- EDGE_PRED ((*condition_bb), 0)->flags |= EDGE_IRREDUCIBLE_LOOP;
+ single_pred_edge ((*condition_bb))->flags |= EDGE_IRREDUCIBLE_LOOP;
}
/* At this point condition_bb is loop predheader with two successors,
bb != ENTRY_BLOCK_PTR;
bb = get_immediate_dominator (CDI_DOMINATORS, bb))
{
- e = EDGE_PRED (bb, 0);
- if (EDGE_COUNT (bb->preds) > 1)
+ if (!single_pred_p (bb))
continue;
+ e = single_pred_edge (bb);
if (!(e->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
continue;
? boolean_true_node
: boolean_false_node);
- if (EDGE_COUNT (e->src->preds) > 1)
+ if (!single_pred_p (e->src))
return cond;
- e = EDGE_PRED (e->src, 0);
+ e = single_pred_edge (e->src);
if (e->src == ENTRY_BLOCK_PTR)
return cond;
}
continue;
/* If either bb1's succ or bb2 or bb2's succ is non NULL. */
- if (EDGE_COUNT (bb1->succs) < 1
+ if (EDGE_COUNT (bb1->succs) == 0
|| bb2 == NULL
- || EDGE_COUNT (bb2->succs) < 1)
+ || EDGE_COUNT (bb2->succs) == 0)
continue;
/* Find the bb which is the fall through to the other. */
e1 = EDGE_SUCC (bb1, 0);
/* Make sure that bb1 is just a fall through. */
- if (EDGE_COUNT (bb1->succs) > 1
+ if (!single_succ_p (bb1) > 1
|| (e1->flags & EDGE_FALLTHRU) == 0)
continue;
/* Also make that bb1 only have one pred and it is bb. */
- if (EDGE_COUNT (bb1->preds) > 1
- || EDGE_PRED (bb1, 0)->src != bb)
+ if (!single_pred_p (bb1)
+ || single_pred (bb1) != bb)
continue;
phi = phi_nodes (bb2);
edge from OTHER_BLOCK which reaches BB and represents the desired
path from COND_BLOCK. */
if (e->dest == middle_bb)
- e = EDGE_SUCC (e->dest, 0);
+ e = single_succ_edge (e->dest);
/* Now we know the incoming edge to BB that has the argument for the
RHS of our new assignment statement. */
;
/* If we have one successor, we could have some phi nodes to
translate through. */
- else if (EDGE_COUNT (block->succs) == 1)
+ else if (single_succ_p (block))
{
- phi_translate_set (ANTIC_OUT, ANTIC_IN(EDGE_SUCC (block, 0)->dest),
- block, EDGE_SUCC (block, 0)->dest);
+ phi_translate_set (ANTIC_OUT, ANTIC_IN(single_succ (block)),
+ block, single_succ (block));
}
/* If we have multiple successors, we take the intersection of all of
them. */
bitmap_value_replace_in_set (AVAIL_OUT (block), ssa_name (i));
}
}
- if (EDGE_COUNT (block->preds) > 1)
+ if (!single_pred_p (block))
{
value_set_node_t node;
for (node = ANTIC_IN (block)->head;
ENTRY_BLOCK_PTR (FIXME, if ENTRY_BLOCK_PTR had an index number
different than -1 we wouldn't have to hack this. tree-ssa-dce.c
needs a similar change). */
- if (EDGE_COUNT (EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest->preds) > 1)
- if (!(EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->flags & EDGE_ABNORMAL))
- split_edge (EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
+ if (!single_pred_p (single_succ (ENTRY_BLOCK_PTR)))
+ if (!(single_succ_edge (ENTRY_BLOCK_PTR)->flags & EDGE_ABNORMAL))
+ split_edge (single_succ_edge (ENTRY_BLOCK_PTR));
FOR_ALL_BB (bb)
bb->aux = xcalloc (1, sizeof (struct bb_value_sets));
rd->outgoing_edge->dest);
/* And fixup the flags on the single remaining edge. */
- EDGE_SUCC (local_info->bb, 0)->flags
+ single_succ_edge (local_info->bb)->flags
&= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE | EDGE_ABNORMAL);
- EDGE_SUCC (local_info->bb, 0)->flags |= EDGE_FALLTHRU;
+ single_succ_edge (local_info->bb)->flags |= EDGE_FALLTHRU;
}
}
/* Mark the blocks in the chain leading to the end. */
at_bb = bb_for_stmt (at);
call_bb = bb_for_stmt (bsi_stmt (bsi));
- for (bb = call_bb; bb != at_bb; bb = EDGE_SUCC (bb, 0)->dest)
+ for (bb = call_bb; bb != at_bb; bb = single_succ (bb))
bb->aux = &bb->aux;
bb->aux = &bb->aux;
}
/* Unmark the blocks. */
- for (bb = call_bb; bb != at_bb; bb = EDGE_SUCC (bb, 0)->dest)
+ for (bb = call_bb; bb != at_bb; bb = single_succ (bb))
bb->aux = NULL;
bb->aux = NULL;
basic_block abb;
stmt_ann_t ann;
- if (EDGE_COUNT (bb->succs) > 1)
+ if (!single_succ_p (bb))
return;
for (bsi = bsi_last (bb); !bsi_end_p (bsi); bsi_prev (&bsi))
while (bsi_end_p (absi))
{
- ass_var = propagate_through_phis (ass_var, EDGE_SUCC (abb, 0));
- abb = EDGE_SUCC (abb, 0)->dest;
+ ass_var = propagate_through_phis (ass_var, single_succ_edge (abb));
+ abb = single_succ (abb);
absi = bsi_start (abb);
}
if (TREE_CODE (stmt) == MODIFY_EXPR)
stmt = TREE_OPERAND (stmt, 1);
- first = EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest;
+ first = single_succ (ENTRY_BLOCK_PTR);
/* Remove the code after call_bsi that will become unreachable. The
possibly unreachable code in other blocks is removed later in
}
/* Replace the call by a jump to the start of function. */
- e = redirect_edge_and_branch (EDGE_SUCC (t->call_block, 0), first);
+ e = redirect_edge_and_branch (single_succ_edge (t->call_block), first);
gcc_assert (e);
PENDING_STMT (e) = NULL_TREE;
var_ann (param)->default_def = new_name;
phi = create_phi_node (name, first);
SSA_NAME_DEF_STMT (name) = phi;
- add_phi_arg (phi, new_name, EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
+ add_phi_arg (phi, new_name, single_succ_edge (ENTRY_BLOCK_PTR));
/* For all calls the same set of variables should be clobbered. This
means that there always should be the appropriate phi node except
bool phis_constructed = false;
struct tailcall *tailcalls = NULL, *act, *next;
bool changed = false;
- basic_block first = EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest;
+ basic_block first = single_succ (ENTRY_BLOCK_PTR);
tree stmt, param, ret_type, tmp, phi;
edge_iterator ei;
if (!phis_constructed)
{
/* Ensure that there is only one predecessor of the block. */
- if (EDGE_COUNT (first->preds) > 1)
- first = split_edge (EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
+ if (!single_pred_p (first))
+ first = split_edge (single_succ_edge (ENTRY_BLOCK_PTR));
/* Copy the args if needed. */
for (param = DECL_ARGUMENTS (current_function_decl);
var_ann (param)->default_def = new_name;
phi = create_phi_node (name, first);
SSA_NAME_DEF_STMT (name) = phi;
- add_phi_arg (phi, new_name, EDGE_PRED (first, 0));
+ add_phi_arg (phi, new_name, single_pred_edge (first));
}
phis_constructed = true;
}
/* RET_TYPE can be a float when -ffast-maths is
enabled. */
fold_convert (ret_type, integer_zero_node),
- EDGE_PRED (first, 0));
+ single_pred_edge (first));
a_acc = PHI_RESULT (phi);
}
/* RET_TYPE can be a float when -ffast-maths is
enabled. */
fold_convert (ret_type, integer_one_node),
- EDGE_PRED (first, 0));
+ single_pred_edge (first));
m_acc = PHI_RESULT (phi);
}
}
}
/* Make sure there exists a single-predecessor exit bb: */
- if (EDGE_COUNT (loop->single_exit->dest->preds) != 1)
+ if (!single_pred_p (loop->single_exit->dest))
{
edge e = loop->single_exit;
if (!(e->flags & EDGE_ABNORMAL))
/* gcc_assert (vect_can_advance_ivs_p (loop_vinfo)); */
/* Make sure there exists a single-predecessor exit bb: */
- gcc_assert (EDGE_COUNT (exit_bb->preds) == 1);
+ gcc_assert (single_pred_p (exit_bb));
for (phi = phi_nodes (loop->header), phi1 = phi_nodes (update_bb);
phi && phi1;
/* Fix phi expressions in the successor bb. */
gcc_assert (PHI_ARG_DEF_FROM_EDGE (phi1, update_e) ==
- PHI_ARG_DEF_FROM_EDGE (phi, EDGE_SUCC (loop->latch, 0)));
+ PHI_ARG_DEF_FROM_EDGE (phi, single_succ_edge (loop->latch)));
SET_PHI_ARG_DEF (phi1, update_e->dest_idx, ni_name);
}
}
tree orig_phi, new_phi, update_phi;
tree guard_arg, loop_arg;
basic_block new_merge_bb = guard_edge->dest;
- edge e = EDGE_SUCC (new_merge_bb, 0);
+ edge e = single_succ_edge (new_merge_bb);
basic_block update_bb = e->dest;
basic_block orig_bb = (entry_phis ? loop->header : update_bb);
edge new_e, enter_e;
tree cond_stmt, then_label, else_label;
- enter_e = EDGE_SUCC (guard_bb, 0);
+ enter_e = single_succ_edge (guard_bb);
enter_e->flags &= ~EDGE_FALLTHRU;
enter_e->flags |= EDGE_FALSE_VALUE;
bsi = bsi_last (guard_bb);