This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Fix for automatic parallelization
Hi,
Here is the last fix for the problem that I've reported yesterday,
where gcc failed on the verification of loop structures. The patch
filters out all the loops that are in irreducible sections.
Another possible way to fix this problem is to mark the newly created
blocks and edges with the irreducible flag, but I'm not sure we want
to parallelize these loops.
Sebastian
Index: tree-parloops.c
===================================================================
--- tree-parloops.c (revision 131430)
+++ tree-parloops.c (working copy)
@@ -431,6 +431,25 @@ loop_parallel_p (struct loop *loop, htab
return ret;
}
+/* Return true when LOOP contains irreducible basic blocks. */
+
+static inline bool
+loop_has_irreducible_bbs (struct loop *loop)
+{
+ unsigned i;
+ basic_block *bbs = get_loop_body_in_dom_order (loop);
+ bool res = true;
+
+ for (i = 0; i < loop->num_nodes; i++)
+ if (bbs[i]->flags & BB_IRREDUCIBLE_LOOP)
+ goto end;
+
+ res = false;
+ end:
+ free (bbs);
+ return res;
+}
+
/* Assigns the address of OBJ in TYPE to an ssa name, and returns this name.
The assignment statement is placed before LOOP. DECL_ADDRESS maps decls
to their addresses that can be reused. The address of OBJ is known to
@@ -1738,6 +1757,7 @@ parallelize_loops (void)
|| expected_loop_iterations (loop) <= n_threads
/* And of course, the loop must be parallelizable. */
|| !can_duplicate_loop_p (loop)
+ || !loop_has_irreducible_bbs (loop)
|| !loop_parallel_p (loop, reduction_list, &niter_desc))
continue;