Handle simple latch in expand_omp_for_generic
[gcc.git] / gcc / omp-low.c
index cdcf9d6d9c8477cef406a5c70c1e07c867f93ec9..f59a6a436f02dae5fc8ea6f028cbc018e7e91cf4 100644 (file)
@@ -6162,7 +6162,9 @@ expand_omp_for_generic (struct omp_region *region,
   if (!broken_loop)
     {
       l2_bb = create_empty_bb (cont_bb);
-      gcc_assert (BRANCH_EDGE (cont_bb)->dest == l1_bb);
+      gcc_assert (BRANCH_EDGE (cont_bb)->dest == l1_bb
+                 || (single_succ_edge (BRANCH_EDGE (cont_bb)->dest)->dest
+                     == l1_bb));
       gcc_assert (EDGE_COUNT (cont_bb->succs) == 2);
     }
   else
@@ -6438,6 +6440,11 @@ expand_omp_for_generic (struct omp_region *region,
       make_edge (cont_bb, l2_bb, EDGE_FALSE_VALUE);
       add_bb_to_loop (l2_bb, cont_bb->loop_father);
       e = find_edge (cont_bb, l1_bb);
+      if (e == NULL)
+       {
+         e = BRANCH_EDGE (cont_bb);
+         gcc_assert (single_succ (e->dest) == l1_bb);
+       }
       if (gimple_omp_for_combined_p (fd->for_stmt))
        {
          remove_edge (e);