diff options
author | Martin Liska <mliska@suse.cz> | 2016-07-12 17:27:36 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2016-07-12 15:27:36 +0000 |
commit | 4661839ee33dff6b43625e9e69fd9a74830556b4 (patch) | |
tree | 70856e5c2b14b375399cf75b6678131352b177dd | |
parent | f507d20235bb7c05ce24c92f65b8aead2594e797 (diff) | |
download | gcc-4661839ee33dff6b43625e9e69fd9a74830556b4.zip gcc-4661839ee33dff6b43625e9e69fd9a74830556b4.tar.gz gcc-4661839ee33dff6b43625e9e69fd9a74830556b4.tar.bz2 |
Introduce new param: AVG_LOOP_NITER
* params.def: Add avg-loop niter.
* tree-ssa-loop-ivopts.c (avg_loop_niter): Use the param.
* cfgloopanal.c (expected_loop_iterations_unbounded): Likewise.
* doc/invoke.texi: Document the new parameter.
From-SVN: r238252
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cfgloopanal.c | 9 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 3 | ||||
-rw-r--r-- | gcc/params.def | 5 | ||||
-rw-r--r-- | gcc/tree-ssa-loop-ivopts.c | 7 |
5 files changed, 22 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 982ba69..0304005 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-07-12 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. + * doc/invoke.texi: Document the new parameter. + 2016-07-12 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/71700 diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c index c163986..2739f44 100644 --- a/gcc/cfgloopanal.c +++ b/gcc/cfgloopanal.c @@ -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; } diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 997faa1..88fff05 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -9150,6 +9150,9 @@ If the number of candidates in the set is smaller than this value, always try to remove unnecessary ivs from the set when adding a new one. +@item avg-loop-niter +Average number of iterations of a loop. + @item scev-max-expr-size Bound on size of expressions used in the scalar evolutions analyzer. Large expressions slow the analyzer. diff --git a/gcc/params.def b/gcc/params.def index 894b7f3..b86d592 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -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.", diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index f5f6e78..20cf9ef 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -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; |