/* Loop unrolling and peeling.
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GCC.
loop->lpt_decision.decision = LPT_NONE;
- if (rtl_dump_file)
- fprintf (rtl_dump_file, "\n;; *** Considering loop %d for complete peeling ***\n",
+ if (dump_file)
+ fprintf (dump_file,
+ "\n;; *** Considering loop %d for complete peeling ***\n",
loop->num);
loop->ninsns = num_loop_insns (loop);
loop->lpt_decision.decision = LPT_NONE;
- if (rtl_dump_file)
- fprintf (rtl_dump_file, "\n;; *** Considering loop %d ***\n", loop->num);
+ if (dump_file)
+ fprintf (dump_file, "\n;; *** Considering loop %d ***\n", loop->num);
/* Do not peel cold areas. */
if (!maybe_hot_bb_p (loop->header))
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not considering loop, cold area\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not considering loop, cold area\n");
loop = next;
continue;
}
/* Can the loop be manipulated? */
if (!can_duplicate_loop_p (loop))
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file,
+ if (dump_file)
+ fprintf (dump_file,
";; Not considering loop, cannot duplicate\n");
loop = next;
continue;
/* Skip non-innermost loops. */
if (loop->inner)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not considering loop, is not innermost\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not considering loop, is not innermost\n");
loop = next;
continue;
}
{
struct niter_desc *desc;
- if (rtl_dump_file)
- fprintf (rtl_dump_file, "\n;; Considering peeling once rolling loop\n");
+ if (dump_file)
+ fprintf (dump_file, "\n;; Considering peeling once rolling loop\n");
/* Is the loop small enough? */
if ((unsigned) PARAM_VALUE (PARAM_MAX_ONCE_PEELED_INSNS) < loop->ninsns)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not considering loop, is too big\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not considering loop, is too big\n");
return;
}
|| !desc->const_iter
|| desc->niter != 0)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Unable to prove that the loop rolls exactly once\n");
+ if (dump_file)
+ fprintf (dump_file,
+ ";; Unable to prove that the loop rolls exactly once\n");
return;
}
/* Success. */
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Decided to peel exactly once rolling loop\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Decided to peel exactly once rolling loop\n");
loop->lpt_decision.decision = LPT_PEEL_COMPLETELY;
}
unsigned npeel;
struct niter_desc *desc;
- if (rtl_dump_file)
- fprintf (rtl_dump_file, "\n;; Considering peeling completely\n");
+ if (dump_file)
+ fprintf (dump_file, "\n;; Considering peeling completely\n");
/* Skip non-innermost loops. */
if (loop->inner)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not considering loop, is not innermost\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not considering loop, is not innermost\n");
return;
}
/* Do not peel cold areas. */
if (!maybe_hot_bb_p (loop->header))
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not considering loop, cold area\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not considering loop, cold area\n");
return;
}
/* Can the loop be manipulated? */
if (!can_duplicate_loop_p (loop))
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file,
+ if (dump_file)
+ fprintf (dump_file,
";; Not considering loop, cannot duplicate\n");
return;
}
/* Is the loop small enough? */
if (!npeel)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not considering loop, is too big\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not considering loop, is too big\n");
return;
}
|| desc->assumptions
|| !desc->const_iter)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Unable to prove that the loop iterates constant times\n");
+ if (dump_file)
+ fprintf (dump_file,
+ ";; Unable to prove that the loop iterates constant times\n");
return;
}
if (desc->niter > npeel - 1)
{
- if (rtl_dump_file)
+ if (dump_file)
{
- fprintf (rtl_dump_file, ";; Not peeling loop completely, rolls too much (");
- fprintf (rtl_dump_file, HOST_WIDEST_INT_PRINT_DEC, desc->niter);
- fprintf (rtl_dump_file, " iterations > %d [maximum peelings])\n", npeel);
+ fprintf (dump_file,
+ ";; Not peeling loop completely, rolls too much (");
+ fprintf (dump_file, HOST_WIDEST_INT_PRINT_DEC, desc->niter);
+ fprintf (dump_file, " iterations > %d [maximum peelings])\n", npeel);
}
return;
}
/* Success. */
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Decided to peel loop completely\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Decided to peel loop completely\n");
loop->lpt_decision.decision = LPT_PEEL_COMPLETELY;
}
the loop. */
remove_path (loops, ei);
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Peeled loop completely, %d times\n", (int) npeel);
+ if (dump_file)
+ fprintf (dump_file, ";; Peeled loop completely, %d times\n", (int) npeel);
}
-/* Decide whether to unroll LOOP iterating constant number of times and how much. */
+/* Decide whether to unroll LOOP iterating constant number of times
+ and how much. */
static void
decide_unroll_constant_iterations (struct loop *loop, int flags)
return;
}
- if (rtl_dump_file)
- fprintf (rtl_dump_file,
- "\n;; Considering unrolling loop with constant number of iterations\n");
+ if (dump_file)
+ fprintf (dump_file,
+ "\n;; Considering unrolling loop with constant "
+ "number of iterations\n");
/* nunroll = total number of copies of the original loop body in
unrolled loop (i.e. if it is 2, we have to duplicate loop body once. */
nunroll = PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS) / loop->ninsns;
- nunroll_by_av = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLED_INSNS) / loop->av_ninsns;
+ nunroll_by_av
+ = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLED_INSNS) / loop->av_ninsns;
if (nunroll > nunroll_by_av)
nunroll = nunroll_by_av;
if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLL_TIMES))
/* Skip big loops. */
if (nunroll <= 1)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not considering loop, is too big\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not considering loop, is too big\n");
return;
}
/* Check number of iterations. */
if (!desc->simple_p || !desc->const_iter || desc->assumptions)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Unable to prove that the loop iterates constant times\n");
+ if (dump_file)
+ fprintf (dump_file,
+ ";; Unable to prove that the loop iterates constant times\n");
return;
}
/* Check whether the loop rolls enough to consider. */
if (desc->niter < 2 * nunroll)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not unrolling loop, doesn't roll\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not unrolling loop, doesn't roll\n");
return;
}
}
}
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; max_unroll %d (%d copies, initial %d).\n",
+ if (dump_file)
+ fprintf (dump_file, ";; max_unroll %d (%d copies, initial %d).\n",
best_unroll + 1, best_copies, nunroll);
loop->lpt_decision.decision = LPT_UNROLL_CONSTANT;
loop->lpt_decision.times = best_unroll;
- if (rtl_dump_file)
- fprintf (rtl_dump_file,
+ if (dump_file)
+ fprintf (dump_file,
";; Decided to unroll the constant times rolling loop, %d times.\n",
loop->lpt_decision.times);
}
in the first copy, so that the loops that start with test
of exit condition have continuous body after unrolling. */
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Condition on beginning of loop.\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Condition on beginning of loop.\n");
/* Peel exit_mod iterations. */
RESET_BIT (wont_exit, 0);
/* Leave exit test in last copy, for the same reason as above if
the loop tests the condition at the end of loop body. */
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Condition on end of loop.\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Condition on end of loop.\n");
/* We know that niter >= max_unroll + 2; so we do not need to care of
case when we would exit before reaching the loop. So just peel
remove_path (loops, remove_edges[i]);
free (remove_edges);
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Unrolled loop %d times, constant # of iterations %i insns\n",max_unroll, num_loop_insns (loop));
+ if (dump_file)
+ fprintf (dump_file,
+ ";; Unrolled loop %d times, constant # of iterations %i insns\n",
+ max_unroll, num_loop_insns (loop));
}
/* Decide whether to unroll LOOP iterating runtime computable number of times
return;
}
- if (rtl_dump_file)
- fprintf (rtl_dump_file,
- "\n;; Considering unrolling loop with runtime computable number of iterations\n");
+ if (dump_file)
+ fprintf (dump_file,
+ "\n;; Considering unrolling loop with runtime "
+ "computable number of iterations\n");
/* nunroll = total number of copies of the original loop body in
unrolled loop (i.e. if it is 2, we have to duplicate loop body once. */
/* Skip big loops. */
if (nunroll <= 1)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not considering loop, is too big\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not considering loop, is too big\n");
return;
}
/* Check simpleness. */
if (!desc->simple_p || desc->assumptions)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file,
- ";; Unable to prove that the number of iterations can be counted in runtime\n");
+ if (dump_file)
+ fprintf (dump_file,
+ ";; Unable to prove that the number of iterations "
+ "can be counted in runtime\n");
return;
}
if (desc->const_iter)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Loop iterates constant times\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Loop iterates constant times\n");
return;
}
/* If we have profile feedback, check whether the loop rolls. */
if (loop->header->count && expected_loop_iterations (loop) < 2 * nunroll)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not unrolling loop, doesn't roll\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not unrolling loop, doesn't roll\n");
return;
}
loop->lpt_decision.decision = LPT_UNROLL_RUNTIME;
loop->lpt_decision.times = i - 1;
- if (rtl_dump_file)
- fprintf (rtl_dump_file,
- ";; Decided to unroll the runtime computable times rolling loop, %d times.\n",
+ if (dump_file)
+ fprintf (dump_file,
+ ";; Decided to unroll the runtime computable "
+ "times rolling loop, %d times.\n",
loop->lpt_decision.times);
}
desc->niter_max--;
}
- if (rtl_dump_file)
- fprintf (rtl_dump_file,
- ";; Unrolled loop %d times, counting # of iterations in runtime, %i insns\n",
+ if (dump_file)
+ fprintf (dump_file,
+ ";; Unrolled loop %d times, counting # of iterations "
+ "in runtime, %i insns\n",
max_unroll, num_loop_insns (loop));
}
return;
}
- if (rtl_dump_file)
- fprintf (rtl_dump_file, "\n;; Considering simply peeling loop\n");
+ if (dump_file)
+ fprintf (dump_file, "\n;; Considering simply peeling loop\n");
/* npeel = number of iterations to peel. */
npeel = PARAM_VALUE (PARAM_MAX_PEELED_INSNS) / loop->ninsns;
/* Skip big loops. */
if (!npeel)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not considering loop, is too big\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not considering loop, is too big\n");
return;
}
/* Check number of iterations. */
if (desc->simple_p && !desc->assumptions && desc->const_iter)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Loop iterates constant times\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Loop iterates constant times\n");
return;
}
of mispredicts. */
if (num_loop_branches (loop) > 1)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not peeling, contains branches\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not peeling, contains branches\n");
return;
}
unsigned niter = expected_loop_iterations (loop);
if (niter + 1 > npeel)
{
- if (rtl_dump_file)
+ if (dump_file)
{
- fprintf (rtl_dump_file, ";; Not peeling loop, rolls too much (");
- fprintf (rtl_dump_file, HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT) (niter + 1));
- fprintf (rtl_dump_file, " iterations > %d [maximum peelings])\n", npeel);
+ fprintf (dump_file, ";; Not peeling loop, rolls too much (");
+ fprintf (dump_file, HOST_WIDEST_INT_PRINT_DEC,
+ (HOST_WIDEST_INT) (niter + 1));
+ fprintf (dump_file, " iterations > %d [maximum peelings])\n",
+ npeel);
}
return;
}
{
/* For now we have no good heuristics to decide whether loop peeling
will be effective, so disable it. */
- if (rtl_dump_file)
- fprintf (rtl_dump_file,
+ if (dump_file)
+ fprintf (dump_file,
";; Not peeling loop, no evidence it will be profitable\n");
return;
}
loop->lpt_decision.decision = LPT_PEEL_SIMPLE;
loop->lpt_decision.times = npeel;
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Decided to simply peel the loop, %d times.\n",
+ if (dump_file)
+ fprintf (dump_file, ";; Decided to simply peel the loop, %d times.\n",
loop->lpt_decision.times);
}
free_simple_loop_desc (loop);
}
}
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Peeling loop %d times\n", npeel);
+ if (dump_file)
+ fprintf (dump_file, ";; Peeling loop %d times\n", npeel);
}
/* Decide whether to unroll LOOP stupidly and how much. */
return;
}
- if (rtl_dump_file)
- fprintf (rtl_dump_file, "\n;; Considering unrolling loop stupidly\n");
+ if (dump_file)
+ fprintf (dump_file, "\n;; Considering unrolling loop stupidly\n");
/* nunroll = total number of copies of the original loop body in
unrolled loop (i.e. if it is 2, we have to duplicate loop body once. */
nunroll = PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS) / loop->ninsns;
- nunroll_by_av = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLED_INSNS) / loop->av_ninsns;
+ nunroll_by_av
+ = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLED_INSNS) / loop->av_ninsns;
if (nunroll > nunroll_by_av)
nunroll = nunroll_by_av;
if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLL_TIMES))
/* Skip big loops. */
if (nunroll <= 1)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not considering loop, is too big\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not considering loop, is too big\n");
return;
}
/* Check simpleness. */
if (desc->simple_p && !desc->assumptions)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; The loop is simple\n");
+ if (dump_file)
+ fprintf (dump_file, ";; The loop is simple\n");
return;
}
of mispredicts. */
if (num_loop_branches (loop) > 1)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not unrolling, contains branches\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not unrolling, contains branches\n");
return;
}
if (loop->header->count
&& expected_loop_iterations (loop) < 2 * nunroll)
{
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Not unrolling loop, doesn't roll\n");
+ if (dump_file)
+ fprintf (dump_file, ";; Not unrolling loop, doesn't roll\n");
return;
}
loop->lpt_decision.decision = LPT_UNROLL_STUPID;
loop->lpt_decision.times = i - 1;
- if (rtl_dump_file)
- fprintf (rtl_dump_file,
+ if (dump_file)
+ fprintf (dump_file,
";; Decided to unroll the loop stupidly, %d times.\n",
loop->lpt_decision.times);
}
desc->simple_p = false;
}
- if (rtl_dump_file)
- fprintf (rtl_dump_file, ";; Unrolled loop %d times, %i insns\n",
+ if (dump_file)
+ fprintf (dump_file, ";; Unrolled loop %d times, %i insns\n",
nunroll, num_loop_insns (loop));
}