Commit ed20ae98 by Thomas Schwinge Committed by Thomas Schwinge

Make it easier to diff expand_omp_for_* functions.

	gcc/
	* omp-low.c (expand_omp_for_static_chunk): Rename variable si to
	gsi, and variables v_* to v*.

From-SVN: r210858
parent 6842efc7
2014-05-23 Thomas Schwinge <thomas@codesourcery.com>
* omp-low.c (expand_omp_for_static_chunk): Rename variable si to
gsi, and variables v_* to v*.
2014-05-23 Eric Botcazou <ebotcazou@adacore.com> 2014-05-23 Eric Botcazou <ebotcazou@adacore.com>
* varasm.c (output_constructor_bitfield): Fix thinkos in latest change. * varasm.c (output_constructor_bitfield): Fix thinkos in latest change.
......
...@@ -6166,10 +6166,10 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -6166,10 +6166,10 @@ expand_omp_for_static_chunk (struct omp_region *region,
{ {
tree n, s0, e0, e, t; tree n, s0, e0, e, t;
tree trip_var, trip_init, trip_main, trip_back, nthreads, threadid; tree trip_var, trip_init, trip_main, trip_back, nthreads, threadid;
tree type, itype, v_main, v_back, v_extra; tree type, itype, vmain, vback, vextra;
basic_block entry_bb, exit_bb, body_bb, seq_start_bb, iter_part_bb; basic_block entry_bb, exit_bb, body_bb, seq_start_bb, iter_part_bb;
basic_block trip_update_bb = NULL, cont_bb, collapse_bb = NULL, fin_bb; basic_block trip_update_bb = NULL, cont_bb, collapse_bb = NULL, fin_bb;
gimple_stmt_iterator si; gimple_stmt_iterator gsi;
gimple stmt; gimple stmt;
edge se; edge se;
enum built_in_function get_num_threads = BUILT_IN_OMP_GET_NUM_THREADS; enum built_in_function get_num_threads = BUILT_IN_OMP_GET_NUM_THREADS;
...@@ -6202,8 +6202,8 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -6202,8 +6202,8 @@ expand_omp_for_static_chunk (struct omp_region *region,
exit_bb = region->exit; exit_bb = region->exit;
/* Trip and adjustment setup goes in ENTRY_BB. */ /* Trip and adjustment setup goes in ENTRY_BB. */
si = gsi_last_bb (entry_bb); gsi = gsi_last_bb (entry_bb);
gcc_assert (gimple_code (gsi_stmt (si)) == GIMPLE_OMP_FOR); gcc_assert (gimple_code (gsi_stmt (gsi)) == GIMPLE_OMP_FOR);
if (gimple_omp_for_kind (fd->for_stmt) == GF_OMP_FOR_KIND_DISTRIBUTE) if (gimple_omp_for_kind (fd->for_stmt) == GF_OMP_FOR_KIND_DISTRIBUTE)
{ {
...@@ -6217,7 +6217,7 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -6217,7 +6217,7 @@ expand_omp_for_static_chunk (struct omp_region *region,
basic_block l2_dom_bb = NULL; basic_block l2_dom_bb = NULL;
counts = XALLOCAVEC (tree, fd->collapse); counts = XALLOCAVEC (tree, fd->collapse);
expand_omp_for_init_counts (fd, &si, entry_bb, counts, expand_omp_for_init_counts (fd, &gsi, entry_bb, counts,
fin_bb, first_zero_iter, fin_bb, first_zero_iter,
l2_dom_bb); l2_dom_bb);
t = NULL_TREE; t = NULL_TREE;
...@@ -6233,21 +6233,21 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -6233,21 +6233,21 @@ expand_omp_for_static_chunk (struct omp_region *region,
&& (t == NULL_TREE || !integer_onep (t))) && (t == NULL_TREE || !integer_onep (t)))
{ {
n1 = fold_convert (type, unshare_expr (fd->loop.n1)); n1 = fold_convert (type, unshare_expr (fd->loop.n1));
n1 = force_gimple_operand_gsi (&si, n1, true, NULL_TREE, n1 = force_gimple_operand_gsi (&gsi, n1, true, NULL_TREE,
true, GSI_SAME_STMT); true, GSI_SAME_STMT);
n2 = fold_convert (type, unshare_expr (fd->loop.n2)); n2 = fold_convert (type, unshare_expr (fd->loop.n2));
n2 = force_gimple_operand_gsi (&si, n2, true, NULL_TREE, n2 = force_gimple_operand_gsi (&gsi, n2, true, NULL_TREE,
true, GSI_SAME_STMT); true, GSI_SAME_STMT);
stmt = gimple_build_cond (fd->loop.cond_code, n1, n2, stmt = gimple_build_cond (fd->loop.cond_code, n1, n2,
NULL_TREE, NULL_TREE); NULL_TREE, NULL_TREE);
gsi_insert_before (&si, stmt, GSI_SAME_STMT); gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
if (walk_tree (gimple_cond_lhs_ptr (stmt), if (walk_tree (gimple_cond_lhs_ptr (stmt),
expand_omp_regimplify_p, NULL, NULL) expand_omp_regimplify_p, NULL, NULL)
|| walk_tree (gimple_cond_rhs_ptr (stmt), || walk_tree (gimple_cond_rhs_ptr (stmt),
expand_omp_regimplify_p, NULL, NULL)) expand_omp_regimplify_p, NULL, NULL))
{ {
si = gsi_for_stmt (stmt); gsi = gsi_for_stmt (stmt);
gimple_regimplify_operands (stmt, &si); gimple_regimplify_operands (stmt, &gsi);
} }
se = split_block (entry_bb, stmt); se = split_block (entry_bb, stmt);
se->flags = EDGE_TRUE_VALUE; se->flags = EDGE_TRUE_VALUE;
...@@ -6258,25 +6258,25 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -6258,25 +6258,25 @@ expand_omp_for_static_chunk (struct omp_region *region,
if (gimple_in_ssa_p (cfun)) if (gimple_in_ssa_p (cfun))
{ {
int dest_idx = find_edge (entry_bb, fin_bb)->dest_idx; int dest_idx = find_edge (entry_bb, fin_bb)->dest_idx;
for (si = gsi_start_phis (fin_bb); for (gsi = gsi_start_phis (fin_bb);
!gsi_end_p (si); gsi_next (&si)) !gsi_end_p (gsi); gsi_next (&gsi))
{ {
gimple phi = gsi_stmt (si); gimple phi = gsi_stmt (gsi);
add_phi_arg (phi, gimple_phi_arg_def (phi, dest_idx), add_phi_arg (phi, gimple_phi_arg_def (phi, dest_idx),
se, UNKNOWN_LOCATION); se, UNKNOWN_LOCATION);
} }
} }
si = gsi_last_bb (entry_bb); gsi = gsi_last_bb (entry_bb);
} }
t = build_call_expr (builtin_decl_explicit (get_num_threads), 0); t = build_call_expr (builtin_decl_explicit (get_num_threads), 0);
t = fold_convert (itype, t); t = fold_convert (itype, t);
nthreads = force_gimple_operand_gsi (&si, t, true, NULL_TREE, nthreads = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
true, GSI_SAME_STMT); true, GSI_SAME_STMT);
t = build_call_expr (builtin_decl_explicit (get_thread_num), 0); t = build_call_expr (builtin_decl_explicit (get_thread_num), 0);
t = fold_convert (itype, t); t = fold_convert (itype, t);
threadid = force_gimple_operand_gsi (&si, t, true, NULL_TREE, threadid = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
true, GSI_SAME_STMT); true, GSI_SAME_STMT);
n1 = fd->loop.n1; n1 = fd->loop.n1;
...@@ -6293,14 +6293,14 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -6293,14 +6293,14 @@ expand_omp_for_static_chunk (struct omp_region *region,
gcc_assert (innerc); gcc_assert (innerc);
n2 = OMP_CLAUSE_DECL (innerc); n2 = OMP_CLAUSE_DECL (innerc);
} }
n1 = force_gimple_operand_gsi (&si, fold_convert (type, n1), n1 = force_gimple_operand_gsi (&gsi, fold_convert (type, n1),
true, NULL_TREE, true, GSI_SAME_STMT); true, NULL_TREE, true, GSI_SAME_STMT);
n2 = force_gimple_operand_gsi (&si, fold_convert (itype, n2), n2 = force_gimple_operand_gsi (&gsi, fold_convert (itype, n2),
true, NULL_TREE, true, GSI_SAME_STMT); true, NULL_TREE, true, GSI_SAME_STMT);
step = force_gimple_operand_gsi (&si, fold_convert (itype, step), step = force_gimple_operand_gsi (&gsi, fold_convert (itype, step),
true, NULL_TREE, true, GSI_SAME_STMT); true, NULL_TREE, true, GSI_SAME_STMT);
fd->chunk_size fd->chunk_size
= force_gimple_operand_gsi (&si, fold_convert (itype, fd->chunk_size), = force_gimple_operand_gsi (&gsi, fold_convert (itype, fd->chunk_size),
true, NULL_TREE, true, GSI_SAME_STMT); true, NULL_TREE, true, GSI_SAME_STMT);
t = build_int_cst (itype, (fd->loop.cond_code == LT_EXPR ? -1 : 1)); t = build_int_cst (itype, (fd->loop.cond_code == LT_EXPR ? -1 : 1));
...@@ -6314,7 +6314,7 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -6314,7 +6314,7 @@ expand_omp_for_static_chunk (struct omp_region *region,
else else
t = fold_build2 (TRUNC_DIV_EXPR, itype, t, step); t = fold_build2 (TRUNC_DIV_EXPR, itype, t, step);
t = fold_convert (itype, t); t = fold_convert (itype, t);
n = force_gimple_operand_gsi (&si, t, true, NULL_TREE, n = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
true, GSI_SAME_STMT); true, GSI_SAME_STMT);
trip_var = create_tmp_reg (itype, ".trip"); trip_var = create_tmp_reg (itype, ".trip");
...@@ -6332,7 +6332,7 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -6332,7 +6332,7 @@ expand_omp_for_static_chunk (struct omp_region *region,
} }
stmt = gimple_build_assign (trip_init, build_int_cst (itype, 0)); stmt = gimple_build_assign (trip_init, build_int_cst (itype, 0));
gsi_insert_before (&si, stmt, GSI_SAME_STMT); gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
t = fold_build2 (MULT_EXPR, itype, threadid, fd->chunk_size); t = fold_build2 (MULT_EXPR, itype, threadid, fd->chunk_size);
t = fold_build2 (MULT_EXPR, itype, t, step); t = fold_build2 (MULT_EXPR, itype, t, step);
...@@ -6340,31 +6340,31 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -6340,31 +6340,31 @@ expand_omp_for_static_chunk (struct omp_region *region,
t = fold_build_pointer_plus (n1, t); t = fold_build_pointer_plus (n1, t);
else else
t = fold_build2 (PLUS_EXPR, type, t, n1); t = fold_build2 (PLUS_EXPR, type, t, n1);
v_extra = force_gimple_operand_gsi (&si, t, true, NULL_TREE, vextra = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
true, GSI_SAME_STMT); true, GSI_SAME_STMT);
/* Remove the GIMPLE_OMP_FOR. */ /* Remove the GIMPLE_OMP_FOR. */
gsi_remove (&si, true); gsi_remove (&gsi, true);
/* Iteration space partitioning goes in ITER_PART_BB. */ /* Iteration space partitioning goes in ITER_PART_BB. */
si = gsi_last_bb (iter_part_bb); gsi = gsi_last_bb (iter_part_bb);
t = fold_build2 (MULT_EXPR, itype, trip_main, nthreads); t = fold_build2 (MULT_EXPR, itype, trip_main, nthreads);
t = fold_build2 (PLUS_EXPR, itype, t, threadid); t = fold_build2 (PLUS_EXPR, itype, t, threadid);
t = fold_build2 (MULT_EXPR, itype, t, fd->chunk_size); t = fold_build2 (MULT_EXPR, itype, t, fd->chunk_size);
s0 = force_gimple_operand_gsi (&si, t, true, NULL_TREE, s0 = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
false, GSI_CONTINUE_LINKING); false, GSI_CONTINUE_LINKING);
t = fold_build2 (PLUS_EXPR, itype, s0, fd->chunk_size); t = fold_build2 (PLUS_EXPR, itype, s0, fd->chunk_size);
t = fold_build2 (MIN_EXPR, itype, t, n); t = fold_build2 (MIN_EXPR, itype, t, n);
e0 = force_gimple_operand_gsi (&si, t, true, NULL_TREE, e0 = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
false, GSI_CONTINUE_LINKING); false, GSI_CONTINUE_LINKING);
t = build2 (LT_EXPR, boolean_type_node, s0, n); t = build2 (LT_EXPR, boolean_type_node, s0, n);
gsi_insert_after (&si, gimple_build_cond_empty (t), GSI_CONTINUE_LINKING); gsi_insert_after (&gsi, gimple_build_cond_empty (t), GSI_CONTINUE_LINKING);
/* Setup code for sequential iteration goes in SEQ_START_BB. */ /* Setup code for sequential iteration goes in SEQ_START_BB. */
si = gsi_start_bb (seq_start_bb); gsi = gsi_start_bb (seq_start_bb);
tree startvar = fd->loop.v; tree startvar = fd->loop.v;
tree endvar = NULL_TREE; tree endvar = NULL_TREE;
...@@ -6390,12 +6390,12 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -6390,12 +6390,12 @@ expand_omp_for_static_chunk (struct omp_region *region,
else else
t = fold_build2 (PLUS_EXPR, type, t, n1); t = fold_build2 (PLUS_EXPR, type, t, n1);
t = fold_convert (TREE_TYPE (startvar), t); t = fold_convert (TREE_TYPE (startvar), t);
t = force_gimple_operand_gsi (&si, t, t = force_gimple_operand_gsi (&gsi, t,
DECL_P (startvar) DECL_P (startvar)
&& TREE_ADDRESSABLE (startvar), && TREE_ADDRESSABLE (startvar),
NULL_TREE, false, GSI_CONTINUE_LINKING); NULL_TREE, false, GSI_CONTINUE_LINKING);
stmt = gimple_build_assign (startvar, t); stmt = gimple_build_assign (startvar, t);
gsi_insert_after (&si, stmt, GSI_CONTINUE_LINKING); gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
t = fold_convert (itype, e0); t = fold_convert (itype, e0);
t = fold_build2 (MULT_EXPR, itype, t, step); t = fold_build2 (MULT_EXPR, itype, t, step);
...@@ -6404,73 +6404,73 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -6404,73 +6404,73 @@ expand_omp_for_static_chunk (struct omp_region *region,
else else
t = fold_build2 (PLUS_EXPR, type, t, n1); t = fold_build2 (PLUS_EXPR, type, t, n1);
t = fold_convert (TREE_TYPE (startvar), t); t = fold_convert (TREE_TYPE (startvar), t);
e = force_gimple_operand_gsi (&si, t, true, NULL_TREE, e = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
false, GSI_CONTINUE_LINKING); false, GSI_CONTINUE_LINKING);
if (endvar) if (endvar)
{ {
stmt = gimple_build_assign (endvar, e); stmt = gimple_build_assign (endvar, e);
gsi_insert_after (&si, stmt, GSI_CONTINUE_LINKING); gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
if (useless_type_conversion_p (TREE_TYPE (fd->loop.v), TREE_TYPE (e))) if (useless_type_conversion_p (TREE_TYPE (fd->loop.v), TREE_TYPE (e)))
stmt = gimple_build_assign (fd->loop.v, e); stmt = gimple_build_assign (fd->loop.v, e);
else else
stmt = gimple_build_assign_with_ops (NOP_EXPR, fd->loop.v, e, stmt = gimple_build_assign_with_ops (NOP_EXPR, fd->loop.v, e,
NULL_TREE); NULL_TREE);
gsi_insert_after (&si, stmt, GSI_CONTINUE_LINKING); gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
} }
if (fd->collapse > 1) if (fd->collapse > 1)
expand_omp_for_init_vars (fd, &si, counts, inner_stmt, startvar); expand_omp_for_init_vars (fd, &gsi, counts, inner_stmt, startvar);
if (!broken_loop) if (!broken_loop)
{ {
/* The code controlling the sequential loop goes in CONT_BB, /* The code controlling the sequential loop goes in CONT_BB,
replacing the GIMPLE_OMP_CONTINUE. */ replacing the GIMPLE_OMP_CONTINUE. */
si = gsi_last_bb (cont_bb); gsi = gsi_last_bb (cont_bb);
stmt = gsi_stmt (si); stmt = gsi_stmt (gsi);
gcc_assert (gimple_code (stmt) == GIMPLE_OMP_CONTINUE); gcc_assert (gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
v_main = gimple_omp_continue_control_use (stmt); vmain = gimple_omp_continue_control_use (stmt);
v_back = gimple_omp_continue_control_def (stmt); vback = gimple_omp_continue_control_def (stmt);
if (!gimple_omp_for_combined_p (fd->for_stmt)) if (!gimple_omp_for_combined_p (fd->for_stmt))
{ {
if (POINTER_TYPE_P (type)) if (POINTER_TYPE_P (type))
t = fold_build_pointer_plus (v_main, step); t = fold_build_pointer_plus (vmain, step);
else else
t = fold_build2 (PLUS_EXPR, type, v_main, step); t = fold_build2 (PLUS_EXPR, type, vmain, step);
if (DECL_P (v_back) && TREE_ADDRESSABLE (v_back)) if (DECL_P (vback) && TREE_ADDRESSABLE (vback))
t = force_gimple_operand_gsi (&si, t, true, NULL_TREE, t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
true, GSI_SAME_STMT); true, GSI_SAME_STMT);
stmt = gimple_build_assign (v_back, t); stmt = gimple_build_assign (vback, t);
gsi_insert_before (&si, stmt, GSI_SAME_STMT); gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
t = build2 (fd->loop.cond_code, boolean_type_node, t = build2 (fd->loop.cond_code, boolean_type_node,
DECL_P (v_back) && TREE_ADDRESSABLE (v_back) DECL_P (vback) && TREE_ADDRESSABLE (vback)
? t : v_back, e); ? t : vback, e);
gsi_insert_before (&si, gimple_build_cond_empty (t), GSI_SAME_STMT); gsi_insert_before (&gsi, gimple_build_cond_empty (t), GSI_SAME_STMT);
} }
/* Remove GIMPLE_OMP_CONTINUE. */ /* Remove GIMPLE_OMP_CONTINUE. */
gsi_remove (&si, true); gsi_remove (&gsi, true);
if (fd->collapse > 1 && !gimple_omp_for_combined_p (fd->for_stmt)) if (fd->collapse > 1 && !gimple_omp_for_combined_p (fd->for_stmt))
collapse_bb = extract_omp_for_update_vars (fd, cont_bb, body_bb); collapse_bb = extract_omp_for_update_vars (fd, cont_bb, body_bb);
/* Trip update code goes into TRIP_UPDATE_BB. */ /* Trip update code goes into TRIP_UPDATE_BB. */
si = gsi_start_bb (trip_update_bb); gsi = gsi_start_bb (trip_update_bb);
t = build_int_cst (itype, 1); t = build_int_cst (itype, 1);
t = build2 (PLUS_EXPR, itype, trip_main, t); t = build2 (PLUS_EXPR, itype, trip_main, t);
stmt = gimple_build_assign (trip_back, t); stmt = gimple_build_assign (trip_back, t);
gsi_insert_after (&si, stmt, GSI_CONTINUE_LINKING); gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
} }
/* Replace the GIMPLE_OMP_RETURN with a barrier, or nothing. */ /* Replace the GIMPLE_OMP_RETURN with a barrier, or nothing. */
si = gsi_last_bb (exit_bb); gsi = gsi_last_bb (exit_bb);
if (!gimple_omp_return_nowait_p (gsi_stmt (si))) if (!gimple_omp_return_nowait_p (gsi_stmt (gsi)))
{ {
t = gimple_omp_return_lhs (gsi_stmt (si)); t = gimple_omp_return_lhs (gsi_stmt (gsi));
gsi_insert_after (&si, build_omp_barrier (t), GSI_SAME_STMT); gsi_insert_after (&gsi, build_omp_barrier (t), GSI_SAME_STMT);
} }
gsi_remove (&si, true); gsi_remove (&gsi, true);
/* Connect the new blocks. */ /* Connect the new blocks. */
find_edge (iter_part_bb, seq_start_bb)->flags = EDGE_TRUE_VALUE; find_edge (iter_part_bb, seq_start_bb)->flags = EDGE_TRUE_VALUE;
...@@ -6532,9 +6532,9 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -6532,9 +6532,9 @@ expand_omp_for_static_chunk (struct omp_region *region,
locus = gimple_phi_arg_location_from_edge (phi, se); locus = gimple_phi_arg_location_from_edge (phi, se);
/* A special case -- fd->loop.v is not yet computed in /* A special case -- fd->loop.v is not yet computed in
iter_part_bb, we need to use v_extra instead. */ iter_part_bb, we need to use vextra instead. */
if (t == fd->loop.v) if (t == fd->loop.v)
t = v_extra; t = vextra;
add_phi_arg (nphi, t, ene, locus); add_phi_arg (nphi, t, ene, locus);
locus = redirect_edge_var_map_location (vm); locus = redirect_edge_var_map_location (vm);
add_phi_arg (nphi, redirect_edge_var_map_def (vm), re, locus); add_phi_arg (nphi, redirect_edge_var_map_def (vm), re, locus);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment