re PR tree-optimization/81578 (ICE in omp_reduction_init_op)
authorJakub Jelinek <jakub@redhat.com>
Fri, 28 Jul 2017 07:11:51 +0000 (09:11 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 28 Jul 2017 07:11:51 +0000 (09:11 +0200)
PR tree-optimization/81578
* tree-parloops.c (build_new_reduction): Bail out if
reduction_code isn't one of the standard OpenMP reductions.
Move the details printing after that decision.

* gcc.dg/pr81578.c: New test.

From-SVN: r250651

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

index be98abe05157f12349af7f4c4d69c4ae01129160..b2aec1afa54f3d45ff42d15de4c991fa64992c46 100644 (file)
@@ -1,3 +1,10 @@
+2017-07-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/81578
+       * tree-parloops.c (build_new_reduction): Bail out if
+       reduction_code isn't one of the standard OpenMP reductions.
+       Move the details printing after that decision.
+
 2017-07-27  Peter Bergner  <bergner@vnet.ibm.com>
 
        * config/rs6000/predicates.md (volatile_mem_operand): Remove code
index 0fa0da85deba0281c17bae1d2f4b2b8827425189..19f10701053bbbfa7b981770fcf9a6ea8708fc3e 100644 (file)
@@ -1,3 +1,8 @@
+2017-07-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/81578
+       * gcc.dg/pr81578.c: New test.
+
 2017-07-28  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/81573
diff --git a/gcc/testsuite/gcc.dg/pr81578.c b/gcc/testsuite/gcc.dg/pr81578.c
new file mode 100644 (file)
index 0000000..a6ef77f
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR tree-optimization/81578 */
+/* { dg-do compile { target pthread } } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2" } */
+
+int
+foo (int *x)
+{
+  int i, r = 1;
+  for (i = 0; i != 1024; i++)
+    r *= x[i] < 0;
+  return r;
+}
index 470964bebf79b895d3e51cf235234e736f8a1c83..538932e50bfb8e9761fd6551483f620dcac2cb76 100644 (file)
@@ -2475,23 +2475,39 @@ build_new_reduction (reduction_info_table_type *reduction_list,
 
   gcc_assert (reduc_stmt);
 
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    {
-      fprintf (dump_file,
-              "Detected reduction. reduction stmt is:\n");
-      print_gimple_stmt (dump_file, reduc_stmt, 0);
-      fprintf (dump_file, "\n");
-    }
-
   if (gimple_code (reduc_stmt) == GIMPLE_PHI)
     {
       tree op1 = PHI_ARG_DEF (reduc_stmt, 0);
       gimple *def1 = SSA_NAME_DEF_STMT (op1);
       reduction_code = gimple_assign_rhs_code (def1);
     }
-
   else
     reduction_code = gimple_assign_rhs_code (reduc_stmt);
+  /* Check for OpenMP supported reduction.  */
+  switch (reduction_code)
+    {
+    case PLUS_EXPR:
+    case MULT_EXPR:
+    case MAX_EXPR:
+    case MIN_EXPR:
+    case BIT_IOR_EXPR:
+    case BIT_XOR_EXPR:
+    case BIT_AND_EXPR:
+    case TRUTH_OR_EXPR:
+    case TRUTH_XOR_EXPR:
+    case TRUTH_AND_EXPR:
+      break;
+    default:
+      return;
+    }
+
+  if (dump_file && (dump_flags & TDF_DETAILS))
+    {
+      fprintf (dump_file,
+              "Detected reduction. reduction stmt is:\n");
+      print_gimple_stmt (dump_file, reduc_stmt, 0);
+      fprintf (dump_file, "\n");
+    }
 
   new_reduction = XCNEW (struct reduction_info);