On 12/10/15 16:49, Tom de Vries wrote:
Hi,

I've committed the following patch series to the gomp-4_0-branch.

      1    Add pass_dominator::jump_threading_p ()
      2    Add dom_walker::walk_until
      3    Add pass_dominator::sese_mode_p ()
      4    Add skip_stmt parm to pass_dominator::get_sese ()
      5    Add oacc kernels related infra functions
      6    Add pass_dominator_oacc_kernels

The patch series adds a pass pass_dominator_oacc_kernels, which does the
pass_dominator optimizations (with the exception of jump threading) on
each oacc kernels region rather than on the whole function.

Bootstrapped and reg-tested on x86_64.

I'll post the patches individually, in reply to this email.

This patch adds the ability to walk a part of a dominator tree, rather than the whole tree.

Thanks,
- Tom
Add dom_walker::walk_until

2015-10-12  Tom de Vries  <t...@codesourcery.com>

	* domwalk.c (dom_walker::walk): Rename to ...
	(dom_walker::walk_until): ... this.  Add and handle until and
	until_inclusive parameters.
	(dom_walker::walk): Reimplement using dom_walker::walk_until.
	* domwalk.h (dom_walker::walk_until): Declare.
---
 gcc/domwalk.c | 32 +++++++++++++++++++++++++++-----
 gcc/domwalk.h |  2 ++
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/gcc/domwalk.c b/gcc/domwalk.c
index bbf9ff8..5fe666e 100644
--- a/gcc/domwalk.c
+++ b/gcc/domwalk.c
@@ -144,11 +144,18 @@ cmp_bb_postorder (const void *a, const void *b)
 }
 
 /* Recursively walk the dominator tree.
-   BB is the basic block we are currently visiting.  */
+   BB is the basic block we are currently visiting.  UNTIL is a basic_block that
+   is the root of a subtree that we won't visit.  If UNTIL_INCLUSIVE, we visit
+   UNTIL, but not it's children.  Otherwise don't visit UNTIL and its
+   children.  */
 
 void
-dom_walker::walk (basic_block bb)
+dom_walker::walk_until (basic_block bb, basic_block until, bool until_inclusive)
 {
+  bool skip_self = (bb == until && !until_inclusive);
+  if (skip_self)
+    return;
+
   basic_block dest;
   basic_block *worklist = XNEWVEC (basic_block,
 				   n_basic_blocks_for_fn (cfun) * 2);
@@ -182,9 +189,15 @@ dom_walker::walk (basic_block bb)
 	  worklist[sp++] = NULL;
 
 	  int saved_sp = sp;
-	  for (dest = first_dom_son (m_dom_direction, bb);
-	       dest; dest = next_dom_son (m_dom_direction, dest))
-	    worklist[sp++] = dest;
+	  bool skip_children = bb == until && until_inclusive;
+	  if (!skip_children)
+	    for (dest = first_dom_son (m_dom_direction, bb);
+		 dest; dest = next_dom_son (m_dom_direction, dest))
+	      {
+		bool skip_child = (dest == until && !until_inclusive);
+		if (!skip_child)
+		  worklist[sp++] = dest;
+	      }
 	  if (m_dom_direction == CDI_DOMINATORS)
 	    switch (sp - saved_sp)
 	      {
@@ -218,3 +231,12 @@ dom_walker::walk (basic_block bb)
     }
   free (worklist);
 }
+
+/* Recursively walk the dominator tree.
+   BB is the basic block we are currently visiting.  */
+
+void
+dom_walker::walk (basic_block bb)
+{
+  walk_until (bb, NULL, true);
+}
diff --git a/gcc/domwalk.h b/gcc/domwalk.h
index 71a7c47..71e6075 100644
--- a/gcc/domwalk.h
+++ b/gcc/domwalk.h
@@ -34,6 +34,8 @@ public:
 
   /* Walk the dominator tree.  */
   void walk (basic_block);
+  /* Walk a part of the dominator tree.  */
+  void walk_until (basic_block, basic_block, bool);
 
   /* Function to call before the recursive walk of the dominator children.  */
   virtual void before_dom_children (basic_block) {}
-- 
1.9.1

Reply via email to