The following turns MAX_NUM_CHAINS and MAX_CHAIN_LEN to params which
allows to experiment with raising them. For the testcase in PR111489
raising MAX_CHAIN_LEN from 5 to 8 avoids the bogus diagnostics
at -O2, at -O3 we need a MAX_CHAIN_LEN of 6.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/111489
* doc/invoke.texi (--param uninit-max-chain-len): Document.
(--param uninit-max-num-chains): Likewise.
* params.def (-param=uninit-max-chain-len=): New.
(-param=uninit-max-num-chains=): Likewise.
* gimple-predicate-analysis.cc (MAX_NUM_CHAINS): Define to
param_uninit_max_num_chains.
(MAX_CHAIN_LEN): Define to param_uninit_max_chain_len.
(uninit_analysis::init_use_preds): Avoid VLA.
(uninit_analysis::init_from_phi_def): Likewise.
(compute_control_dep_chain): Avoid using MAX_CHAIN_LEN in
template parameter.
---
gcc/doc/invoke.texi | 7 +++++++
gcc/gimple-predicate-analysis.cc | 13 ++++++++-----
gcc/params.opt | 9 +++++++++
3 files changed, 24 insertions(+), 5 deletions(-)
@@ -16348,6 +16348,13 @@ crossing a loop backedge when comparing to
Maximum number of nested calls to search for control dependencies
during uninitialized variable analysis.
+@item uninit-max-chain-len
+Maximum number of predicates anded for each predicate ored in the normalized
+predicate chain.
+
+@item uninit-max-num-chains
+Maximum number of predicates ored in the normalized predicate chain.
+
@item sched-autopref-queue-depth
Hardware autoprefetcher scheduler model control flag.
Number of lookahead cycles the model looks into; at '
@@ -50,8 +50,8 @@
/* In our predicate normal form we have MAX_NUM_CHAINS or predicates
and in those MAX_CHAIN_LEN (inverted) and predicates. */
-#define MAX_NUM_CHAINS 8
-#define MAX_CHAIN_LEN 5
+#define MAX_NUM_CHAINS (unsigned)param_uninit_max_num_chains
+#define MAX_CHAIN_LEN (unsigned)param_uninit_max_chain_len
/* Return true if X1 is the negation of X2. */
@@ -1163,11 +1163,12 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb,
vec<edge> cd_chains[], unsigned *num_chains,
unsigned in_region = 0)
{
- auto_vec<edge, MAX_CHAIN_LEN + 1> cur_cd_chain;
+ auto_vec<edge, 10> cur_cd_chain;
unsigned num_calls = 0;
unsigned depth = 0;
bool complete_p = true;
/* Walk the post-dominator chain. */
+ cur_cd_chain.reserve (MAX_CHAIN_LEN + 1);
compute_control_dep_chain_pdom (dom_bb, dep_bb, NULL, cd_chains,
num_chains, cur_cd_chain, &num_calls,
in_region, depth, &complete_p);
@@ -2035,7 +2036,7 @@ uninit_analysis::init_use_preds (predicate &use_preds, basic_block def_bb,
are logical conjunctions. Together, the DEP_CHAINS vector is
used below to initialize an OR expression of the conjunctions. */
unsigned num_chains = 0;
- auto_vec<edge> dep_chains[MAX_NUM_CHAINS];
+ auto_vec<edge> *dep_chains = new auto_vec<edge>[MAX_NUM_CHAINS];
if (!dfs_mark_dominating_region (use_bb, cd_root, in_region, region)
|| !compute_control_dep_chain (cd_root, use_bb, dep_chains, &num_chains,
@@ -2060,6 +2061,7 @@ uninit_analysis::init_use_preds (predicate &use_preds, basic_block def_bb,
Each OR subexpression is represented by one element of DEP_CHAINS,
where each element consists of a series of AND subexpressions. */
use_preds.init_from_control_deps (dep_chains, num_chains, true);
+ delete[] dep_chains;
return !use_preds.is_empty ();
}
@@ -2144,7 +2146,7 @@ uninit_analysis::init_from_phi_def (gphi *phi)
break;
unsigned num_chains = 0;
- auto_vec<edge> dep_chains[MAX_NUM_CHAINS];
+ auto_vec<edge> *dep_chains = new auto_vec<edge>[MAX_NUM_CHAINS];
for (unsigned i = 0; i < nedges; i++)
{
edge e = def_edges[i];
@@ -2175,6 +2177,7 @@ uninit_analysis::init_from_phi_def (gphi *phi)
which the PHI operands are defined to values for which M_EVAL is
false. */
m_phi_def_preds.init_from_control_deps (dep_chains, num_chains, false);
+ delete[] dep_chains;
return !m_phi_def_preds.is_empty ();
}
@@ -1106,6 +1106,15 @@ Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
Common Joined UInteger Var(param_uninit_control_dep_attempts) Init(1000) IntegerRange(1, 65536) Param Optimization
Maximum number of nested calls to search for control dependencies during uninitialized variable analysis.
+-param=uninit-max-chain-len=
+Common Joined UInteger Var(param_uninit_max_chain_len) Init(5) IntegerRange(1, 128) Param Optimization
+Maximum number of predicates anded for each predicate ored in the normalized
+predicate chain.
+
+-param=uninit-max-num-chains=
+Common Joined UInteger Var(param_uninit_max_num_chains) Init(8) IntegerRange(1, 128) Param Optimization
+Maximum number of predicates ored in the normalized predicate chain.
+
-param=uninlined-function-insns=
Common Joined UInteger Var(param_uninlined_function_insns) Init(2) Optimization IntegerRange(0, 1000000) Param
Instruction accounted for function prologue, epilogue and other overhead.