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

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
How does this work with OpenMP and compiler/FE generated temporary arrays?
If I just do

!$OMP parallel do
    do i = 1,nsplit
        pi(i) = sum(compute( low(i), high(i) ))
    end do

I still get

  #pragma omp parallel
    {
      {
        #pragma omp for private(i) nowait
        for (i = 1; i <= 4; i = i + 1)
          {
            {
              real(kind=4) val.4;
              integer(kind=8) * D.3617;
              integer(kind=8) * D.3618;
              struct array1_real(kind=4) atmp.5;
              real(kind=4) A.6[4];
...
              atmp.5.data = (void * restrict) &A.6;
              atmp.5.offset = 0;
              compute (&atmp.5, D.3617, D.3618);

and after lower:

      .omp_data_o.17.high = &high;
      .omp_data_o.17.low = &low;
      .omp_data_o.17.pi = &pi;
      #pragma omp parallel shared(pi) shared(low) shared(high) [child fn:
MAIN__._omp_fn.0 (.omp_data_o.17)]
      .omp_data_i = (struct .omp_data_s.16 & restrict) &.omp_data_o.17;
      #pragma omp for private(i) nowait
      for (i = 1; i <= 4; i = i + 1)
      try
        {
          val.4 = 0.0;
          D.3644 = i + -1;
          D.3674 = .omp_data_i->low;
          D.3617 = &*D.3674[D.3644];
          D.3644 = i + -1;
          D.3675 = .omp_data_i->high;
          D.3618 = &*D.3675[D.3644];
          atmp.5.dtype = 281;
          atmp.5.dim[0].stride = 1;
          atmp.5.dim[0].lbound = 0;
          atmp.5.dim[0].ubound = 3;
          atmp.5.data = &A.6;

but somehow OMP expansion duplicated A.6 into the child function.  Does it
simply look at the BLOCK_VARs and duplicates them all, replacing what is
used in the body?  There is separate_decls_in_region that I guess is supposed
to do that for autopar, but it only looks at SSA names.  So it must be really
the OMP (SSA) lowering that was supposed to handle this duplication?  At least
for the OMP example above I don't see anything explicitely marking A.6/atmp
as non-shared.

Reply via email to