diff options
author | Alexey Kravets <kayrick@ispras.ru> | 2011-05-26 15:11:48 +0000 |
---|---|---|
committer | Sebastian Pop <sebastian.pop@amd.com> | 2011-05-26 15:11:48 +0000 |
commit | bcbc6eac9771bfd8a89174333917444eb0ea9c3e (patch) | |
tree | 2ad194cb49a8543b94d58b9a473bdda473d69b49 | |
parent | 32bfae46af376fb1105777dab1309436b076d637 (diff) |
Fix PR49147: ICE with -fgraphite-opencl-ignore-depgraphite
2011-05-26 Alexey Kravets <kayrick@ispras.ru>
PR middle-end/49147
* graphite-opencl-codegen.c
(opencl_get_perfect_nested_loop_depth): Use
enabled_dependency_in_clast_loop_p instead of
dependency_in_clast_loop_p.
* graphite-opencl.c (opencl_transform_stmt_list): Ditto.
(enabled_dependency_in_clast_loop_p): New.
* graphite-opencl.h (enabled_dependency_in_clast_loop_p): Export.
* gcc.dg/graphite/pr49147.c: New test.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/graphite@174293 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog.graphite | 13 | ||||
-rw-r--r-- | gcc/graphite-opencl-codegen.c | 2 | ||||
-rw-r--r-- | gcc/graphite-opencl.c | 19 | ||||
-rw-r--r-- | gcc/graphite-opencl.h | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/graphite/pr49147.c | 46 |
5 files changed, 78 insertions, 4 deletions
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index a4130b964b4..40dc9a606af 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,16 @@ +2011-05-26 Alexey Kravets <kayrick@ispras.ru> + + PR middle-end/49147 + * graphite-opencl-codegen.c + (opencl_get_perfect_nested_loop_depth): Use + enabled_dependency_in_clast_loop_p instead of + dependency_in_clast_loop_p. + * graphite-opencl.c (opencl_transform_stmt_list): Ditto. + (enabled_dependency_in_clast_loop_p): New. + * graphite-opencl.h (enabled_dependency_in_clast_loop_p): Export. + + * gcc.dg/graphite/pr49147.c: New test. + 2011-05-24 Sebastian Pop <sebastian.pop@amd.com> * graphite-opencl-codegen.c (opencl_print_local_vars): Fix typo. diff --git a/gcc/graphite-opencl-codegen.c b/gcc/graphite-opencl-codegen.c index e2eea2e1cbb..450eded42c9 100644 --- a/gcc/graphite-opencl-codegen.c +++ b/gcc/graphite-opencl-codegen.c @@ -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); diff --git a/gcc/graphite-opencl.c b/gcc/graphite-opencl.c index 0d53f66c629..e118d172851 100644 --- a/gcc/graphite-opencl.c +++ b/gcc/graphite-opencl.c @@ -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. */ diff --git a/gcc/graphite-opencl.h b/gcc/graphite-opencl.h index dd047c91a43..1fab5920c93 100644 --- a/gcc/graphite-opencl.h +++ b/gcc/graphite-opencl.h @@ -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); diff --git a/gcc/testsuite/gcc.dg/graphite/pr49147.c b/gcc/testsuite/gcc.dg/graphite/pr49147.c new file mode 100644 index 00000000000..d5f5f3058e7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr49147.c @@ -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; +} |