re PR middle-end/88588 (ICE in make_decl_rtl, at varasm.c:1329)
authorJakub Jelinek <jakub@gcc.gnu.org>
Wed, 13 Mar 2019 08:24:41 +0000 (09:24 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 13 Mar 2019 08:24:41 +0000 (09:24 +0100)
PR middle-end/88588
* omp-simd-clone.c (ipa_simd_modify_stmt_ops): Handle PHI args.
(ipa_simd_modify_function_body): Handle PHIs.

* c-c++-common/gomp/pr88588.c: New test.

From-SVN: r269636

gcc/ChangeLog
gcc/omp-simd-clone.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/pr88588.c [new file with mode: 0644]

index bb58b304eac3ca74bb79d991d6db6b72f7f64fff..74ed2670675edf2497670edc221f126526d43f39 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/88588
+       * omp-simd-clone.c (ipa_simd_modify_stmt_ops): Handle PHI args.
+       (ipa_simd_modify_function_body): Handle PHIs.
+
 2019-03-12  Robin Dapp  <rdapp@linux.ibm.com>
 
        * config/s390/s390.c (s390_option_override_internal): Use more
index 388198b4dd4b4b743495593cafdb57da7e272b93..472e2025e19b5ccc2837593f23fce190b0da8e72 100644 (file)
@@ -866,6 +866,18 @@ ipa_simd_modify_stmt_ops (tree *tp, int *walk_subtrees, void *data)
 
   if (tp != orig_tp)
     {
+      if (gimple_code (info->stmt) == GIMPLE_PHI
+         && cand
+         && TREE_CODE (*orig_tp) == ADDR_EXPR
+         && TREE_CODE (TREE_OPERAND (*orig_tp, 0)) == PARM_DECL
+         && cand->alias_ptr_type)
+       {
+         gcc_assert (TREE_CODE (cand->alias_ptr_type) == SSA_NAME);
+         *orig_tp = cand->alias_ptr_type;
+         info->modified = true;
+         return NULL_TREE;
+       }
+
       repl = build_fold_addr_expr (repl);
       gimple *stmt;
       if (is_gimple_debug (info->stmt))
@@ -882,7 +894,18 @@ ipa_simd_modify_stmt_ops (tree *tp, int *walk_subtrees, void *data)
          stmt = gimple_build_assign (make_ssa_name (TREE_TYPE (repl)), repl);
          repl = gimple_assign_lhs (stmt);
        }
-      gimple_stmt_iterator gsi = gsi_for_stmt (info->stmt);
+      gimple_stmt_iterator gsi;
+      if (gimple_code (info->stmt) == GIMPLE_PHI)
+       {
+         gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
+         /* Cache SSA_NAME for next time.  */
+         if (cand
+             && TREE_CODE (*orig_tp) == ADDR_EXPR
+             && TREE_CODE (TREE_OPERAND (*orig_tp, 0)) == PARM_DECL)
+           cand->alias_ptr_type = repl;
+       }
+      else
+       gsi = gsi_for_stmt (info->stmt);
       gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
       *orig_tp = repl;
     }
@@ -983,6 +1006,31 @@ ipa_simd_modify_function_body (struct cgraph_node *node,
     {
       gimple_stmt_iterator gsi;
 
+      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+       {
+         gphi *phi = as_a <gphi *> (gsi_stmt (gsi));
+         int i, n = gimple_phi_num_args (phi);
+         info.stmt = phi;
+         struct walk_stmt_info wi;
+         memset (&wi, 0, sizeof (wi));
+         info.modified = false;
+         wi.info = &info;
+         for (i = 0; i < n; ++i)
+           {
+             int walk_subtrees = 1;
+             tree arg = gimple_phi_arg_def (phi, i);
+             tree op = arg;
+             ipa_simd_modify_stmt_ops (&op, &walk_subtrees, &wi);
+             if (op != arg)
+               {
+                 SET_PHI_ARG_DEF (phi, i, op);
+                 gcc_assert (TREE_CODE (op) == SSA_NAME);
+                 if (gimple_phi_arg_edge (phi, i)->flags & EDGE_ABNORMAL)
+                   SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op) = 1;
+               }
+           }
+       }
+
       gsi = gsi_start_bb (bb);
       while (!gsi_end_p (gsi))
        {
index c41914e6f389e01104762b7bde1a82c8e1bc13da..5ba400fa2b3e81c55171b92fb340e0454ac86d68 100644 (file)
@@ -1,4 +1,9 @@
-2019-03-13 Thomas Koenig  <tkoenig@gcc.gnu.org>
+2019-03-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/88588
+       * c-c++-common/gomp/pr88588.c: New test.
+
+2019-03-13  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/66695
        PR fortran/77746
diff --git a/gcc/testsuite/c-c++-common/gomp/pr88588.c b/gcc/testsuite/c-c++-common/gomp/pr88588.c
new file mode 100644 (file)
index 0000000..fb1a671
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR middle-end/88588 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp -O1" } */
+
+int *v;
+
+#pragma omp declare simd
+void
+foo (int x)
+{
+  int *a = &x;
+
+  for (;;)
+    {
+      *v = *a;
+      a = v;
+    }
+}