I've tried to follow where the scalar loop appears in
expand_omp_for_static_nochunk but got lost quickly.  So the following
papers over the lack of OMP expansion populating the loop tree
as I've done in the original patch introducing loops to it.

If the OMP expansion code knows at some point "here is a new loop
and this is the header block and this is the latch block" I can
write a helper that properly updates the loop tree with that
information (call alloc_loop, init ->header and ->latch and
call add_loop).  But at the moment I have no idea where to call
that function ...

Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Richard.

2013-04-29  Richard Biener  <rguent...@suse.de>

        PR middle-end/57089
        * omp-low.c (expand_omp_for_static_nochunk): Mark loops for
        fixup.

        * gfortran.dg/gomp/pr57089.f90: New testcase.

Index: gcc/omp-low.c
===================================================================
*** gcc/omp-low.c       (revision 198389)
--- gcc/omp-low.c       (working copy)
*************** expand_omp_for_static_nochunk (struct om
*** 4370,4375 ****
--- 4370,4380 ----
                           recompute_dominator (CDI_DOMINATORS, body_bb));
    set_immediate_dominator (CDI_DOMINATORS, fin_bb,
                           recompute_dominator (CDI_DOMINATORS, fin_bb));
+ 
+   /* ???  The scalar loop that remains in the body is not registered
+      with the loop tree.  Mark that for fixup.  */
+   if (current_loops)
+     loops_state_set (LOOPS_NEED_FIXUP);
  }
  
  
Index: gcc/testsuite/gfortran.dg/gomp/pr57089.f90
===================================================================
*** gcc/testsuite/gfortran.dg/gomp/pr57089.f90  (revision 0)
--- gcc/testsuite/gfortran.dg/gomp/pr57089.f90  (working copy)
***************
*** 0 ****
--- 1,12 ----
+ ! PR middle-end/57089
+ ! { dg-do compile }
+ ! { dg-options "-O -fopenmp" }
+   SUBROUTINE T()
+     INTEGER            :: npoints, grad_deriv
+     SELECT CASE(grad_deriv)
+     CASE (0)
+        !$omp do
+        DO ii=1,npoints
+        END DO
+     END SELECT
+   END SUBROUTINE 

Reply via email to