static basic_block
expand_omp_for_ordered_loops (struct omp_for_data *fd, tree *counts,
basic_block cont_bb, basic_block body_bb,
- bool ordered_lastprivate)
+ basic_block l0_bb, bool ordered_lastprivate)
{
if (fd->ordered == fd->collapse)
return cont_bb;
class loop *loop = alloc_loop ();
loop->header = new_header;
loop->latch = e2->src;
- add_loop (loop, body_bb->loop_father);
+ add_loop (loop, l0_bb->loop_father);
}
}
}
if (i < fd->ordered)
{
+ if (entry_bb->loop_father != l0_bb->loop_father)
+ {
+ remove_bb_from_loops (l0_bb);
+ add_bb_to_loop (l0_bb, entry_bb->loop_father);
+ gcc_assert (single_succ (l0_bb) == l1_bb);
+ }
cont_bb
= create_empty_bb (EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb);
- add_bb_to_loop (cont_bb, l1_bb->loop_father);
+ add_bb_to_loop (cont_bb, l0_bb->loop_father);
gimple_stmt_iterator gsi = gsi_after_labels (cont_bb);
gimple *g = gimple_build_omp_continue (fd->loop.v, fd->loop.v);
gsi_insert_before (&gsi, g, GSI_SAME_STMT);
}
expand_omp_ordered_source_sink (region, fd, counts, cont_bb);
cont_bb = expand_omp_for_ordered_loops (fd, counts, cont_bb, l1_bb,
- ordered_lastprivate);
+ l0_bb, ordered_lastprivate);
if (counts[fd->collapse - 1])
{
gcc_assert (fd->collapse == 1);
--- /dev/null
+/* PR middle-end/108685 */
+/* { dg-do compile } */
+
+void
+foo (int a)
+{
+ for (int m = 0; m < 10; m++)
+ #pragma omp for collapse(2) ordered(4)
+ for (int i = 0; i < 2; i++)
+ for (int j = 0; j < a; j++)
+ for (int k = 0; k < 2; k++)
+ for (int l = 0; l < a; l++)
+ {
+ #pragma omp ordered depend (source)
+ __builtin_abort ();
+ }
+}