https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68977

vries at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at gcc dot gnu.org

--- Comment #2 from vries at gcc dot gnu.org ---
minimal version:
...
int
main ()
{
  int i, j;

#pragma acc parallel
  {
#pragma acc loop gang
    for (i = 0; i < 10; i++)
      {
#pragma acc loop gang
        for (j = 1; j < 10; j++)
          { }
      }

#pragma acc loop gang worker
    for (i = 0; i < 10; i++)
      { }
  }

  return 0;
}
...

The problem is that we have stmt:
...
  .step.4_68 = _85;
...
And the defining stmt of _85 is NULL.

Before oaccdevlow, the assignment loops like:
...
  .step.4_68 = GOACC_LOOP (1, 1, 10, 1, -1, 0);
...

During oaccdevlow we translate the GOACC_LOOP, and we try to gimplify an
assign:
...
19254     gimplify_assign (lhs, r, &seq);
(gdb) call debug_generic_expr (lhs)
.step.4_68
(gdb) call debug_generic_expr (r)
(D.1697 * D.1698) * 1
(gdb) call debug_gimple_seq (seq)
D.1697 = GOACC_DIM_SIZE (0);
D.1698 = GOACC_DIM_SIZE (1);
...

But during gimplification, we run into:
...
    case INIT_EXPR:
      ...
      if (seen_error ())
        return GS_ERROR;
...
And we're left with the uninitialized ssa name.

An easy fix seems to be:
...
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 185426f..c1aeddd 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -19128,7 +19128,7 @@ oacc_xform_loop (gcall *call)
        -> chunks=ceil (range/(chunksize*threads*step))
      striding=false,chunking=false
        -> chunk_size=ceil(range/(threads*step)),chunks=1  */
-  push_gimplify_context (true);
+  push_gimplify_context (false);

   switch (code)
     {
...

It means we're left with an uninitialized var, but ssa updating rewrites that
into a default def, so we have valid ssa.

We could also adopt the omp_lower strategy:
...
  /* If we have issued syntax errors, avoid doing any heavy
     lifting.
     Just replace the OMP directives with a NOP to avoid
     confusing RTL expansion.  */
  if (seen_error () && is_gimple_omp (stmt))
    {
      gsi_replace (gsi_p, gimple_build_nop (), true);
      return;
    }
...

Reply via email to