This is the mail archive of the gcc@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]

[RFC] completely peel loops unconditionally


Hi!

This proof of concept patch enables complete loop peeling unconditionally
(if -floop-optimize is specified, i.e. at -O1).  This is most definitely
always a win (but see below) and there is no way currently to only enable
complete peeling without general peeling.

The question remains, if we should propose different param settings in
this unconditional case (i.e., when -fpeel-loops or -funroll-loops is
not specified), and specifically for -Os.  Looking at params.def I see
no easy way or place to fix the defaults depending on optimization
options.  How would one best do this?

Proof of concept, not bootstrapped, not tested.

Thanks,
Richard.

2004Jun16  Richard Guenther <richard.guenther@uni-tuebingen.de>

	* passes.c (rest_of_handle_loop2): call peel_loops_completely.
	cfgloop.h: export it.
	loop-unroll.c: likewise.
	(unroll_and_peel_loops): don't peel_loops_completely again.

Index: passes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/passes.c,v
retrieving revision 2.19
diff -u -u -r2.19 passes.c
--- passes.c	16 Jun 2004 07:25:52 -0000	2.19
+++ passes.c	16 Jun 2004 10:56:15 -0000
@@ -1400,6 +1400,9 @@
       if (flag_unswitch_loops)
 	unswitch_loops (loops);

+      /* Peeling small loops completely is always a win.  */
+      peel_loops_completely (loops, 0);
+
       if (flag_peel_loops || flag_unroll_loops)
 	unroll_and_peel_loops (loops,
 			       (flag_peel_loops ? UAP_PEEL : 0) |
Index: cfgloop.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloop.h,v
retrieving revision 1.19
diff -u -u -r1.19 cfgloop.h
--- cfgloop.h	3 Jun 2004 15:01:08 -0000	1.19
+++ cfgloop.h	16 Jun 2004 10:56:16 -0000
@@ -426,6 +426,7 @@
 };

 extern void unroll_and_peel_loops (struct loops *, int);
+extern void peel_loops_completely (struct loops *, int);
 extern void doloop_optimize_loops (struct loops *);

 #endif /* GCC_CFGLOOP_H */
Index: loop-unroll.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-unroll.c,v
retrieving revision 1.16
diff -u -u -r1.16 loop-unroll.c
--- loop-unroll.c	24 Feb 2004 23:39:55 -0000	1.16
+++ loop-unroll.c	16 Jun 2004 10:56:16 -0000
@@ -67,7 +67,7 @@
    */

 static void decide_unrolling_and_peeling (struct loops *, int);
-static void peel_loops_completely (struct loops *, int);
+void peel_loops_completely (struct loops *, int);
 static void decide_peel_simple (struct loop *, int);
 static void decide_peel_once_rolling (struct loop *, int);
 static void decide_peel_completely (struct loop *, int);
@@ -87,9 +87,9 @@
   struct loop *loop, *next;
   bool check;

-  /* First perform complete loop peeling (it is almost surely a win,
+  /* Complete loop peeling was performed unconditionally in
+     rest_of_handle_loop2. (it is almost surely a win,
      and affects parameters for further decision a lot).  */
-  peel_loops_completely (loops, flags);

   /* Now decide rest of unrolling and peeling.  */
   decide_unrolling_and_peeling (loops, flags);


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