diff --git a/gcc/testsuite/c-c++-common/pr118205.c b/gcc/testsuite/c-c++-common/pr118205.c new file mode 100644 index 00000000000..c98f8d84a1b --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr118205.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/118205 */ + +/* { dg-do compile } */ +/* { dg-require-effective-target fgraphite } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O -floop-parallelize-all -ftree-parallelize-loops=2" } */ + +int x; +void g(int); +int f() { + unsigned res = 0; + int arr[] = {}; + int y = 0; + for (unsigned int i = 1; i; i++) + { + for (int n = 0; n < 2; n++) + { + g(arr[i]); + res = y > x ? y : x; + y = res; + } + g(arr[i]); + } + return res; +} diff --git a/gcc/tree-parloops.cc b/gcc/tree-parloops.cc index 8427c287a6a..42183297399 100644 --- a/gcc/tree-parloops.cc +++ b/gcc/tree-parloops.cc @@ -948,7 +948,7 @@ reduction_phi (reduction_info_table_type *reduction_list, gimple *phi) { struct reduction_info tmpred, *red; - if (reduction_list->is_empty () || phi == NULL) + if (reduction_list->is_empty () || phi == NULL || !is_a (phi)) return NULL; if (gimple_uid (phi) == (unsigned int)-1