summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-im.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-loop-im.c')
-rw-r--r--gcc/tree-ssa-loop-im.c65
1 files changed, 36 insertions, 29 deletions
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 7f7f3528c14..0e806f4b682 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -633,7 +633,7 @@ mem_ref_in_stmt (gimple stmt)
else return false. */
static bool
-extract_true_false_args_from_phi (basic_block dom, gimple phi,
+extract_true_false_args_from_phi (basic_block dom, gphi *phi,
tree *true_arg_p, tree *false_arg_p)
{
basic_block bb = gimple_bb (phi);
@@ -716,7 +716,7 @@ determine_max_movement (gimple stmt, bool must_preserve_exec)
level = superloop_at_depth (loop, 1);
lim_data->max_loop = level;
- if (gimple_code (stmt) == GIMPLE_PHI)
+ if (gphi *phi = dyn_cast <gphi *> (stmt))
{
use_operand_p use_p;
unsigned min_cost = UINT_MAX;
@@ -727,7 +727,7 @@ determine_max_movement (gimple stmt, bool must_preserve_exec)
evaluated. For this reason the PHI cost (and thus the
cost we remove from the loop by doing the invariant motion)
is that of the cheapest PHI argument dependency chain. */
- FOR_EACH_PHI_ARG (use_p, stmt, iter, SSA_OP_USE)
+ FOR_EACH_PHI_ARG (use_p, phi, iter, SSA_OP_USE)
{
val = USE_FROM_PTR (use_p);
@@ -757,7 +757,7 @@ determine_max_movement (gimple stmt, bool must_preserve_exec)
min_cost = MIN (min_cost, total_cost);
lim_data->cost += min_cost;
- if (gimple_phi_num_args (stmt) > 1)
+ if (gimple_phi_num_args (phi) > 1)
{
basic_block dom = get_immediate_dominator (CDI_DOMINATORS, bb);
gimple cond;
@@ -769,7 +769,7 @@ determine_max_movement (gimple stmt, bool must_preserve_exec)
/* Verify that this is an extended form of a diamond and
the PHI arguments are completely controlled by the
predicate in DOM. */
- if (!extract_true_false_args_from_phi (dom, stmt, NULL, NULL))
+ if (!extract_true_false_args_from_phi (dom, phi, NULL, NULL))
return false;
/* Fold in dependencies and cost of the condition. */
@@ -886,12 +886,12 @@ nonpure_call_p (gimple stmt)
static gimple
rewrite_reciprocal (gimple_stmt_iterator *bsi)
{
- gimple stmt, stmt1, stmt2;
+ gassign *stmt, *stmt1, *stmt2;
tree name, lhs, type;
tree real_one;
gimple_stmt_iterator gsi;
- stmt = gsi_stmt (*bsi);
+ stmt = as_a <gassign *> (gsi_stmt (*bsi));
lhs = gimple_assign_lhs (stmt);
type = TREE_TYPE (lhs);
@@ -921,22 +921,28 @@ rewrite_reciprocal (gimple_stmt_iterator *bsi)
static gimple
rewrite_bittest (gimple_stmt_iterator *bsi)
{
- gimple stmt, use_stmt, stmt1, stmt2;
+ gassign *stmt;
+ gimple stmt1;
+ gassign *stmt2;
+ gimple use_stmt;
+ gcond *cond_stmt;
tree lhs, name, t, a, b;
use_operand_p use;
- stmt = gsi_stmt (*bsi);
+ stmt = as_a <gassign *> (gsi_stmt (*bsi));
lhs = gimple_assign_lhs (stmt);
/* Verify that the single use of lhs is a comparison against zero. */
if (TREE_CODE (lhs) != SSA_NAME
- || !single_imm_use (lhs, &use, &use_stmt)
- || gimple_code (use_stmt) != GIMPLE_COND)
+ || !single_imm_use (lhs, &use, &use_stmt))
return stmt;
- if (gimple_cond_lhs (use_stmt) != lhs
- || (gimple_cond_code (use_stmt) != NE_EXPR
- && gimple_cond_code (use_stmt) != EQ_EXPR)
- || !integer_zerop (gimple_cond_rhs (use_stmt)))
+ cond_stmt = dyn_cast <gcond *> (use_stmt);
+ if (!cond_stmt)
+ return stmt;
+ if (gimple_cond_lhs (cond_stmt) != lhs
+ || (gimple_cond_code (cond_stmt) != NE_EXPR
+ && gimple_cond_code (cond_stmt) != EQ_EXPR)
+ || !integer_zerop (gimple_cond_rhs (cond_stmt)))
return stmt;
/* Get at the operands of the shift. The rhs is TMP1 & 1. */
@@ -984,7 +990,9 @@ rewrite_bittest (gimple_stmt_iterator *bsi)
/* Replace the SSA_NAME we compare against zero. Adjust
the type of zero accordingly. */
SET_USE (use, name);
- gimple_cond_set_rhs (use_stmt, build_int_cst_type (TREE_TYPE (name), 0));
+ gimple_cond_set_rhs (cond_stmt,
+ build_int_cst_type (TREE_TYPE (name),
+ 0));
/* Don't use gsi_replace here, none of the new assignments sets
the variable originally set in stmt. Move bsi to stmt1, and
@@ -1168,18 +1176,16 @@ void
move_computations_dom_walker::before_dom_children (basic_block bb)
{
struct loop *level;
- gimple_stmt_iterator bsi;
- gimple stmt;
unsigned cost = 0;
struct lim_aux_data *lim_data;
if (!loop_outer (bb->loop_father))
return;
- for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); )
+ for (gphi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi); )
{
- gimple new_stmt;
- stmt = gsi_stmt (bsi);
+ gassign *new_stmt;
+ gphi *stmt = bsi.phi ();
lim_data = get_lim_data (stmt);
if (lim_data == NULL)
@@ -1233,11 +1239,11 @@ move_computations_dom_walker::before_dom_children (basic_block bb)
remove_phi_node (&bsi, false);
}
- for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); )
+ for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi); )
{
edge e;
- stmt = gsi_stmt (bsi);
+ gimple stmt = gsi_stmt (bsi);
lim_data = get_lim_data (stmt);
if (lim_data == NULL)
@@ -1275,11 +1281,11 @@ move_computations_dom_walker::before_dom_children (basic_block bb)
{
/* The new VUSE is the one from the virtual PHI in the loop
header or the one already present. */
- gimple_stmt_iterator gsi2;
+ gphi_iterator gsi2;
for (gsi2 = gsi_start_phis (e->dest);
!gsi_end_p (gsi2); gsi_next (&gsi2))
{
- gimple phi = gsi_stmt (gsi2);
+ gphi *phi = gsi2.phi ();
if (virtual_operand_p (gimple_phi_result (phi)))
{
gimple_set_vuse (stmt, PHI_ARG_DEF_FROM_EDGE (phi, e));
@@ -1886,9 +1892,10 @@ execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag)
}
if (!loop_has_only_one_exit)
- for (gsi = gsi_start_phis (old_dest); !gsi_end_p (gsi); gsi_next (&gsi))
+ for (gphi_iterator gpi = gsi_start_phis (old_dest);
+ !gsi_end_p (gpi); gsi_next (&gpi))
{
- gimple phi = gsi_stmt (gsi);
+ gphi *phi = gpi.phi ();
unsigned i;
for (i = 0; i < gimple_phi_num_args (phi); i++)
@@ -1950,7 +1957,7 @@ execute_sm (struct loop *loop, vec<edge> exits, mem_ref_p ref)
{
tree tmp_var, store_flag = NULL_TREE;
unsigned i;
- gimple load;
+ gassign *load;
struct fmt_data fmt_data;
edge ex;
struct lim_aux_data *lim_data;
@@ -2007,7 +2014,7 @@ execute_sm (struct loop *loop, vec<edge> exits, mem_ref_p ref)
FOR_EACH_VEC_ELT (exits, i, ex)
if (!multi_threaded_model_p)
{
- gimple store;
+ gassign *store;
store = gimple_build_assign (unshare_expr (ref->mem.ref), tmp_var);
gsi_insert_on_edge (ex, store);
}