gcc/ChangeLog: * tree-ssa-loop-ivcanon.c: Include "optinfo.h". (try_unroll_loop_completely): Port to optinfo. (canonicalize_loop_induction_variables): Use OPTINFO_NOTE. * tree-ssa-loop-niter.c: Include "optinfo.h". (number_of_iterations_exit): Port to OPTINFO_FAILURE. --- gcc/tree-ssa-loop-ivcanon.c | 38 ++++++++++++++++++++++++++++---------- gcc/tree-ssa-loop-niter.c | 7 ++++--- 2 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index 24bf60e..0ab9d61 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -63,6 +63,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-inline.h" #include "tree-cfgcleanup.h" #include "builtins.h" +#include "optinfo.h" /* Specifies types of loops that may be unrolled. */ @@ -936,21 +937,19 @@ try_unroll_loop_completely (struct loop *loop, loops_to_unloop.safe_push (loop); loops_to_unloop_nunroll.safe_push (n_unroll); - if (dump_enabled_p ()) + if (optinfo_enabled_p ()) { if (!n_unroll) - dump_printf_loc (MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS, locus, - "loop turned into non-loop; it never loops\n"); + OPTINFO_SUCCESS_DETAILS (loop) + << "loop turned into non-loop; it never loops"; else { - dump_printf_loc (MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS, locus, - "loop with %d iterations completely unrolled", - (int) n_unroll); + pending_optinfo info = OPTINFO_SUCCESS_DETAILS (loop) + << optinfo_printf ("loop with %d iterations completely unrolled", + (int) n_unroll); if (loop->header->count.initialized_p ()) - dump_printf (MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS, - " (header execution count %d)", - (int)loop->header->count.to_gcov_type ()); - dump_printf (MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS, "\n"); + info << optinfo_printf (" (header execution count %d)", + (int)loop->header->count.to_gcov_type ()); } } @@ -1240,6 +1239,25 @@ canonicalize_loop_induction_variables (struct loop *loop, fprintf (dump_file, "Loop %d likely iterates at most %i times.\n", loop->num, (int)likely_max_loop_iterations_int (loop)); } + /* FIXME: this duplicates the above usage of "dump_file". */ + if (optinfo_enabled_p ()) + { + if (TREE_CODE (niter) == INTEGER_CST) + OPTINFO_NOTE (loop) + << optinfo_printf ("loop %d iterates ", loop->num) + << slim (niter) + << " times"; + else if (maxiter >= 0) + OPTINFO_NOTE (loop) + << optinfo_printf ("loop %d iterates at most %i times", + loop->num, + (int)maxiter); + else if (likely_max_loop_iterations_int (loop) >= 0) + OPTINFO_NOTE (loop) + << optinfo_printf ("loop %d likely iterates at most %i times", + loop->num, + (int)likely_max_loop_iterations_int (loop)); + } /* Remove exits that are known to be never taken based on loop bound. Needs to be called after compilation of max_loop_iterations_int that diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 7a54c5f..8eee6de 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-scalar-evolution.h" #include "params.h" #include "tree-dfa.h" +#include "optinfo.h" /* The maximum number of dominator BBs we search for conditions @@ -2447,9 +2448,9 @@ number_of_iterations_exit (struct loop *loop, edge exit, return true; if (warn) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, gimple_location_safe (stmt), - "missed loop optimization: niters analysis ends up " - "with assumptions.\n"); + OPTINFO_FAILURE (stmt) + << ("missed loop optimization: niters analysis ends up " + "with assumptions"); return false; } -- 1.8.5.3