re PR tree-optimization/36181 (Simple for loop generates ICE with -ftree-parallelize...
authorSebastian Pop <spop@gcc.gnu.org>
Tue, 20 May 2008 19:17:12 +0000 (19:17 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Tue, 20 May 2008 19:17:12 +0000 (19:17 +0000)
2008-05-20  Sebastian Pop  <sebastian.pop@amd.com>
    Jan Sjodin  <jan.sjodin@amd.com>

PR tree-optimization/36181
* tree-parloops.c (loop_has_vector_phi_nodes): New.
(parallelize_loops): Don't parallelize when the loop has vector
phi nodes.

* gcc.dg/tree-ssa/pr36181.c: New.

From-SVN: r135673

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr36181.c [new file with mode: 0644]
gcc/tree-parloops.c

index ba15ab570147298a97e70e5d1b5f5bb3d8b5de6f..65cb134a4616ff20b88d5fb45e6e3d3c2336b538 100644 (file)
@@ -1,3 +1,11 @@
+2008-05-20  Sebastian Pop  <sebastian.pop@amd.com>
+           Jan Sjodin  <jan.sjodin@amd.com>
+
+       PR tree-optimization/36181
+       * tree-parloops.c (loop_has_vector_phi_nodes): New.
+       (parallelize_loops): Don't parallelize when the loop has vector
+       phi nodes.
+
 2008-05-20  Jan Sjodin  <jan.sjodin@amd.com>
            Sebastian Pop  <sebastian.pop@amd.com>
 
index fae968728a57a173ce0729e79faaaf475312f63f..0ff1a091d549695b991f00411d18ac610c01bb03 100644 (file)
@@ -1,3 +1,9 @@
+2008-05-20  Jan Sjodin  <jan.sjodin@amd.com>
+           Sebastian Pop  <sebastian.pop@amd.com>
+
+       PR tree-optimization/36181
+       * gcc.dg/tree-ssa/pr36181.c: New.
+
 2008-05-20  Uros Bizjak  <ubizjak@gmail.com>
 
        PR testsuite/36057
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr36181.c b/gcc/testsuite/gcc.dg/tree-ssa/pr36181.c
new file mode 100644 (file)
index 0000000..6eda0a4
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -ftree-parallelize-loops=2" } */
+
+int foo ()
+{
+  int i, sum = 0, data[1024];
+
+  for(i = 0; i<1024; i++)
+    sum += data[i];
+
+  return sum;
+}
+
index de4f3065a52490a9bca4ec79ff5cb1ccf9e2377e..109e3058921b190abdee620ee76f9ab0e6ab1973 100644 (file)
@@ -1797,6 +1797,27 @@ gen_parallel_loop (struct loop *loop, htab_t reduction_list,
   omp_expand_local (parallel_head);
 }
 
+/* Returns true when LOOP contains vector phi nodes.  */
+
+static bool
+loop_has_vector_phi_nodes (struct loop *loop)
+{
+  unsigned i;
+  basic_block *bbs = get_loop_body_in_dom_order (loop);
+  bool res = true;
+  tree phi;
+
+  for (i = 0; i < loop->num_nodes; i++)
+    for (phi = phi_nodes (bbs[i]); phi; phi = PHI_CHAIN (phi))
+      if (TREE_CODE (TREE_TYPE (PHI_RESULT (phi))) == VECTOR_TYPE)
+       goto end;
+
+  res = false;
+ end:
+  free (bbs);
+  return res;
+}
+
 /* Detect parallel loops and generate parallel code using libgomp
    primitives.  Returns true if some loop was parallelized, false
    otherwise.  */
@@ -1828,6 +1849,8 @@ parallelize_loops (void)
          /* And of course, the loop must be parallelizable.  */
          || !can_duplicate_loop_p (loop)
          || loop_has_blocks_with_irreducible_flag (loop)
+         /* FIXME: the check for vector phi nodes could be removed.  */
+         || loop_has_vector_phi_nodes (loop)
          || !loop_parallel_p (loop, reduction_list, &niter_desc))
        continue;