]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/88588 (ICE in make_decl_rtl, at varasm.c:1329)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 12:17:22 +0000 (14:17 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 12:17:22 +0000 (14:17 +0200)
Backported from mainline
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.

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

From-SVN: r275129

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

index 52c1cf41637a2f28f9ddf0ae2f507f6b86b139e2..a60a54e8ffc60d9986a503775f97fd83b123ee0a 100644 (file)
@@ -1,6 +1,12 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       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  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/89663
index 7815ce929ae511e5b7d7467053e54f7e98140a84..ef3e28bdcb532874ba728667be2fb9d14b843f68 100644 (file)
@@ -865,6 +865,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))
@@ -881,7 +893,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;
     }
@@ -982,6 +1005,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 4966eb9b5a7468c0eb026ac7d19455db51f45775..0c14e5d26dfbc7eb0e4419ecab7e071151eb55e7 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-03-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/88588
+       * c-c++-common/gomp/pr88588.c: New test.
+
        2019-03-12  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/89663
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;
+    }
+}