]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
niter: Make MAX_DOMINATORS_TO_WALK configurable at runtime
authorMichiel Derhaeg <Michiel.Derhaeg@synopsys.com>
Wed, 29 Apr 2026 15:38:58 +0000 (08:38 -0700)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 30 Apr 2026 07:16:25 +0000 (09:16 +0200)
MAX_DOMINATORS_TO_WALK can be too small for very large function bodies.
Made it an option such that we can increase the value when needed.

gcc/ChangeLog:

* doc/params.texi: Added --param=max-niter-dominators-walk.
* params.opt: Added --param=max-niter-dominators-walk.
* tree-ssa-loop-niter.cc (MAX_DOMINATORS_TO_WALK): Removed.
(determine_value_range): Updated.
(bound_difference): Updated.
(simplify_using_initial_conditions): Updated.

Signed-off-by: Michiel Derhaeg <michiel@synopsys.com>
gcc/doc/params.texi
gcc/params.opt
gcc/tree-ssa-loop-niter.cc

index 31b04688cf77c20d777e397509f687dd15329f8e..e6c89607e0d832fb3b5941af577dab0557402a84 100644 (file)
@@ -889,6 +889,11 @@ protection when @option{-fstack-protector} is used.
 The minimum size of variables taking part in stack slot sharing when not
 optimizing.
 
+@paindex max-niter-dominators-walk
+@item max-niter-dominators-walk
+Maximum number of dominators BBs to walk when simplifying loop bounds
+and conditions.
+
 @paindex max-jump-thread-duplication-stmts
 @item max-jump-thread-duplication-stmts
 Maximum number of statements allowed in a block that needs to be
index b35ca688cdf15de81915e47be0ec6c19df5a974e..9eeb1f3fa64e80a2e4ef89583966497b5f602da8 100644 (file)
@@ -674,6 +674,10 @@ Bound on the cost of an expression to compute the number of iterations.
 Common Joined UInteger Var(param_max_iterations_to_track) Init(1000) Param Optimization
 Bound on the number of iterations the brute force # of iterations analysis algorithm evaluates.
 
+-param=max-niter-dominators-walk=
+Common Joined UInteger Var(param_max_niter_dominators_walk) Init(8) IntegerRange(1, 1024) Param Optimization
+Maximum number of dominators BBs to walk when simplifying loop bounds and conditions.
+
 -param=max-jump-thread-duplication-stmts=
 Common Joined UInteger Var(param_max_jump_thread_duplication_stmts) Init(15) Param Optimization
 Maximum number of statements allowed in a block that needs to be duplicated when threading jumps.
index 00c4a9c81f85c41a8afe6ebb63978ee03cdcb84b..c39401147aedb4ff8e3001a9048d72b68b5d5d04 100644 (file)
@@ -48,11 +48,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "sreal.h"
 
 
-/* The maximum number of dominator BBs we search for conditions
-   of loop header copies we use for simplifying a conditional
-   expression.  */
-#define MAX_DOMINATORS_TO_WALK 8
-
 /*
 
    Analysis of number of iterations of an affine exit test.
@@ -441,7 +436,8 @@ determine_value_range (class loop *loop, tree type, tree var, mpz_t off,
       /* Now walk the dominators of the loop header and use the entry
         guards to refine the estimates.  */
       for (bb = loop->header;
-          bb != ENTRY_BLOCK_PTR_FOR_FN (cfun) && cnt < MAX_DOMINATORS_TO_WALK;
+          bb != ENTRY_BLOCK_PTR_FOR_FN (cfun)
+            && cnt < param_max_niter_dominators_walk;
           bb = get_immediate_dominator (CDI_DOMINATORS, bb))
        {
          edge e;
@@ -769,7 +765,8 @@ bound_difference (class loop *loop, tree x, tree y, bounds *bnds)
   /* Now walk the dominators of the loop header and use the entry
      guards to refine the estimates.  */
   for (bb = loop->header;
-       bb != ENTRY_BLOCK_PTR_FOR_FN (cfun) && cnt < MAX_DOMINATORS_TO_WALK;
+       bb != ENTRY_BLOCK_PTR_FOR_FN (cfun)
+        && cnt < param_max_niter_dominators_walk;
        bb = get_immediate_dominator (CDI_DOMINATORS, bb))
     {
       if (!single_pred_p (bb))
@@ -3100,7 +3097,8 @@ simplify_using_initial_conditions (class loop *loop, tree expr)
      the number of BBs times the number of loops in degenerate
      cases.  */
   for (bb = loop->header;
-       bb != ENTRY_BLOCK_PTR_FOR_FN (cfun) && cnt < MAX_DOMINATORS_TO_WALK;
+       bb != ENTRY_BLOCK_PTR_FOR_FN (cfun)
+        && cnt < param_max_niter_dominators_walk;
        bb = get_immediate_dominator (CDI_DOMINATORS, bb))
     {
       if (!single_pred_p (bb))