This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] completely peel loops unconditionally
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 16 Jun 2004 17:03:09 +0200
- Subject: Re: [RFC] completely peel loops unconditionally
- References: <Pine.LNX.4.53.0406161251300.2199@bellatrix.tat.physik.uni-tuebingen.de>
Hello,
> 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.
I believe you would at least need to check whether the loop you unroll
is small enough. But I suggest wait till we merge the lno branch stuff,
since complete unrolling of small loops would more profitably be done
there (in fact it needs just changing a few lines of code there to
achieve it). Provided everything goes well, we should have this in 3.5.
Zdenek
> 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);