public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-2513] mark region also for USE predicate discovery
@ 2022-09-07 10:08 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-09-07 10:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d14514641d7d2052bc2bf1f09018e1f18f19850a

commit r13-2513-gd14514641d7d2052bc2bf1f09018e1f18f19850a
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Sep 6 15:30:53 2022 +0200

    mark region also for USE predicate discovery
    
    The following makes sure to mark the dominating region also for
    USE predicate discovery, avoiding compute_control_dep_chain to
    walk to unrelated areas, eating up walking budget.
    
            * gimple-predicate-analysis.cc (dfs_mark_dominating_region):
            Adjust to take the region exit source as argument.
            (uninit_analysis::init_from_phi_def): Adjust.
            (uninit_analysis::init_use_preds): Mark the dominating region
            before computing control dependences.

Diff:
---
 gcc/gimple-predicate-analysis.cc | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc
index 5dade458947..f81af2589cd 100644
--- a/gcc/gimple-predicate-analysis.cc
+++ b/gcc/gimple-predicate-analysis.cc
@@ -934,23 +934,23 @@ simple_control_dep_chain (vec<edge>& chain, basic_block from, basic_block to)
 }
 
 /* Perform a DFS walk on predecessor edges to mark the region denoted
-   by the EXIT edge and DOM which dominates EXIT->src, including DOM.
+   by the EXIT_SRC block and DOM which dominates EXIT_SRC, including DOM.
    Blocks in the region are marked with FLAG and added to BBS.  BBS is
    filled up to its capacity only after which the walk is terminated
    and false is returned.  If the whole region was marked, true is returned.  */
 
 static bool
-dfs_mark_dominating_region (edge exit, basic_block dom, int flag,
+dfs_mark_dominating_region (basic_block exit_src, basic_block dom, int flag,
 			    vec<basic_block> &bbs)
 {
-  if (exit->src == dom || exit->src->flags & flag)
+  if (exit_src == dom || exit_src->flags & flag)
     return true;
   if (!bbs.space (1))
     return false;
-  bbs.quick_push (exit->src);
-  exit->src->flags |= flag;
+  bbs.quick_push (exit_src);
+  exit_src->flags |= flag;
   auto_vec<edge_iterator, 20> stack (bbs.allocated () - bbs.length () + 1);
-  stack.quick_push (ei_start (exit->src->preds));
+  stack.quick_push (ei_start (exit_src->preds));
   while (!stack.is_empty ())
     {
       /* Look at the edge on the top of the stack.  */
@@ -1960,6 +1960,10 @@ uninit_analysis::init_use_preds (predicate &use_preds, basic_block def_bb,
     }
   while (1);
 
+  auto_bb_flag in_region (cfun);
+  auto_vec<basic_block, 20> region (MIN (n_basic_blocks_for_fn (cfun),
+					 param_uninit_control_dep_attempts));
+
   /* Set DEP_CHAINS to the set of edges between CD_ROOT and USE_BB.
      Each DEP_CHAINS element is a series of edges whose conditions
      are logical conjunctions.  Together, the DEP_CHAINS vector is
@@ -1967,7 +1971,9 @@ uninit_analysis::init_use_preds (predicate &use_preds, basic_block def_bb,
   unsigned num_chains = 0;
   auto_vec<edge> dep_chains[MAX_NUM_CHAINS];
 
-  if (!compute_control_dep_chain (cd_root, use_bb, dep_chains, &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,
+				     in_region))
     {
       /* If the info in dep_chains is not complete we need to use a
 	 conservative approximation for the use predicate.  */
@@ -1979,6 +1985,10 @@ uninit_analysis::init_use_preds (predicate &use_preds, basic_block def_bb,
       simple_control_dep_chain (dep_chains[0], cd_root, use_bb);
     }
 
+  /* Unmark the region.  */
+  for (auto bb : region)
+    bb->flags &= ~in_region;
+
   /* From the set of edges computed above initialize *THIS as the OR
      condition under which the definition in DEF_BB is used in USE_BB.
      Each OR subexpression is represented by one element of DEP_CHAINS,
@@ -2061,7 +2071,8 @@ uninit_analysis::init_from_phi_def (gphi *phi)
 	}
     }
   for (unsigned i = 0; i < nedges; i++)
-    if (!dfs_mark_dominating_region (def_edges[i], cd_root, in_region, region))
+    if (!dfs_mark_dominating_region (def_edges[i]->src, cd_root,
+				     in_region, region))
       break;
 
   unsigned num_chains = 0;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-07 10:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07 10:08 [gcc r13-2513] mark region also for USE predicate discovery Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).