@@ -280,7 +280,7 @@ opencl_get_perfect_nested_loop_depth (opencl_main code_gen,
{
struct clast_for *child;
- if (dependency_in_clast_loop_p (code_gen, meta, loop, depth))
+ if (enabled_dependency_in_clast_loop_p (code_gen, meta, loop, depth))
return 0;
child = opencl_get_single_loop_child (loop);
@@ -2144,9 +2144,8 @@ opencl_transform_stmt_list (struct clast_stmt *s, opencl_main code_gen,
bool parallel = false;
/* If there are dependencies in loop, it can't be parallelized. */
- if (!flag_graphite_opencl_no_dep_check &&
- dependency_in_clast_loop_p (code_gen, current_clast,
- for_stmt, depth))
+ if (enabled_dependency_in_clast_loop_p (code_gen, current_clast,
+ for_stmt, depth))
{
if (dump_p)
fprintf (dump_file, "dependency in loop\n");
@@ -2609,6 +2608,20 @@ dependency_in_clast_loop_p (opencl_main code_gen, opencl_clast_meta meta,
return false;
}
+/* Returns true, if dependency checking enabled and there is dependency in
+ clast loop STMT on depth DEPTH.
+ CODE_GEN holds information related to code generation. */
+
+bool
+enabled_dependency_in_clast_loop_p (opencl_main code_gen,
+ opencl_clast_meta meta,
+ struct clast_for *stmt, int depth)
+{
+ if (flag_graphite_opencl_no_dep_check)
+ return false;
+ return dependency_in_clast_loop_p (code_gen, meta, stmt, depth);
+}
+
/* Init graphite-opencl pass. Must be called in each function before
any scop processing. */
@@ -251,4 +251,6 @@ extern bool opencl_should_be_parallel_p (opencl_main, opencl_clast_meta, int);
extern basic_block opencl_create_bb (opencl_main);
extern bool dependency_in_clast_loop_p (opencl_main, opencl_clast_meta,
struct clast_for *, int);
+extern bool enabled_dependency_in_clast_loop_p (opencl_main, opencl_clast_meta,
+ struct clast_for *, int);
extern tree opencl_get_base_object_by_tree (tree);
new file mode 100644
@@ -0,0 +1,46 @@
+/* { dg-do compile } */
+/* { dg-options "-fgraphite-opencl -fgraphite-opencl-ignore-dep -g -Ofast" } */
+
+#define DEBUG 0
+#if DEBUG
+#include <stdio.h>
+#endif
+
+#define N 1000
+int a[N];
+
+static int __attribute__((noinline))
+foo (void)
+{
+ int j;
+ int i;
+
+ /* This is not blocked as it is not profitable. */
+ for (i = 0; i < N; i++)
+ for (j = 0; j < N; j++)
+ a[j] = a[i] + 1;
+
+ return a[0];
+}
+
+extern void abort ();
+
+int
+main (void)
+{
+ int i, res;
+
+ for (i = 0; i < N; i++)
+ a[i] = i;
+
+ res = foo ();
+
+#if DEBUG
+ fprintf (stderr, "res = %d \n", res);
+#endif
+
+ if (res != 1999)
+ abort ();
+
+ return 0;
+}