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] for optimization/13159


Hello,

there are two problems with the loop optimizer code:

1) Strongly connected components detection in mark_irreducible_loops
   incorrectly handles vertices with outdegree 0.
2) Loop unswitching expects the loop preheaders to have just a single
   successor (the entry of the loop), but does not preserve this
   invariant, thus causing problems when the loop is unswitched more
   than once.

This patch fixes the problems.  Bootstrapped with -funswitch-loops & regtested
on i686.

Zdenek

	* cfgloopanal.c (mark_irreducible_loops): Fix the strongly connected
	components detection.
	* loop-unswitch.c (unswitch_loop): Preserve simple preheaders.

Index: cfgloopanal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloopanal.c,v
retrieving revision 1.16
diff -c -3 -p -r1.16 cfgloopanal.c
*** cfgloopanal.c	11 Dec 2003 00:20:36 -0000	1.16
--- cfgloopanal.c	26 Dec 2003 19:37:57 -0000
*************** mark_irreducible_loops (struct loops *lo
*** 1247,1253 ****
  	           : e->dest->index + 1;
            if (closed[sidx])
  	    {
! 	      if (!closed[mri[sidx]])
  		{
  		  if (mr[sidx] < mr[idx])
  		    {
--- 1247,1253 ----
  	           : e->dest->index + 1;
            if (closed[sidx])
  	    {
! 	      if (mri[sidx] != -1 && !closed[mri[sidx]])
  		{
  		  if (mr[sidx] < mr[idx])
  		    {
Index: loop-unswitch.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-unswitch.c,v
retrieving revision 1.9
diff -c -3 -p -r1.9 loop-unswitch.c
*** loop-unswitch.c	11 Dec 2003 00:20:45 -0000	1.9
--- loop-unswitch.c	26 Dec 2003 19:37:57 -0000
*************** unswitch_loop (struct loops *loops, stru
*** 402,406 ****
--- 402,410 ----
    fix_loop_placement (loop);
    fix_loop_placement (nloop);
  
+   /* Preserve the simple loop preheaders.  */
+   loop_split_edge_with (loop_preheader_edge (loop), NULL_RTX, loops);
+   loop_split_edge_with (loop_preheader_edge (nloop), NULL_RTX, loops);
+ 
    return nloop;
  }


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