[PATCH] Fix PR36078, fallout from early loop unrolling

Richard Guenther rguenther@suse.de
Tue Apr 29 13:49:00 GMT 2008


This patch adds a missing SSA update after early complete loop unrolling.
Appearantly this is only needed if unrolling doesn't operate on
loop-closed SSA form, but it might also paper over a problem with not
doing so.

So, Zdenek - does this make sense or should we switch back to going
into loop-closed SSA form for unrolling?

Boostrap / regtest on x86_64-unknown-linux-gnu running.

Thanks,
Richard.

2008-04-29  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/36078
	* tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely):
	If we are not in loop-closed SSA form finalize the pass with	
	an SSA update.

	* gfortran.fortran-torture/compile/pr36078.f90: New testcase.

Index: tree-ssa-loop-ivcanon.c
===================================================================
*** tree-ssa-loop-ivcanon.c	(revision 134750)
--- tree-ssa-loop-ivcanon.c	(working copy)
*************** tree_unroll_loops_completely (bool may_i
*** 340,346 ****
  {
    loop_iterator li;
    struct loop *loop;
!   bool changed;
    enum unroll_level ul;
  
    do
--- 340,346 ----
  {
    loop_iterator li;
    struct loop *loop;
!   bool changed, ever_changed = false;
    enum unroll_level ul;
  
    do
*************** tree_unroll_loops_completely (bool may_i
*** 372,380 ****
--- 372,386 ----
  	     complete unrolling might have invalidated it.  */
  	  scev_reset ();
  	}
+ 
+       ever_changed |= changed;
      }
    while (changed);
  
+   if (ever_changed
+       && !loops_state_satisfies_p (LOOP_CLOSED_SSA))
+     return TODO_update_ssa;
+ 
    return 0;
  }
  
Index: testsuite/gfortran.fortran-torture/compile/pr36078.f90
===================================================================
*** testsuite/gfortran.fortran-torture/compile/pr36078.f90	(revision 0)
--- testsuite/gfortran.fortran-torture/compile/pr36078.f90	(revision 0)
***************
*** 0 ****
--- 1,22 ----
+    subroutine foo(func,p,eval)
+       real(kind=kind(1.0d0)), dimension(3,0:4,0:4,0:4) :: p
+       logical(kind=kind(.true.)), dimension(5,5,5) :: eval
+       interface
+          subroutine func(values,pt)
+             real(kind=kind(1.0d0)), dimension(:), intent(out) :: values
+             real(kind=kind(1.0d0)), dimension(:,:), intent(in) :: pt
+          end subroutine
+       end interface
+       real(kind=kind(1.0d0)), dimension(125,3) :: pt
+       integer(kind=kind(1)) :: n_pt
+ 
+       n_pt = 1
+       pt(1:n_pt,:) = &
+          reshape( &
+             pack( &
+                transpose(reshape(p,(/3,125/))), &
+                spread(reshape(eval,(/125/)),dim=2,ncopies=3)), &
+             (/n_pt,3/))
+ 
+    end subroutine
+    end 



More information about the Gcc-patches mailing list