From 604637de550a9d23b8a509cdbf493a7212a186f0 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Tue, 21 Jun 2016 14:52:31 +0200
Subject: [PATCH] Introduce new param: AVG_LOOP_NITER
gcc/ChangeLog:
2016-06-21 Martin Liska <mliska@suse.cz>
* params.def: Add avg-loop niter.
* tree-ssa-loop-ivopts.c (avg_loop_niter): Use the param.
* cfgloopanal.c (expected_loop_iterations_unbounded): Likewise.
---
gcc/cfgloopanal.c | 9 ++++-----
gcc/params.def | 5 +++++
gcc/tree-ssa-loop-ivopts.c | 7 +++----
3 files changed, 12 insertions(+), 9 deletions(-)
@@ -241,10 +241,9 @@ expected_loop_iterations_unbounded (const struct loop *loop,
if (read_profile_p)
*read_profile_p = false;
- /* Average loop rolls about 3 times. If we have no profile at all, it is
- best we can do. */
+ /* If we have no profile at all, use AVG_LOOP_NITER. */
if (profile_status_for_fn (cfun) == PROFILE_ABSENT)
- expected = 3;
+ expected = PARAM_VALUE (PARAM_AVG_LOOP_NITER);
else if (loop->latch->count || loop->header->count)
{
gcov_type count_in, count_latch;
@@ -282,9 +281,9 @@ expected_loop_iterations_unbounded (const struct loop *loop,
if (freq_in == 0)
{
- /* If we have no profile at all, expect 3 iterations. */
+ /* If we have no profile at all, use AVG_LOOP_NITER iterations. */
if (!freq_latch)
- expected = 3;
+ expected = PARAM_VALUE (PARAM_AVG_LOOP_NITER);
else
expected = freq_latch * 2;
}
@@ -527,6 +527,11 @@ DEFPARAM(PARAM_IV_ALWAYS_PRUNE_CAND_SET_BOUND,
"If number of candidates in the set is smaller, we always try to remove unused ivs during its optimization.",
10, 0, 0)
+DEFPARAM(PARAM_AVG_LOOP_NITER,
+ "avg-loop-niter",
+ "Average number of iterations of a loop.",
+ 10, 1, 0)
+
DEFPARAM(PARAM_SCEV_MAX_EXPR_SIZE,
"scev-max-expr-size",
"Bound on size of expressions used in the scalar evolutions analyzer.",
@@ -115,8 +115,6 @@ along with GCC; see the file COPYING3. If not see
/* The infinite cost. */
#define INFTY 10000000
-#define AVG_LOOP_NITER(LOOP) 5
-
/* Returns the expected number of loop iterations for LOOP.
The average trip count is computed from profile data if it
exists. */
@@ -128,8 +126,9 @@ avg_loop_niter (struct loop *loop)
if (niter == -1)
{
niter = likely_max_stmt_executions_int (loop);
- if (niter == -1 || niter > AVG_LOOP_NITER (loop))
- return AVG_LOOP_NITER (loop);
+
+ if (niter == -1 || niter > PARAM_VALUE (PARAM_AVG_LOOP_NITER))
+ return PARAM_VALUE (PARAM_AVG_LOOP_NITER);
}
return niter;
--
2.8.4