aboutsummaryrefslogtreecommitdiff
path: root/gcc/cfgloop.c
diff options
context:
space:
mode:
authormarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-24 16:22:44 +0000
committermarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-24 16:22:44 +0000
commitfbf561f42d8ee8c1286cd3948d38835fdb77abd1 (patch)
tree58def27bed7c883fb39401708de460fccdea696c /gcc/cfgloop.c
parentb6d48a7882da778bab9b1e72d0eb9f2e290028d8 (diff)
Dump profile-based number of iterations
* analyze_brprob.py: Parse and display average number of loop iterations. * cfgloop.c (flow_loop_dump): Dump average number of loop iterations. * cfgloop.h: Change 'struct loop' to 'const struct loop' for a few functions. * cfgloopanal.c (expected_loop_iterations_unbounded): Set a new argument to true if the expected number of iterations is loop-based. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237762 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfgloop.c')
-rw-r--r--gcc/cfgloop.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 5650f0d92c5..e6174bd2191 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -136,6 +136,14 @@ flow_loop_dump (const struct loop *loop, FILE *file,
loop_depth (loop), (long) (loop_outer (loop)
? loop_outer (loop)->num : -1));
+ if (loop->latch)
+ {
+ bool read_profile_p;
+ gcov_type nit = expected_loop_iterations_unbounded (loop, &read_profile_p);
+ if (read_profile_p && !loop->any_estimate)
+ fprintf (file, ";; profile-based iteration count: %lu\n", nit);
+ }
+
fprintf (file, ";; nodes:");
bbs = get_loop_body (loop);
for (i = 0; i < loop->num_nodes; i++)
@@ -1913,7 +1921,7 @@ get_estimated_loop_iterations (struct loop *loop, widest_int *nit)
false, otherwise returns true. */
bool
-get_max_loop_iterations (struct loop *loop, widest_int *nit)
+get_max_loop_iterations (const struct loop *loop, widest_int *nit)
{
if (!loop->any_upper_bound)
return false;
@@ -1927,7 +1935,7 @@ get_max_loop_iterations (struct loop *loop, widest_int *nit)
on the number of iterations of LOOP could not be derived, returns -1. */
HOST_WIDE_INT
-get_max_loop_iterations_int (struct loop *loop)
+get_max_loop_iterations_int (const struct loop *loop)
{
widest_int nit;
HOST_WIDE_INT hwi_nit;