Commit 17720e84 by Tom de Vries Committed by Tom de Vries

Handle 2 preds for fin_bb in expand_omp_for_static_chunk

2015-09-03  Tom de Vries  <tom@codesourcery.com>

	PR tree-optimization/65637
	* omp-low.c (expand_omp_for_static_chunk): Handle case that fin_bb has 2
	predecessors.

	* gcc.dg/autopar/reduc-4.c: New test.

From-SVN: r227438
parent 1b96e9a4
2015-09-03 Tom de Vries <tom@codesourcery.com> 2015-09-03 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/65637 PR tree-optimization/65637
* omp-low.c (expand_omp_for_static_chunk): Handle case that fin_bb has 2
predecessors.
2015-09-03 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/65637
* omp-low.c (find_phi_with_arg_on_edge): New function. * omp-low.c (find_phi_with_arg_on_edge): New function.
(expand_omp_for_static_chunk): Fix inner loop phi. (expand_omp_for_static_chunk): Fix inner loop phi.
......
...@@ -7035,7 +7035,7 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -7035,7 +7035,7 @@ expand_omp_for_static_chunk (struct omp_region *region,
se->probability = REG_BR_PROB_BASE / 2000 - 1; se->probability = REG_BR_PROB_BASE / 2000 - 1;
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 (iter_part_bb, fin_bb)->dest_idx;
for (gphi_iterator gpi = gsi_start_phis (fin_bb); for (gphi_iterator gpi = gsi_start_phis (fin_bb);
!gsi_end_p (gpi); gsi_next (&gpi)) !gsi_end_p (gpi); gsi_next (&gpi))
{ {
...@@ -7316,7 +7316,7 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -7316,7 +7316,7 @@ expand_omp_for_static_chunk (struct omp_region *region,
/* When we redirect the edge from trip_update_bb to iter_part_bb, we /* When we redirect the edge from trip_update_bb to iter_part_bb, we
remove arguments of the phi nodes in fin_bb. We need to create remove arguments of the phi nodes in fin_bb. We need to create
appropriate phi nodes in iter_part_bb instead. */ appropriate phi nodes in iter_part_bb instead. */
se = single_pred_edge (fin_bb); se = find_edge (iter_part_bb, fin_bb);
re = single_succ_edge (trip_update_bb); re = single_succ_edge (trip_update_bb);
vec<edge_var_map> *head = redirect_edge_var_map_vector (re); vec<edge_var_map> *head = redirect_edge_var_map_vector (re);
ene = single_succ_edge (entry_bb); ene = single_succ_edge (entry_bb);
...@@ -7331,6 +7331,10 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -7331,6 +7331,10 @@ expand_omp_for_static_chunk (struct omp_region *region,
phi = psi.phi (); phi = psi.phi ();
t = gimple_phi_result (phi); t = gimple_phi_result (phi);
gcc_assert (t == redirect_edge_var_map_result (vm)); gcc_assert (t == redirect_edge_var_map_result (vm));
if (!single_pred_p (fin_bb))
t = copy_ssa_name (t, phi);
nphi = create_phi_node (t, iter_part_bb); nphi = create_phi_node (t, iter_part_bb);
t = PHI_ARG_DEF_FROM_EDGE (phi, se); t = PHI_ARG_DEF_FROM_EDGE (phi, se);
...@@ -7355,16 +7359,20 @@ expand_omp_for_static_chunk (struct omp_region *region, ...@@ -7355,16 +7359,20 @@ expand_omp_for_static_chunk (struct omp_region *region,
gcc_assert (inner_loop_phi != NULL); gcc_assert (inner_loop_phi != NULL);
add_phi_arg (inner_loop_phi, gimple_phi_result (nphi), add_phi_arg (inner_loop_phi, gimple_phi_result (nphi),
find_edge (seq_start_bb, body_bb), locus); find_edge (seq_start_bb, body_bb), locus);
if (!single_pred_p (fin_bb))
add_phi_arg (phi, gimple_phi_result (nphi), se, locus);
} }
gcc_assert (gsi_end_p (psi) && (head == NULL || i == head->length ())); gcc_assert (gsi_end_p (psi) && (head == NULL || i == head->length ()));
redirect_edge_var_map_clear (re); redirect_edge_var_map_clear (re);
while (1) if (single_pred_p (fin_bb))
{ while (1)
psi = gsi_start_phis (fin_bb); {
if (gsi_end_p (psi)) psi = gsi_start_phis (fin_bb);
break; if (gsi_end_p (psi))
remove_phi_node (&psi, false); break;
} remove_phi_node (&psi, false);
}
/* Make phi node for trip. */ /* Make phi node for trip. */
phi = create_phi_node (trip_main, iter_part_bb); phi = create_phi_node (trip_main, iter_part_bb);
......
2015-09-03 Tom de Vries <tom@codesourcery.com> 2015-09-03 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/65637 PR tree-optimization/65637
* gcc.dg/autopar/reduc-4.c: New test.
2015-09-03 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/65637
* gcc.dg/autopar/pr46099-2.c: New test. * gcc.dg/autopar/pr46099-2.c: New test.
2015-09-03 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com> 2015-09-03 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>
......
/* { dg-do compile } */
/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized --param parloops-chunk-size=100" } */
#include "reduc-3.c"
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