This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix parloops ICE (PR tree-optimization/81578)


On July 27, 2017 9:10:48 PM GMT+02:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>Not all vectorizable reductions are valid OpenMP standard reductions
>(we could create user defined reductions from that, but that would be
>quite a lot of work).
>
>This patch bails out for unsupported reductions.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Thanks,
Richard.

>2017-07-27  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.
>
>	* gcc.dg/pr81578.c: New test.
>
>--- gcc/tree-parloops.c.jj	2017-07-19 14:01:24.000000000 +0200
>+++ gcc/tree-parloops.c	2017-07-27 14:27:13.966749227 +0200
>@@ -2475,23 +2475,39 @@ build_new_reduction (reduction_info_tabl
> 
>   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);
> 
>--- gcc/testsuite/gcc.dg/pr81578.c.jj	2017-07-27 14:48:16.426441581
>+0200
>+++ gcc/testsuite/gcc.dg/pr81578.c	2017-07-27 14:48:01.000000000 +0200
>@@ -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;
>+}
>
>	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]