static tree
split_at_bb_p (class loop *loop, basic_block bb, tree *border, affine_iv *iv)
{
- gimple *last;
gcond *stmt;
affine_iv iv2;
/* BB must end in a simple conditional jump. */
- last = last_stmt (bb);
- if (!last || gimple_code (last) != GIMPLE_COND)
+ stmt = safe_dyn_cast <gcond *> (*gsi_last_bb (bb));
+ if (!stmt)
return NULL_TREE;
- stmt = as_a <gcond *> (last);
enum tree_code code = gimple_cond_code (stmt);
bool initial_true)
{
edge exit = single_exit (loop);
- gcond *stmt = as_a <gcond *> (last_stmt (exit->src));
+ gcond *stmt = as_a <gcond *> (*gsi_last_bb (exit->src));
gimple_cond_set_condition (stmt, gimple_cond_code (guard),
nextval, newbound);
update_stmt (stmt);
gimple_stmt_iterator gsi;
edge new_e, skip_e;
- gimple *stmt = last_stmt (exit->src);
+ gcond *stmt = as_a <gcond *> (*gsi_last_bb (exit->src));
skip_stmt = gimple_build_cond (gimple_cond_code (stmt),
gimple_cond_lhs (stmt),
gimple_cond_rhs (stmt),
gphi *phi = find_or_create_guard_phi (loop1, guard_iv, &iv);
if (!phi)
continue;
- gcond *guard_stmt = as_a<gcond *> (last_stmt (bbs[i]));
+ gcond *guard_stmt = as_a<gcond *> (*gsi_last_bb (bbs[i]));
tree guard_init = PHI_ARG_DEF_FROM_EDGE (phi,
loop_preheader_edge (loop1));
enum tree_code guard_code = gimple_cond_code (guard_stmt);
/* Finally patch out the two copies of the condition to be always
true/false (or opposite). */
- gcond *force_true = as_a<gcond *> (last_stmt (bbs[i]));
- gcond *force_false = as_a<gcond *> (last_stmt (get_bb_copy (bbs[i])));
+ gcond *force_true = as_a<gcond *> (*gsi_last_bb (bbs[i]));
+ gcond *force_false = as_a<gcond *> (*gsi_last_bb (get_bb_copy (bbs[i])));
if (!initial_true)
std::swap (force_true, force_false);
gimple_cond_make_true (force_true);
for (hash_set<basic_block>::iterator iter = dep_bbs->begin ();
iter != dep_bbs->end (); ++iter)
{
- gimple *last = last_stmt (*iter);
-
+ gimple *last = *gsi_last_bb (*iter);
if (!last)
return false;
{
basic_block cond_bb = invar_branch->src;
bool true_invar = !!(invar_branch->flags & EDGE_TRUE_VALUE);
- gcond *cond = as_a <gcond *> (last_stmt (cond_bb));
+ gcond *cond = as_a <gcond *> (*gsi_last_bb (cond_bb));
gcc_assert (cond_bb->loop_father == loop1);
}
basic_block cond_bb_copy = get_bb_copy (cond_bb);
- gcond *cond_copy = as_a<gcond *> (last_stmt (cond_bb_copy));
+ gcond *cond_copy = as_a<gcond *> (*gsi_last_bb (cond_bb_copy));
/* Replace the condition in loop2 with a bool constant to let PassManager
remove the variant branch after current pass completes. */
if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
continue;
- gimple *last = last_stmt (bb);
-
- if (!last || gimple_code (last) != GIMPLE_COND)
+ gcond *cond = safe_dyn_cast <gcond *> (*gsi_last_bb (bb));
+ if (!cond)
continue;
- gcond *cond = as_a <gcond *> (last);
edge branch_edge = get_cond_branch_to_split_loop (loop, cond);
if (branch_edge)
ssa_op_iter iter;
/* BB must end in a simple conditional jump. */
- last = last_stmt (bb);
+ last = *gsi_last_bb (bb);
if (!last)
return;
if (predicates.is_empty ())
continue;
- gimple *stmt = last_stmt (bbs[i]);
+ gimple *stmt = *gsi_last_bb (bbs[i]);
tree folded = evaluate_control_stmt_using_entry_checks (stmt,
predicate_path,
ignored_edge_flag,
if (visit (bb))
break;
- gimple *last = last_stmt (bb);
+ gimple *last = *gsi_last_bb (bb);
if (gcond *cond = safe_dyn_cast <gcond *> (last))
{
if (gimple_cond_true_p (cond))
next = single_succ (header);
else
{
- cond = safe_dyn_cast <gcond *> (last_stmt (header));
+ cond = safe_dyn_cast <gcond *> (*gsi_last_bb (header));
if (! cond)
return NULL;
extract_true_false_edges_from_block (header, &te, &fe);
FOR_EACH_BB_FN (bb, cfun)
{
- gswitch *stmt= safe_dyn_cast <gswitch *> (last_stmt (bb));
+ gswitch *stmt= safe_dyn_cast <gswitch *> (*gsi_last_bb (bb));
if (stmt && !CONSTANT_CLASS_P (gimple_switch_index (stmt)))
{
unsigned nlabels = gimple_switch_num_labels (stmt);
}
else if (!single_succ_p (bb) || other_edge->dest != single_succ (bb))
return;
- gimple *zero_cond = last_stmt (pred_bb);
+ gcond *zero_cond = safe_dyn_cast <gcond *> (*gsi_last_bb (pred_bb));
if (zero_cond == NULL
- || gimple_code (zero_cond) != GIMPLE_COND
|| (gimple_cond_code (zero_cond)
!= ((pred_edge->flags & EDGE_TRUE_VALUE) ? NE_EXPR : EQ_EXPR))
|| !integer_zerop (gimple_cond_rhs (zero_cond)))
else if (!integer_onep (other_val))
return;
}
- gcond *zero_gcond = as_a <gcond *> (zero_cond);
if (pred_edge->flags & EDGE_TRUE_VALUE)
- gimple_cond_make_true (zero_gcond);
+ gimple_cond_make_true (zero_cond);
else
- gimple_cond_make_false (zero_gcond);
+ gimple_cond_make_false (zero_cond);
update_stmt (zero_cond);
*cfg_changed = true;
}
conditional jump sequence. */
static void
-optimize_spaceship (gimple *stmt)
+optimize_spaceship (gcond *stmt)
{
enum tree_code code = gimple_cond_code (stmt);
if (code != EQ_EXPR && code != NE_EXPR)
if (((EDGE_SUCC (bb0, 0)->flags & EDGE_TRUE_VALUE) != 0) ^ (code == EQ_EXPR))
bb1 = EDGE_SUCC (bb0, 0)->dest;
- gimple *g = last_stmt (bb1);
+ gcond *g = safe_dyn_cast <gcond *> (*gsi_last_bb (bb1));
if (g == NULL
- || gimple_code (g) != GIMPLE_COND
|| !single_pred_p (bb1)
|| (operand_equal_p (gimple_cond_lhs (g), arg1, 0)
? !operand_equal_p (gimple_cond_rhs (g), arg2, 0)
continue;
bb2 = EDGE_SUCC (bb1, i)->dest;
- g = last_stmt (bb2);
+ g = safe_dyn_cast <gcond *> (*gsi_last_bb (bb2));
if (g == NULL
- || gimple_code (g) != GIMPLE_COND
|| !single_pred_p (bb2)
|| (operand_equal_p (gimple_cond_lhs (g), arg1, 0)
? !operand_equal_p (gimple_cond_rhs (g), arg2, 0)
}
}
- g = gimple_build_call_internal (IFN_SPACESHIP, 2, arg1, arg2);
+ gcall *gc = gimple_build_call_internal (IFN_SPACESHIP, 2, arg1, arg2);
tree lhs = make_ssa_name (integer_type_node);
- gimple_call_set_lhs (g, lhs);
+ gimple_call_set_lhs (gc, lhs);
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
- gsi_insert_before (&gsi, g, GSI_SAME_STMT);
+ gsi_insert_before (&gsi, gc, GSI_SAME_STMT);
- gcond *cond = as_a <gcond *> (stmt);
- gimple_cond_set_lhs (cond, lhs);
- gimple_cond_set_rhs (cond, integer_zero_node);
+ gimple_cond_set_lhs (stmt, lhs);
+ gimple_cond_set_rhs (stmt, integer_zero_node);
update_stmt (stmt);
- g = last_stmt (bb1);
- cond = as_a <gcond *> (g);
+ gcond *cond = as_a <gcond *> (*gsi_last_bb (bb1));
gimple_cond_set_lhs (cond, lhs);
if (em1->src == bb1 && e2 != em1)
{
gimple_cond_set_code (cond, (e1->flags & EDGE_TRUE_VALUE)
? EQ_EXPR : NE_EXPR);
}
- update_stmt (g);
+ update_stmt (cond);
if (e2 != e1 && e2 != em1)
{
- g = last_stmt (bb2);
- cond = as_a <gcond *> (g);
+ cond = as_a <gcond *> (*gsi_last_bb (bb2));
gimple_cond_set_lhs (cond, lhs);
if (em1->src == bb2)
gimple_cond_set_rhs (cond, integer_minus_one_node);
}
gimple_cond_set_code (cond,
(e2->flags & EDGE_TRUE_VALUE) ? NE_EXPR : EQ_EXPR);
- update_stmt (g);
+ update_stmt (cond);
}
wide_int wm1 = wi::minus_one (TYPE_PRECISION (integer_type_node));
}
}
else if (gimple_code (stmt) == GIMPLE_COND)
- optimize_spaceship (stmt);
+ optimize_spaceship (as_a <gcond *> (stmt));
gsi_next (&gsi);
}
if (fma_state.m_deferring_p
maybe_set_nonzero_bits (edge e, tree var)
{
basic_block cond_bb = e->src;
- gimple *stmt = last_stmt (cond_bb);
+ gcond *cond = safe_dyn_cast <gcond *> (*gsi_last_bb (cond_bb));
tree cst;
- if (stmt == NULL
- || gimple_code (stmt) != GIMPLE_COND
- || gimple_cond_code (stmt) != ((e->flags & EDGE_TRUE_VALUE)
+ if (cond == NULL
+ || gimple_cond_code (cond) != ((e->flags & EDGE_TRUE_VALUE)
? EQ_EXPR : NE_EXPR)
- || TREE_CODE (gimple_cond_lhs (stmt)) != SSA_NAME
- || !integer_zerop (gimple_cond_rhs (stmt)))
+ || TREE_CODE (gimple_cond_lhs (cond)) != SSA_NAME
+ || !integer_zerop (gimple_cond_rhs (cond)))
return;
- stmt = SSA_NAME_DEF_STMT (gimple_cond_lhs (stmt));
+ gimple *stmt = SSA_NAME_DEF_STMT (gimple_cond_lhs (cond));
if (!is_gimple_assign (stmt)
|| gimple_assign_rhs_code (stmt) != BIT_AND_EXPR
|| TREE_CODE (gimple_assign_rhs2 (stmt)) != INTEGER_CST)
void
pointer_equiv_analyzer::visit_edge (edge e)
{
- gimple *stmt = last_stmt (e->src);
+ gcond *stmt = safe_dyn_cast <gcond *> (*gsi_last_bb (e->src));
tree lhs;
// Recognize: x_13 [==,!=] &foo.
if (stmt
- && gimple_code (stmt) == GIMPLE_COND
- && (lhs = gimple_cond_lhs (stmt))
+ && ((lhs = gimple_cond_lhs (stmt)), true)
&& TREE_CODE (lhs) == SSA_NAME
&& POINTER_TYPE_P (TREE_TYPE (lhs))
&& TREE_CODE (gimple_cond_rhs (stmt)) == ADDR_EXPR)