summaryrefslogtreecommitdiff
path: root/gcc/tree-parloops.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-parloops.c')
-rw-r--r--gcc/tree-parloops.c101
1 files changed, 58 insertions, 43 deletions
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index e5dca78082c..885dc314994 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -203,12 +203,12 @@ struct reduction_info
enum tree_code reduction_code;/* code for the reduction operation. */
unsigned reduc_version; /* SSA_NAME_VERSION of original reduc_phi
result. */
- gimple keep_res; /* The PHI_RESULT of this phi is the resulting value
+ gphi *keep_res; /* The PHI_RESULT of this phi is the resulting value
of the reduction variable when existing the loop. */
tree initial_value; /* The initial value of the reduction var before entering the loop. */
tree field; /* the name of the field in the parloop data structure intended for reduction. */
tree init; /* reduction initialization value. */
- gimple new_phi; /* (helper field) Newly created phi node whose result
+ gphi *new_phi; /* (helper field) Newly created phi node whose result
will be passed to the atomic operation. Represents
the local result each thread computed for the reduction
operation. */
@@ -501,7 +501,7 @@ take_address_of (tree obj, tree type, edge entry,
{
int uid;
tree *var_p, name, addr;
- gimple stmt;
+ gassign *stmt;
gimple_seq stmts;
/* Since the address of OBJ is invariant, the trees may be shared.
@@ -1038,7 +1038,7 @@ create_phi_for_local_result (reduction_info **slot, struct loop *loop)
{
struct reduction_info *const reduc = *slot;
edge e;
- gimple new_phi;
+ gphi *new_phi;
basic_block store_bb;
tree local_res;
source_location locus;
@@ -1509,23 +1509,26 @@ transform_to_exit_first_loop (struct loop *loop,
bool ok;
edge exit = single_dom_exit (loop), hpred;
tree control, control_name, res, t;
- gimple phi, nphi, cond_stmt, stmt, cond_nit;
- gimple_stmt_iterator gsi;
+ gphi *phi, *nphi;
+ gassign *stmt;
+ gcond *cond_stmt, *cond_nit;
tree nit_1;
split_block_after_labels (loop->header);
orig_header = single_succ (loop->header);
hpred = single_succ_edge (loop->header);
- cond_stmt = last_stmt (exit->src);
+ cond_stmt = as_a <gcond *> (last_stmt (exit->src));
control = gimple_cond_lhs (cond_stmt);
gcc_assert (gimple_cond_rhs (cond_stmt) == nit);
/* Make sure that we have phi nodes on exit for all loop header phis
(create_parallel_loop requires that). */
- for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
+ for (gphi_iterator gsi = gsi_start_phis (loop->header);
+ !gsi_end_p (gsi);
+ gsi_next (&gsi))
{
- phi = gsi_stmt (gsi);
+ phi = gsi.phi ();
res = PHI_RESULT (phi);
t = copy_ssa_name (res, phi);
SET_PHI_RESULT (phi, t);
@@ -1556,9 +1559,10 @@ transform_to_exit_first_loop (struct loop *loop,
out of the loop is the control variable. */
exit = single_dom_exit (loop);
control_name = NULL_TREE;
- for (gsi = gsi_start_phis (ex_bb); !gsi_end_p (gsi); )
+ for (gphi_iterator gsi = gsi_start_phis (ex_bb);
+ !gsi_end_p (gsi); )
{
- phi = gsi_stmt (gsi);
+ phi = gsi.phi ();
res = PHI_RESULT (phi);
if (virtual_operand_p (res))
{
@@ -1593,8 +1597,8 @@ transform_to_exit_first_loop (struct loop *loop,
/* Initialize the control variable to number of iterations
according to the rhs of the exit condition. */
- gsi = gsi_after_labels (ex_bb);
- cond_nit = last_stmt (exit->src);
+ gimple_stmt_iterator gsi = gsi_after_labels (ex_bb);
+ cond_nit = as_a <gcond *> (last_stmt (exit->src));
nit_1 = gimple_cond_rhs (cond_nit);
nit_1 = force_gimple_operand_gsi (&gsi,
fold_convert (TREE_TYPE (control_name), nit_1),
@@ -1616,7 +1620,12 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
gimple_stmt_iterator gsi;
basic_block bb, paral_bb, for_bb, ex_bb;
tree t, param;
- gimple stmt, for_stmt, phi, cond_stmt;
+ gomp_parallel *omp_par_stmt;
+ gimple omp_return_stmt1, omp_return_stmt2;
+ gimple phi;
+ gcond *cond_stmt;
+ gomp_for *for_stmt;
+ gomp_continue *omp_cont_stmt;
tree cvar, cvar_init, initvar, cvar_next, cvar_base, type;
edge exit, nexit, guard, end, e;
@@ -1628,35 +1637,37 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
t = build_omp_clause (loc, OMP_CLAUSE_NUM_THREADS);
OMP_CLAUSE_NUM_THREADS_EXPR (t)
= build_int_cst (integer_type_node, n_threads);
- stmt = gimple_build_omp_parallel (NULL, t, loop_fn, data);
- gimple_set_location (stmt, loc);
+ omp_par_stmt = gimple_build_omp_parallel (NULL, t, loop_fn, data);
+ gimple_set_location (omp_par_stmt, loc);
- gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
+ gsi_insert_after (&gsi, omp_par_stmt, GSI_NEW_STMT);
/* Initialize NEW_DATA. */
if (data)
{
+ gassign *assign_stmt;
+
gsi = gsi_after_labels (bb);
param = make_ssa_name (DECL_ARGUMENTS (loop_fn), NULL);
- stmt = gimple_build_assign (param, build_fold_addr_expr (data));
- gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+ assign_stmt = gimple_build_assign (param, build_fold_addr_expr (data));
+ gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT);
- stmt = gimple_build_assign (new_data,
+ assign_stmt = gimple_build_assign (new_data,
fold_convert (TREE_TYPE (new_data), param));
- gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+ gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT);
}
/* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_PARALLEL. */
bb = split_loop_exit_edge (single_dom_exit (loop));
gsi = gsi_last_bb (bb);
- stmt = gimple_build_omp_return (false);
- gimple_set_location (stmt, loc);
- gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
+ omp_return_stmt1 = gimple_build_omp_return (false);
+ gimple_set_location (omp_return_stmt1, loc);
+ gsi_insert_after (&gsi, omp_return_stmt1, GSI_NEW_STMT);
/* Extract data for GIMPLE_OMP_FOR. */
gcc_assert (loop->header == single_dom_exit (loop)->src);
- cond_stmt = last_stmt (loop->header);
+ cond_stmt = as_a <gcond *> (last_stmt (loop->header));
cvar = gimple_cond_lhs (cond_stmt);
cvar_base = SSA_NAME_VAR (cvar);
@@ -1680,12 +1691,16 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
guard = make_edge (for_bb, ex_bb, 0);
single_succ_edge (loop->latch)->flags = 0;
end = make_edge (loop->latch, ex_bb, EDGE_FALLTHRU);
- for (gsi = gsi_start_phis (ex_bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ for (gphi_iterator gpi = gsi_start_phis (ex_bb);
+ !gsi_end_p (gpi); gsi_next (&gpi))
{
source_location locus;
tree def;
- phi = gsi_stmt (gsi);
- stmt = SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, exit));
+ gphi *phi = gpi.phi ();
+ gphi *stmt;
+
+ stmt = as_a <gphi *> (
+ SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, exit)));
def = PHI_ARG_DEF_FROM_EDGE (stmt, loop_preheader_edge (loop));
locus = gimple_phi_arg_location_from_edge (stmt,
@@ -1721,16 +1736,16 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
/* Emit GIMPLE_OMP_CONTINUE. */
gsi = gsi_last_bb (loop->latch);
- stmt = gimple_build_omp_continue (cvar_next, cvar);
- gimple_set_location (stmt, loc);
- gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
- SSA_NAME_DEF_STMT (cvar_next) = stmt;
+ omp_cont_stmt = gimple_build_omp_continue (cvar_next, cvar);
+ gimple_set_location (omp_cont_stmt, loc);
+ gsi_insert_after (&gsi, omp_cont_stmt, GSI_NEW_STMT);
+ SSA_NAME_DEF_STMT (cvar_next) = omp_cont_stmt;
/* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_FOR. */
gsi = gsi_last_bb (ex_bb);
- stmt = gimple_build_omp_return (true);
- gimple_set_location (stmt, loc);
- gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
+ omp_return_stmt2 = gimple_build_omp_return (true);
+ gimple_set_location (omp_return_stmt2, loc);
+ gsi_insert_after (&gsi, omp_return_stmt2, GSI_NEW_STMT);
/* After the above dom info is hosed. Re-compute it. */
free_dominance_info (CDI_DOMINATORS);
@@ -1914,12 +1929,12 @@ loop_has_vector_phi_nodes (struct loop *loop ATTRIBUTE_UNUSED)
{
unsigned i;
basic_block *bbs = get_loop_body_in_dom_order (loop);
- gimple_stmt_iterator gsi;
+ gphi_iterator gsi;
bool res = true;
for (i = 0; i < loop->num_nodes; i++)
for (gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi))
- if (TREE_CODE (TREE_TYPE (PHI_RESULT (gsi_stmt (gsi)))) == VECTOR_TYPE)
+ if (TREE_CODE (TREE_TYPE (PHI_RESULT (gsi.phi ()))) == VECTOR_TYPE)
goto end;
res = false;
@@ -1933,7 +1948,7 @@ loop_has_vector_phi_nodes (struct loop *loop ATTRIBUTE_UNUSED)
static void
build_new_reduction (reduction_info_table_type *reduction_list,
- gimple reduc_stmt, gimple phi)
+ gimple reduc_stmt, gphi *phi)
{
reduction_info **slot;
struct reduction_info *new_reduction;
@@ -1973,14 +1988,14 @@ set_reduc_phi_uids (reduction_info **slot, void *data ATTRIBUTE_UNUSED)
static void
gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list)
{
- gimple_stmt_iterator gsi;
+ gphi_iterator gsi;
loop_vec_info simple_loop_info;
simple_loop_info = vect_analyze_loop_form (loop);
for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
{
- gimple phi = gsi_stmt (gsi);
+ gphi *phi = gsi.phi ();
affine_iv iv;
tree res = PHI_RESULT (phi);
bool double_reduc;
@@ -2036,7 +2051,7 @@ try_create_reduction_list (loop_p loop,
reduction_info_table_type *reduction_list)
{
edge exit = single_dom_exit (loop);
- gimple_stmt_iterator gsi;
+ gphi_iterator gsi;
gcc_assert (exit);
@@ -2045,7 +2060,7 @@ try_create_reduction_list (loop_p loop,
for (gsi = gsi_start_phis (exit->dest); !gsi_end_p (gsi); gsi_next (&gsi))
{
- gimple phi = gsi_stmt (gsi);
+ gphi *phi = gsi.phi ();
struct reduction_info *red;
imm_use_iterator imm_iter;
use_operand_p use_p;
@@ -2103,7 +2118,7 @@ try_create_reduction_list (loop_p loop,
iteration space can be distributed efficiently. */
for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
{
- gimple phi = gsi_stmt (gsi);
+ gphi *phi = gsi.phi ();
tree def = PHI_RESULT (phi);
affine_iv iv;