Hi!

Gimple debug binds (both normal and source) need to have a decl as the first
operand.  The simd clone adjustment code would in some cases transform that
into an ARRAY_REF.  The following patch removes such debug stmts.
In the future we could have a VAR_DECL with DECL_ABSTRACT_ORIGIN pointing to
the PARM_DECL that isn't there and debug stmts for it at the start say
for the array[0], but before that is really worth doing we need to think
what we are going to do with debug info in vectorized loops.

So for now just this patch.  Bootstrapped/regtested on x86_64-linux and
i686-linux, committed to trunk.

2018-11-13  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/87898
        * omp-simd-clone.c (ipa_simd_modify_stmt_ops): Formatting fix.
        (ipa_simd_modify_function_body): Remove debug stmts where the first
        argument was changed into a non-decl.

        * gcc.dg/gomp/pr87898.c: New test.

--- gcc/omp-simd-clone.c.jj     2018-10-31 10:33:08.994660342 +0100
+++ gcc/omp-simd-clone.c        2018-11-13 16:47:35.249022270 +0100
@@ -834,11 +834,8 @@ ipa_simd_modify_stmt_ops (tree *tp, int
   struct ipa_parm_adjustment *cand = NULL;
   if (TREE_CODE (*tp) == PARM_DECL)
     cand = ipa_get_adjustment_candidate (&tp, NULL, info->adjustments, true);
-  else
-    {
-      if (TYPE_P (*tp))
-       *walk_subtrees = 0;
-    }
+  else if (TYPE_P (*tp))
+    *walk_subtrees = 0;
 
   tree repl = NULL_TREE;
   if (cand)
@@ -1014,6 +1011,21 @@ ipa_simd_modify_function_body (struct cg
          if (info.modified)
            {
              update_stmt (stmt);
+             /* If the above changed the var of a debug bind into something
+                different, remove the debug stmt.  We could also for all the
+                replaced parameters add VAR_DECLs for debug info purposes,
+                add debug stmts for those to be the simd array accesses and
+                replace debug stmt var operand with that var.  Debugging of
+                vectorized loops doesn't work too well, so don't bother for
+                now.  */
+             if ((gimple_debug_bind_p (stmt)
+                  && !DECL_P (gimple_debug_bind_get_var (stmt)))
+                 || (gimple_debug_source_bind_p (stmt)
+                     && !DECL_P (gimple_debug_source_bind_get_var (stmt))))
+               {
+                 gsi_remove (&gsi, true);
+                 continue;
+               }
              if (maybe_clean_eh_stmt (stmt))
                gimple_purge_dead_eh_edges (gimple_bb (stmt));
            }
--- gcc/testsuite/gcc.dg/gomp/pr87898.c.jj      2018-11-13 16:49:13.621413907 
+0100
+++ gcc/testsuite/gcc.dg/gomp/pr87898.c 2018-11-13 16:48:33.584068511 +0100
@@ -0,0 +1,10 @@
+/* PR tree-optimization/87898 */
+/* { dg-do compile { target fgraphite } } */
+/* { dg-options "-O1 -floop-parallelize-all -fopenmp 
-ftree-parallelize-loops=2 -g" } */
+
+#pragma omp declare simd
+void
+foo (int x)
+{
+  x = 0;
+}

        Jakub

Reply via email to