This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: unrolling and peeling decisions
> > Hello.
> >
> > > And found interesting thing that we predict it to iterate 5 times, peel it 1
> > > time and don't unroll even with -funroll-all-loops. This is somewhat creazy,
> > > as I would like to see it preconditionoed over iter, unrolled and probably not
> > > peeled.
> > >
> > > About the number of iterations, without profile, I think we can't do much better.
> > > We predict all loops to iterate 5 or 11 times (depending whether they do have
> > > multiple exits or not) and that corresponds to the average number of iterations
> > > as measured by Andrea's tester.
> >
> > Well, the problem is that I (wrongly) compare predicted number of iterations
> > with maximum number of unrollings/peelings, not the actual maximum for given
> > loop; the fix is easy (in unroll-new.c:732 and 818 replace with npeel/nunroll).
> > I can't do it here; if you want to, change it (or I will do it on Tuesday).
>
> I noticed that too. I didn't understand the logic behind the test so I wanted
> to discuss that first. I will commit the change.
Hi,
I've commited the attached patch. It does change the condition and changes peeling
heuristics to require number of iterations to be equal to number of peeling
(so in majority of cases loop won't execute) and in unrolling I've disabled
the check when feedback is not available as it generally does wrong job I believe.
Now I get the mset loop unrolled twice, thats approximately what I wanted to.
(old code did unrolled 4 times, but the loop is large and I guess it does
not matter that much).
Does this look OK for you?
Honza
Sun Mar 31 16:53:58 CEST 2002 Jan Hubicka <jh@suse.cz>
* unroll-new.c (peel_loop): Peel when we can peel more than
expected number of iterations.
(unroll_loop_new): Unroll when expected number of iterations
exceeds number of unrollings.
*** unroll-new.c.old Sun Mar 31 16:45:13 2002
--- unroll-new.c Sun Mar 31 16:52:52 2002
*************** peel_loop (loops, loop, will_unroll)
*** 727,747 ****
return 1;
}
/* Do not peel loops that roll too much. */
niter = expected_loop_iterations (loop);
! if (niter > 2 * PARAM_VALUE (PARAM_MAX_PEEL_TIMES))
{
if (rtl_dump_file)
! fprintf (rtl_dump_file, ";; Not peeling loop, rolls too much (%d iterations > %d [2 * maximum peelings])\n", niter, 2 * PARAM_VALUE (PARAM_MAX_PEEL_TIMES));
return 1;
}
-
- ninsns = num_loop_insns (loop);
-
- npeel = PARAM_VALUE (PARAM_MAX_PEELED_INSNS) / ninsns - 1;
- if (npeel > PARAM_VALUE (PARAM_MAX_PEEL_TIMES))
- npeel = PARAM_VALUE (PARAM_MAX_PEEL_TIMES);
/* Neither big loops. */
if (npeel > 0)
{
--- 727,748 ----
return 1;
}
+ ninsns = num_loop_insns (loop);
+
+ npeel = PARAM_VALUE (PARAM_MAX_PEELED_INSNS) / ninsns - 1;
+ if (npeel > PARAM_VALUE (PARAM_MAX_PEEL_TIMES))
+ npeel = PARAM_VALUE (PARAM_MAX_PEEL_TIMES);
+
/* Do not peel loops that roll too much. */
niter = expected_loop_iterations (loop);
! if (niter> npeel - 1)
{
if (rtl_dump_file)
! fprintf (rtl_dump_file, ";; Not peeling loop, rolls too much (%d iterations > %d [maximum peelings - 1])\n", niter, npeel - 1);
return 1;
}
+ npeel = niter;
/* Neither big loops. */
if (npeel > 0)
{
*************** unroll_loop_new (loops, loop, unroll_all
*** 815,821 ****
{
/* Do not unroll loops that do not roll. */
niter = expected_loop_iterations (loop);
! if (niter < 2 * PARAM_VALUE (PARAM_MAX_UNROLL_TIMES))
{
if (rtl_dump_file)
fprintf (rtl_dump_file, ";; Not unrolling loop, doesn't roll\n");
--- 816,822 ----
{
/* Do not unroll loops that do not roll. */
niter = expected_loop_iterations (loop);
! if (niter < 2 * nunroll && flag_branch_probabilities)
{
if (rtl_dump_file)
fprintf (rtl_dump_file, ";; Not unrolling loop, doesn't roll\n");