2016-01-08 Nathan Sidwell <nathan@acm.org>
gcc/
* omp-low.c (expand_omp_atomic_pipeline): Pay attention to
LOOPS_HAVE_SIMPLE_LATCHES state.
2016-01-12 Nathan Sidwell <nathan@acm.org>
gcc/testsuite/
* gcc.dg/goacc/kern-1.c: New.
===================================================================
@@ -12370,6 +12370,9 @@ expand_omp_atomic_pipeline (basic_block
loop->header = loop_header;
loop->latch = store_bb;
add_loop (loop, loop_header->loop_father);
+ if (loops_state_satisfies_p (LOOPS_HAVE_SIMPLE_LATCHES))
+ /* Split the edge from store_bb to loop_header */
+ split_edge (e);
if (gimple_in_ssa_p (cfun))
update_ssa (TODO_update_ssa_no_phi);
===================================================================
@@ -0,0 +1,23 @@
+/* { dg-additional-options "-fopenacc -O2 -ftree-parallelize-loops=32" } */
+
+/* The reduction on sum could cause an ICE with a non-simple latch loop. */
+
+int printf (char const *, ...);
+
+int
+main ()
+{
+ int i;
+ double a[1000], sum = 0;
+
+
+#pragma acc kernels pcopyin(a[0:1000])
+#pragma acc loop reduction(+:sum)
+ for(int i=0; i<1000; i++) {
+ sum += a[i];
+ }
+
+ printf ("%lf\n", sum);
+
+ return 0;
+}