public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Avoid computing RPO for update_ssa
@ 2022-06-30  8:38 Richard Biener
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2022-06-30  8:38 UTC (permalink / raw)
  To: gcc-patches

At some point when domwalk got the ability to use RPO for ordering
dominator children we carefully avoided update_ssa eating the cost
of RPO compute.  Unfortunately some later consolidation of CTORs
lost this again so the following makes this explicit via a special
value to the bb_index_to_rpo argument of domwalk, speeding up
update_ssa again.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	* domwalk.h (dom_walker::dom_walker): Update comment to
	reflect reality and new special argument value for
	bb_index_to_rpo.
	* domwalk.cc (dom_walker::dom_walker): Recognize -1
	bb_index_to_rpo.
	* tree-into-ssa.cc
	(rewrite_update_dom_walker::rewrite_update_dom_walker): Tell
	dom_walker to not use RPO.
---
 gcc/domwalk.cc       | 6 ++++--
 gcc/domwalk.h        | 5 +++--
 gcc/tree-into-ssa.cc | 2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/domwalk.cc b/gcc/domwalk.cc
index d633088dff3..e36e9eb8b55 100644
--- a/gcc/domwalk.cc
+++ b/gcc/domwalk.cc
@@ -191,7 +191,8 @@ dom_walker::dom_walker (cdi_direction direction,
     m_reachability (reachability),
     m_user_bb_to_rpo (bb_index_to_rpo != NULL),
     m_unreachable_dom (NULL),
-    m_bb_to_rpo (bb_index_to_rpo)
+    m_bb_to_rpo (bb_index_to_rpo == (int *)(uintptr_t)-1
+		 ? NULL : bb_index_to_rpo)
 {
 }
 
@@ -272,7 +273,8 @@ void
 dom_walker::walk (basic_block bb)
 {
   /* Compute the basic-block index to RPO mapping lazily.  */
-  if (!m_bb_to_rpo
+  if (!m_user_bb_to_rpo
+      && !m_bb_to_rpo
       && m_dom_direction == CDI_DOMINATORS)
     {
       int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
diff --git a/gcc/domwalk.h b/gcc/domwalk.h
index 17ddc1b83df..b71d29400ad 100644
--- a/gcc/domwalk.h
+++ b/gcc/domwalk.h
@@ -62,8 +62,9 @@ public:
 
   /* You can provide a mapping of basic-block index to RPO if you
      have that readily available or you do multiple walks.  If you
-     specify NULL as BB_INDEX_TO_RPO dominator children will not be
-     walked in RPO order.  */
+     specify NULL as BB_INDEX_TO_RPO this mapping will be computed
+     lazily at walk time.  If you specify -1 dominator children will
+     not be walked in RPO order.  */
   dom_walker (cdi_direction direction, enum reachability = ALL_BLOCKS,
 	      int *bb_index_to_rpo = NULL);
 
diff --git a/gcc/tree-into-ssa.cc b/gcc/tree-into-ssa.cc
index f9655ce1a28..c4e40e8fb08 100644
--- a/gcc/tree-into-ssa.cc
+++ b/gcc/tree-into-ssa.cc
@@ -2146,7 +2146,7 @@ class rewrite_update_dom_walker : public dom_walker
 {
 public:
   rewrite_update_dom_walker (cdi_direction direction)
-    : dom_walker (direction, ALL_BLOCKS, NULL) {}
+    : dom_walker (direction, ALL_BLOCKS, (int *)(uintptr_t)-1) {}
 
   edge before_dom_children (basic_block) final override;
   void after_dom_children (basic_block) final override;
-- 
2.35.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] Avoid computing RPO for update_ssa
@ 2022-06-30  8:38 Richard Biener
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2022-06-30  8:38 UTC (permalink / raw)
  To: gcc-patches

At some point when domwalk got the ability to use RPO for ordering
dominator children we carefully avoided update_ssa eating the cost
of RPO compute.  Unfortunately some later consolidation of CTORs
lost this again so the following makes this explicit via a special
value to the bb_index_to_rpo argument of domwalk, speeding up
update_ssa again.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	* domwalk.h (dom_walker::dom_walker): Update comment to
	reflect reality and new special argument value for
	bb_index_to_rpo.
	* domwalk.cc (dom_walker::dom_walker): Recognize -1
	bb_index_to_rpo.
	* tree-into-ssa.cc
	(rewrite_update_dom_walker::rewrite_update_dom_walker): Tell
	dom_walker to not use RPO.
---
 gcc/domwalk.cc       | 6 ++++--
 gcc/domwalk.h        | 5 +++--
 gcc/tree-into-ssa.cc | 2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/domwalk.cc b/gcc/domwalk.cc
index d633088dff3..e36e9eb8b55 100644
--- a/gcc/domwalk.cc
+++ b/gcc/domwalk.cc
@@ -191,7 +191,8 @@ dom_walker::dom_walker (cdi_direction direction,
     m_reachability (reachability),
     m_user_bb_to_rpo (bb_index_to_rpo != NULL),
     m_unreachable_dom (NULL),
-    m_bb_to_rpo (bb_index_to_rpo)
+    m_bb_to_rpo (bb_index_to_rpo == (int *)(uintptr_t)-1
+		 ? NULL : bb_index_to_rpo)
 {
 }
 
@@ -272,7 +273,8 @@ void
 dom_walker::walk (basic_block bb)
 {
   /* Compute the basic-block index to RPO mapping lazily.  */
-  if (!m_bb_to_rpo
+  if (!m_user_bb_to_rpo
+      && !m_bb_to_rpo
       && m_dom_direction == CDI_DOMINATORS)
     {
       int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
diff --git a/gcc/domwalk.h b/gcc/domwalk.h
index 17ddc1b83df..b71d29400ad 100644
--- a/gcc/domwalk.h
+++ b/gcc/domwalk.h
@@ -62,8 +62,9 @@ public:
 
   /* You can provide a mapping of basic-block index to RPO if you
      have that readily available or you do multiple walks.  If you
-     specify NULL as BB_INDEX_TO_RPO dominator children will not be
-     walked in RPO order.  */
+     specify NULL as BB_INDEX_TO_RPO this mapping will be computed
+     lazily at walk time.  If you specify -1 dominator children will
+     not be walked in RPO order.  */
   dom_walker (cdi_direction direction, enum reachability = ALL_BLOCKS,
 	      int *bb_index_to_rpo = NULL);
 
diff --git a/gcc/tree-into-ssa.cc b/gcc/tree-into-ssa.cc
index f9655ce1a28..c4e40e8fb08 100644
--- a/gcc/tree-into-ssa.cc
+++ b/gcc/tree-into-ssa.cc
@@ -2146,7 +2146,7 @@ class rewrite_update_dom_walker : public dom_walker
 {
 public:
   rewrite_update_dom_walker (cdi_direction direction)
-    : dom_walker (direction, ALL_BLOCKS, NULL) {}
+    : dom_walker (direction, ALL_BLOCKS, (int *)(uintptr_t)-1) {}
 
   edge before_dom_children (basic_block) final override;
   void after_dom_children (basic_block) final override;
-- 
2.35.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] Avoid computing RPO for update_ssa
@ 2022-06-30  8:38 Richard Biener
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2022-06-30  8:38 UTC (permalink / raw)
  To: gcc-patches

At some point when domwalk got the ability to use RPO for ordering
dominator children we carefully avoided update_ssa eating the cost
of RPO compute.  Unfortunately some later consolidation of CTORs
lost this again so the following makes this explicit via a special
value to the bb_index_to_rpo argument of domwalk, speeding up
update_ssa again.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	* domwalk.h (dom_walker::dom_walker): Update comment to
	reflect reality and new special argument value for
	bb_index_to_rpo.
	* domwalk.cc (dom_walker::dom_walker): Recognize -1
	bb_index_to_rpo.
	* tree-into-ssa.cc
	(rewrite_update_dom_walker::rewrite_update_dom_walker): Tell
	dom_walker to not use RPO.
---
 gcc/domwalk.cc       | 6 ++++--
 gcc/domwalk.h        | 5 +++--
 gcc/tree-into-ssa.cc | 2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/domwalk.cc b/gcc/domwalk.cc
index d633088dff3..e36e9eb8b55 100644
--- a/gcc/domwalk.cc
+++ b/gcc/domwalk.cc
@@ -191,7 +191,8 @@ dom_walker::dom_walker (cdi_direction direction,
     m_reachability (reachability),
     m_user_bb_to_rpo (bb_index_to_rpo != NULL),
     m_unreachable_dom (NULL),
-    m_bb_to_rpo (bb_index_to_rpo)
+    m_bb_to_rpo (bb_index_to_rpo == (int *)(uintptr_t)-1
+		 ? NULL : bb_index_to_rpo)
 {
 }
 
@@ -272,7 +273,8 @@ void
 dom_walker::walk (basic_block bb)
 {
   /* Compute the basic-block index to RPO mapping lazily.  */
-  if (!m_bb_to_rpo
+  if (!m_user_bb_to_rpo
+      && !m_bb_to_rpo
       && m_dom_direction == CDI_DOMINATORS)
     {
       int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
diff --git a/gcc/domwalk.h b/gcc/domwalk.h
index 17ddc1b83df..b71d29400ad 100644
--- a/gcc/domwalk.h
+++ b/gcc/domwalk.h
@@ -62,8 +62,9 @@ public:
 
   /* You can provide a mapping of basic-block index to RPO if you
      have that readily available or you do multiple walks.  If you
-     specify NULL as BB_INDEX_TO_RPO dominator children will not be
-     walked in RPO order.  */
+     specify NULL as BB_INDEX_TO_RPO this mapping will be computed
+     lazily at walk time.  If you specify -1 dominator children will
+     not be walked in RPO order.  */
   dom_walker (cdi_direction direction, enum reachability = ALL_BLOCKS,
 	      int *bb_index_to_rpo = NULL);
 
diff --git a/gcc/tree-into-ssa.cc b/gcc/tree-into-ssa.cc
index f9655ce1a28..c4e40e8fb08 100644
--- a/gcc/tree-into-ssa.cc
+++ b/gcc/tree-into-ssa.cc
@@ -2146,7 +2146,7 @@ class rewrite_update_dom_walker : public dom_walker
 {
 public:
   rewrite_update_dom_walker (cdi_direction direction)
-    : dom_walker (direction, ALL_BLOCKS, NULL) {}
+    : dom_walker (direction, ALL_BLOCKS, (int *)(uintptr_t)-1) {}
 
   edge before_dom_children (basic_block) final override;
   void after_dom_children (basic_block) final override;
-- 
2.35.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-30  8:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30  8:38 [PATCH] Avoid computing RPO for update_ssa Richard Biener
  -- strict thread matches above, loose matches on Subject: below --
2022-06-30  8:38 Richard Biener
2022-06-30  8:38 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).