From 40517ca836f868b8bd79bde56aa7c053ffef4fc2 Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Tue, 7 Mar 2017 13:53:04 +0000 Subject: [PATCH 24/33] add-bound-on-selected-cands-20170221.txt --- gcc/doc/invoke.texi | 4 ++++ gcc/params.def | 8 ++++++++ gcc/tree-ssa-loop-ivopts.c | 8 +++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 19a85b6..f9cbdbb 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -9922,6 +9922,10 @@ 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 iv-max-selected-candidates +The induction variable optimizations give up on loops that more induction +variable candidates are selected. + @item avg-loop-niter Average number of iterations of a loop. diff --git a/gcc/params.def b/gcc/params.def index 1b058e4..7daab14 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -527,6 +527,14 @@ 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) +/* The induction variable optimizations give up on loops that more induction + variable candidates are selected. */ + +DEFPARAM(PARAM_IV_MAX_SELECTED_CANDIDATES, + "iv-max-selected-candidates", + "Bound on number of selected iv candidates for loops in iv optimizations.", + 48, 0, 0) + DEFPARAM(PARAM_AVG_LOOP_NITER, "avg-loop-niter", "Average number of iterations of a loop.", diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index dcc4618..8469782 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -667,6 +667,12 @@ struct iv_ca_delta #define ALWAYS_PRUNE_CAND_SET_BOUND \ ((unsigned) PARAM_VALUE (PARAM_IV_ALWAYS_PRUNE_CAND_SET_BOUND)) +/* If there are more candidates slected, we just give up because it usually + causes high register pressure issue. */ + +#define MAX_SELECTED_CANDIDATES \ + ((unsigned) PARAM_VALUE (PARAM_IV_MAX_SELECTED_CANDIDATES)) + /* The list of trees for that the decl_rtl field must be reset is stored here. */ @@ -7382,7 +7388,7 @@ tree_ssa_iv_optimize_loop (struct ivopts_data *data, struct loop *loop) /* Find the optimal set of induction variables (item 3, part 2). */ iv_ca = find_optimal_iv_set (data); - if (!iv_ca) + if (!iv_ca || iv_ca->n_cands > MAX_SELECTED_CANDIDATES) goto finish; changed = true; -- 1.9.1