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, commited] PR 32220


Hello,

eliminate_temp_copies replaces the base variables of the chains of SSA
names generated in unrolling by the same variable (so that out-of-ssa
has chance to generate code without moving the values of the variables
in the loop latch).  If the loop is unrolled enough, the defining
statement is reached in the chain before loop header.  However, if the
bounds on the code growth prevent us from unrolling the loop fully,
some moves of the variable values are necessary; in that case, we will
have chains of ssa names that only copy the value of the variable across
the iteration of the loop.  At the moment, eliminate_temp_copies ICEs
in this case.

Fixed by stopping the traversal of the phi nodes when a loop phi node
is reached.  Bootstrapped & regtested on i686 and ppc-linux, commited.

Zdenek

	PR tree-optimization/32220
	* tree-predcom.c (eliminate_temp_copies): Handle the case that loop
	phi node is reached before defining statement.

	* gfortran.dg/predcom-2.f: New testcase.

Index: testsuite/gfortran.dg/predcom-2.f
===================================================================
*** testsuite/gfortran.dg/predcom-2.f	(revision 0)
--- testsuite/gfortran.dg/predcom-2.f	(revision 0)
***************
*** 0 ****
--- 1,20 ----
+ ! PR 32220, ICE when the loop is not unrolled enough to eliminate all 
+ !   register copies
+ ! { dg-do compile }
+ ! { dg-options "-O3" }
+ 
+       subroutine derv (b,cosxy,thick)
+ c
+       common /shell4/xji(3,3)
+ c
+       dimension cosxy(6,*),
+      1          thick(*),b(*)
+ c
+ 
+       do 125 i=1,3
+       b(k2+i)=xji(i,1) + xji(i,2) + xji(i,3)
+   125 b(k3+i)=cosxy(i+3,kk) + cosxy(i,kk)
+ c
+ c
+       return
+       end
Index: tree-predcom.c
===================================================================
*** tree-predcom.c	(revision 125499)
--- tree-predcom.c	(working copy)
*************** eliminate_temp_copies (struct loop *loop
*** 1932,1938 ****
  
        /* Base all the ssa names in the ud and du chain of NAME on VAR.  */
        stmt = SSA_NAME_DEF_STMT (use);
!       while (TREE_CODE (stmt) == PHI_NODE)
  	{
  	  gcc_assert (single_pred_p (bb_for_stmt (stmt)));
  	  use = PHI_ARG_DEF (stmt, 0);
--- 1932,1944 ----
  
        /* Base all the ssa names in the ud and du chain of NAME on VAR.  */
        stmt = SSA_NAME_DEF_STMT (use);
!       while (TREE_CODE (stmt) == PHI_NODE
! 	     /* In case we could not unroll the loop enough to eliminate
! 		all copies, we may reach the loop header before the defining
! 		statement (in that case, some register copies will be present
! 		in loop latch in the final code, corresponding to the newly
! 		created looparound phi nodes).  */
! 	     && bb_for_stmt (stmt) != loop->header)
  	{
  	  gcc_assert (single_pred_p (bb_for_stmt (stmt)));
  	  use = PHI_ARG_DEF (stmt, 0);


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