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 PR43186, 2nd try


It appears while my earlier fix sped up this testcase somewhat we
can still trigger unreasonable behavior by adjusting it.  Thus
the following limits the loop nest depth we completely unroll
(which is a sensible thing until we properly optimize the unrolled
code as our cost model assumes).  8 sounds like a reasonable
default (and common magic number).

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2010-02-27  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/43186
	* params.def (PARAM_MAX_UNROLL_ITERATIONS): New param.
	* doc/invoke.texi (max-completely-peel-loop-nest-depth): Document.
	* tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely): Limit
	unroller iterations.

	* gcc.c-torture/compile/pr43186.c: Adjust testcase.

Index: gcc/params.def
===================================================================
*** gcc/params.def	(revision 157112)
--- gcc/params.def	(working copy)
*************** DEFPARAM(PARAM_MAX_ONCE_PEELED_INSNS,
*** 266,271 ****
--- 266,276 ----
  	"max-once-peeled-insns",
  	"The maximum number of insns of a peeled loop that rolls only once",
  	400, 0, 0)
+ /* The maximum depth of a loop nest we completely peel.  */
+ DEFPARAM(PARAM_MAX_UNROLL_ITERATIONS,
+ 	 "max-completely-peel-loop-nest-depth",
+ 	 "The maximum depth of a loop nest we completely peel",
+ 	 8, 0, 0)
  
  /* The maximum number of insns of an unswitched loop.  */
  DEFPARAM(PARAM_MAX_UNSWITCH_INSNS,
Index: gcc/doc/invoke.texi
===================================================================
*** gcc/doc/invoke.texi	(revision 157112)
--- gcc/doc/invoke.texi	(working copy)
*************** The maximum number of insns of a complet
*** 8094,8099 ****
--- 8094,8102 ----
  @item max-completely-peel-times
  The maximum number of iterations of a loop to be suitable for complete peeling.
  
+ @item max-completely-peel-loop-nest-depth
+ The maximum depth of a loop nest suitable for complete peeling.
+ 
  @item max-unswitch-insns
  The maximum number of insns of an unswitched loop.
  
Index: gcc/tree-ssa-loop-ivcanon.c
===================================================================
*** gcc/tree-ssa-loop-ivcanon.c	(revision 157112)
--- gcc/tree-ssa-loop-ivcanon.c	(working copy)
*************** tree_unroll_loops_completely (bool may_i
*** 522,527 ****
--- 522,528 ----
    struct loop *loop;
    bool changed;
    enum unroll_level ul;
+   int iteration = 0;
  
    do
      {
*************** tree_unroll_loops_completely (bool may_i
*** 554,560 ****
  	  scev_reset ();
  	}
      }
!   while (changed);
  
    return 0;
  }
--- 555,562 ----
  	  scev_reset ();
  	}
      }
!   while (changed
! 	 && ++iteration <= PARAM_VALUE (PARAM_MAX_UNROLL_ITERATIONS));
  
    return 0;
  }
Index: gcc/testsuite/gcc.c-torture/compile/pr43186.c
===================================================================
--- gcc/testsuite/gcc.c-torture/compile/pr43186.c	(revision 157112)
+++ gcc/testsuite/gcc.c-torture/compile/pr43186.c	(working copy)
@@ -5,7 +5,7 @@ void foo (int i)
   int a, b;
 
   if (!i)
-    for (a = 1; a < 3; a++)
+    for (a = 1; a < 4; a++)
       if (a)
 	for (b = 1; b < 3; b++)
 	  foo (b);


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