This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR40421


This fixes the predcom ICE in 416.gamess - we were not properly
checking whether we can unroll a loop.  Fixed by using the
public helper instead.

Bootstrapped and tested (uh, well - the tree seems to be completely
borked right now...) on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2009-06-13  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/40389
	* tree-predcom.c (should_unroll_loop_p): Remove.
	(tree_predictive_commoning_loop): Use can_unroll_loop_p.

	* gfortran.fortran-torture/compile/pr40421.f: New testcase.

Index: gcc/tree-predcom.c
===================================================================
*** gcc/tree-predcom.c	(revision 148453)
--- gcc/tree-predcom.c	(working copy)
*************** execute_pred_commoning_cbck (struct loop
*** 1870,1912 ****
    execute_pred_commoning (loop, dta->chains, dta->tmp_vars);
  }
  
- /* Returns true if we can and should unroll LOOP FACTOR times.  Number
-    of iterations of the loop is returned in NITER.  */
- 
- static bool
- should_unroll_loop_p (struct loop *loop, unsigned factor,
- 		      struct tree_niter_desc *niter)
- {
-   edge exit;
- 
-   if (factor == 1)
-     return false;
- 
-   /* Check whether unrolling is possible.  We only want to unroll loops
-      for that we are able to determine number of iterations.  We also
-      want to split the extra iterations of the loop from its end,
-      therefore we require that the loop has precisely one
-      exit.  */
- 
-   exit = single_dom_exit (loop);
-   if (!exit)
-     return false;
- 
-   if (!number_of_iterations_exit (loop, exit, niter, false))
-     return false;
- 
-   /* And of course, we must be able to duplicate the loop.  */
-   if (!can_duplicate_loop_p (loop))
-     return false;
- 
-   /* The final loop should be small enough.  */
-   if (tree_num_loop_insns (loop, &eni_size_weights) * factor
-       > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS))
-     return false;
- 
-   return true;
- }
- 
  /* Base NAME and all the names in the chain of phi nodes that use it
     on variable VAR.  The phi nodes are recognized by being in the copies of
     the header of the LOOP.  */
--- 1870,1875 ----
*************** tree_predictive_commoning_loop (struct l
*** 2544,2550 ****
       that its number of iterations is divisible by the factor.  */
    unroll_factor = determine_unroll_factor (chains);
    scev_reset ();
!   unroll = should_unroll_loop_p (loop, unroll_factor, &desc);
    exit = single_dom_exit (loop);
  
    /* Execute the predictive commoning transformations, and possibly unroll the
--- 2507,2514 ----
       that its number of iterations is divisible by the factor.  */
    unroll_factor = determine_unroll_factor (chains);
    scev_reset ();
!   unroll = (unroll_factor > 1
! 	    && can_unroll_loop_p (loop, unroll_factor, &desc));
    exit = single_dom_exit (loop);
  
    /* Execute the predictive commoning transformations, and possibly unroll the
Index: gcc/testsuite/gfortran.fortran-torture/compile/pr40421.f
===================================================================
*** gcc/testsuite/gfortran.fortran-torture/compile/pr40421.f	(revision 0)
--- gcc/testsuite/gfortran.fortran-torture/compile/pr40421.f	(revision 0)
***************
*** 0 ****
--- 1,18 ----
+       SUBROUTINE VROT2(N,DIS)
+       IMPLICIT DOUBLE PRECISION (A-H,O-Z)
+       PARAMETER(ZERO=0.0D+00)
+       COMMON /SYMSPD/ PTR(3,144)
+       DIMENSION DIS(3,2),TMP(3,2)
+       DO I = 1,3
+         TMP1 = ZERO
+         DO J = 1,3
+           TMP1 = TMP1 + PTR(I,N+J)
+         END DO
+         TMP(I,1) = TMP1
+       END DO
+       DO I = 1,3
+         DIS(I,1) = TMP(I,1)
+       END DO
+       RETURN
+       END
+ 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]