]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/111489 - turn uninit limits to params
authorRichard Biener <rguenther@suse.de>
Wed, 20 Sep 2023 06:40:34 +0000 (08:40 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 10 Nov 2023 13:22:03 +0000 (14:22 +0100)
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.

PR tree-optimization/111489
* doc/invoke.texi (--param uninit-max-chain-len): Document.
(--param uninit-max-num-chains): Likewise.
* params.opt (-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.

(cherry picked from commit b8a2a12464d25c45a51c14a025e8e2d3ca8ebeb0)

gcc/doc/invoke.texi
gcc/gimple-predicate-analysis.cc
gcc/params.opt

index de40f62e219cc742b3d2eb708bbbeb9ca7ab2e69..6c76a29574cb82469bbe35538a80b42ab69547e8 100644 (file)
@@ -16102,6 +16102,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 '
index 72d14d71c004ea515b8a9a29c2f03ee6f6fdd486..3615661742dbd5f63dbd451e3316652a84d33e58 100644 (file)
@@ -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.  */
 
@@ -1162,11 +1162,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);
@@ -2034,7 +2035,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,
@@ -2059,6 +2060,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 ();
 }
 
@@ -2143,7 +2145,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];
@@ -2174,6 +2176,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 ();
 }
 
index 823cdb2ff8565b931796cf6a11c17ab249281f2b..f50bbb6ffd8293e521728be45cec20a3862b2f4a 100644 (file)
@@ -1114,6 +1114,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.