{
tree cond = fold (COND_EXPR_COND (stmt));
if (integer_zerop (cond))
- COND_EXPR_COND (stmt) = integer_zero_node;
+ COND_EXPR_COND (stmt) = boolean_false_node;
else if (integer_onep (cond))
- COND_EXPR_COND (stmt) = integer_one_node;
+ COND_EXPR_COND (stmt) = boolean_true_node;
}
}
}
static void
make_goto_expr_edges (basic_block bb)
{
- tree goto_t, dest;
+ tree goto_t;
basic_block target_bb;
int for_call;
block_stmt_iterator last = bsi_last (bb);
CALL_EXPR or MODIFY_EXPR), then the edge is an abnormal edge resulting
from a nonlocal goto. */
if (TREE_CODE (goto_t) != GOTO_EXPR)
- {
- dest = error_mark_node;
- for_call = 1;
- }
+ for_call = 1;
else
{
- dest = GOTO_DESTINATION (goto_t);
+ tree dest = GOTO_DESTINATION (goto_t);
for_call = 0;
/* A GOTO to a local label creates normal edges. */
i = 0;
while (i < old_size - 1)
{
- tree base_case, base_label, base_high, type;
+ tree base_case, base_label, base_high;
base_case = TREE_VEC_ELT (labels, i);
gcc_assert (base_case);
continue;
}
- type = TREE_TYPE (CASE_LOW (base_case));
base_high = CASE_HIGH (base_case) ?
CASE_HIGH (base_case) : CASE_LOW (base_case);
i++;
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;
edge true_edge, false_edge;
extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
-
- /* Otherwise, try to determine which branch of the if() will be taken.
- If VAL is a constant but it can't be reduced to a 0 or a 1, then
- we don't really know which edge will be taken at runtime. This
- may happen when comparing addresses (e.g., if (&var1 == 4)). */
- if (integer_nonzerop (val))
- return true_edge;
- else if (integer_zerop (val))
- return false_edge;
-
- gcc_unreachable ();
+
+ gcc_assert (TREE_CODE (val) == INTEGER_CST);
+ return (zero_p (val) ? false_edge : true_edge);
}
-
/* Given an INTEGER_CST VAL and the entry block BB to a SWITCH_EXPR
statement, determine which edge will be taken out of the block. Return
NULL if any edge may be taken. */
{
/* 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)
{
int phi_num_args = PHI_NUM_ARGS (phi);
+ if (bb_for_stmt (phi) != bb)
+ {
+ error ("bb_for_stmt (phi) is set to a wrong basic block\n");
+ err |= true;
+ }
+
for (i = 0; i < phi_num_args; i++)
{
tree t = PHI_ARG_DEF (phi, i);
for (bsi = bsi_start (bb); !bsi_end_p (bsi); )
{
tree stmt = bsi_stmt (bsi);
+
+ if (bb_for_stmt (stmt) != bb)
+ {
+ error ("bb_for_stmt (stmt) is set to a wrong basic block\n");
+ err |= true;
+ }
+
bsi_next (&bsi);
err |= verify_stmt (stmt, bsi_end_p (bsi));
addr = walk_tree (&stmt, verify_node_sharing, htab, NULL);
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. */