summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-ivcanon.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-loop-ivcanon.c')
-rw-r--r--gcc/tree-ssa-loop-ivcanon.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index eef613c4a77..1a872a32cc4 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -639,22 +639,24 @@ unloop_loops (bitmap loop_closed_ssa_invalidated,
/* Tries to unroll LOOP completely, i.e. NITER times.
UL determines which loops we are allowed to unroll.
- EXIT is the exit of the loop that should be eliminated.
+ EXIT is the exit of the loop that should be eliminated.
MAXITER specfy bound on number of iterations, -1 if it is
- not known or too large for HOST_WIDE_INT. */
+ not known or too large for HOST_WIDE_INT. The location
+ LOCUS corresponding to the loop is used when emitting
+ a summary of the unroll to the dump file. */
static bool
try_unroll_loop_completely (struct loop *loop,
edge exit, tree niter,
enum unroll_level ul,
- HOST_WIDE_INT maxiter)
+ HOST_WIDE_INT maxiter,
+ location_t locus)
{
unsigned HOST_WIDE_INT n_unroll, ninsns, max_unroll, unr_insns;
gimple cond;
struct loop_size size;
bool n_unroll_found = false;
edge edge_to_cancel = NULL;
- int num = loop->num;
/* See if we proved number of iterations to be low constant.
@@ -862,14 +864,25 @@ try_unroll_loop_completely (struct loop *loop,
loops_to_unloop.safe_push (loop);
loops_to_unloop_nunroll.safe_push (n_unroll);
- if (dump_file && (dump_flags & TDF_DETAILS))
+ if (dump_enabled_p ())
{
if (!n_unroll)
- fprintf (dump_file, "Turned loop %d to non-loop; it never loops.\n",
- num);
+ dump_printf_loc (MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS, locus,
+ "Turned loop into non-loop; it never loops.\n");
else
- fprintf (dump_file, "Unrolled loop %d completely "
- "(duplicated %i times).\n", num, (int)n_unroll);
+ {
+ dump_printf_loc (MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS, locus,
+ "Completely unroll loop %d times", (int)n_unroll);
+ if (profile_info)
+ dump_printf (MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS,
+ " (header execution count %d)",
+ (int)loop->header->count);
+ dump_printf (MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS, "\n");
+ }
+ }
+
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
if (exit)
fprintf (dump_file, "Exit condition of peeled iterations was "
"eliminated.\n");
@@ -898,15 +911,17 @@ canonicalize_loop_induction_variables (struct loop *loop,
tree niter;
HOST_WIDE_INT maxiter;
bool modified = false;
+ location_t locus = UNKNOWN_LOCATION;
niter = number_of_latch_executions (loop);
+ exit = single_exit (loop);
if (TREE_CODE (niter) == INTEGER_CST)
- exit = single_exit (loop);
+ locus = gimple_location (last_stmt (exit->src));
else
{
/* If the loop has more than one exit, try checking all of them
for # of iterations determinable through scev. */
- if (!single_exit (loop))
+ if (!exit)
niter = find_loop_niter (loop, &exit);
/* Finally if everything else fails, try brute force evaluation. */
@@ -915,6 +930,9 @@ canonicalize_loop_induction_variables (struct loop *loop,
|| TREE_CODE (niter) != INTEGER_CST))
niter = find_loop_niter_by_eval (loop, &exit);
+ if (exit)
+ locus = gimple_location (last_stmt (exit->src));
+
if (TREE_CODE (niter) != INTEGER_CST)
exit = NULL;
}
@@ -949,7 +967,7 @@ canonicalize_loop_induction_variables (struct loop *loop,
populates the loop bounds. */
modified |= remove_redundant_iv_tests (loop);
- if (try_unroll_loop_completely (loop, exit, niter, ul, maxiter))
+ if (try_unroll_loop_completely (loop, exit, niter, ul, maxiter, locus))
return true;
if (create_iv