From: Richard Biener Date: Thu, 1 Feb 2018 12:51:24 +0000 (+0000) Subject: domwalk.h (dom_walker::dom_walker): Add additional constructor for specifying RPO... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dc3b4a20b5d83aea66758e8da31ce04a8cf3964b;p=gcc.git domwalk.h (dom_walker::dom_walker): Add additional constructor for specifying RPO order and allow NULL for that. 2018-02-01 Richard Biener * domwalk.h (dom_walker::dom_walker): Add additional constructor for specifying RPO order and allow NULL for that. * domwalk.c (dom_walker::dom_walker): Likewise. (dom_walker::walk): Handle NULL RPO order. * tree-into-ssa.c (rewrite_dom_walker): Do not walk dom children in RPO order. (rewrite_update_dom_walker): Likewise. (mark_def_dom_walker): Likewise. * gcc.dg/graphite/pr35356-1.c: Adjust. From-SVN: r257293 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b655476aaac..28804f16cc8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2018-02-01 Richard Biener + + * domwalk.h (dom_walker::dom_walker): Add additional constructor + for specifying RPO order and allow NULL for that. + * domwalk.c (dom_walker::dom_walker): Likewise. + (dom_walker::walk): Handle NULL RPO order. + * tree-into-ssa.c (rewrite_dom_walker): Do not walk dom children + in RPO order. + (rewrite_update_dom_walker): Likewise. + (mark_def_dom_walker): Likewise. + 2018-02-01 Richard Sandiford * config/aarch64/aarch64-protos.h (aarch64_split_sve_subreg_move) diff --git a/gcc/domwalk.c b/gcc/domwalk.c index 0161761330b..2791e93817a 100644 --- a/gcc/domwalk.c +++ b/gcc/domwalk.c @@ -191,13 +191,41 @@ dom_walker::dom_walker (cdi_direction direction, int *bb_index_to_rpo) : m_dom_direction (direction), m_skip_unreachable_blocks (reachability != ALL_BLOCKS), - m_user_bb_to_rpo (bb_index_to_rpo != NULL), + m_user_bb_to_rpo (true), m_unreachable_dom (NULL), m_bb_to_rpo (bb_index_to_rpo) { - /* Compute the basic-block index to RPO mapping if not provided by - the user. */ - if (! m_bb_to_rpo && direction == CDI_DOMINATORS) + /* Set up edge flags if need be. */ + switch (reachability) + { + default: + gcc_unreachable (); + case ALL_BLOCKS: + /* No need to touch edge flags. */ + break; + + case REACHABLE_BLOCKS: + set_all_edges_as_executable (cfun); + break; + + case REACHABLE_BLOCKS_PRESERVING_FLAGS: + /* Preserve the edge flags. */ + break; + } +} + +/* Constructor for a dom walker. */ + +dom_walker::dom_walker (cdi_direction direction, + enum reachability reachability) + : m_dom_direction (direction), + m_skip_unreachable_blocks (reachability != ALL_BLOCKS), + m_user_bb_to_rpo (false), + m_unreachable_dom (NULL), + m_bb_to_rpo (NULL) +{ + /* Compute the basic-block index to RPO mapping. */ + if (direction == CDI_DOMINATORS) { int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (cfun)); int postorder_num = pre_and_rev_post_order_compute (NULL, postorder, @@ -348,7 +376,10 @@ dom_walker::walk (basic_block bb) for (dest = first_dom_son (m_dom_direction, bb); dest; dest = next_dom_son (m_dom_direction, dest)) worklist[sp++] = dest; - if (sp - saved_sp > 1 && m_dom_direction == CDI_DOMINATORS) + /* Sort worklist after RPO order if requested. */ + if (sp - saved_sp > 1 + && m_dom_direction == CDI_DOMINATORS + && m_bb_to_rpo) sort_bbs_postorder (&worklist[saved_sp], sp - saved_sp); } } diff --git a/gcc/domwalk.h b/gcc/domwalk.h index 2e8290f3a1c..3057bddc79e 100644 --- a/gcc/domwalk.h +++ b/gcc/domwalk.h @@ -60,10 +60,13 @@ public: REACHABLE_BLOCKS_PRESERVING_FLAGS }; + dom_walker (cdi_direction direction, enum reachability = ALL_BLOCKS); + /* You can provide a mapping of basic-block index to RPO if you - have that readily available or you do multiple walks. */ - dom_walker (cdi_direction direction, enum reachability = ALL_BLOCKS, - int *bb_index_to_rpo = NULL); + 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. */ + dom_walker (cdi_direction direction, enum reachability, int *bb_index_to_rpo); ~dom_walker (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bd118a9391c..36ffcea1675 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-02-01 Richard Biener + + * gcc.dg/graphite/pr35356-1.c: Adjust. + 2018-02-01 Richard Sandiford PR testsuite/83846 diff --git a/gcc/testsuite/gcc.dg/graphite/pr35356-1.c b/gcc/testsuite/gcc.dg/graphite/pr35356-1.c index ce85178fa68..07339c8f641 100644 --- a/gcc/testsuite/gcc.dg/graphite/pr35356-1.c +++ b/gcc/testsuite/gcc.dg/graphite/pr35356-1.c @@ -34,4 +34,4 @@ if (n >= k + 1 && k >= 0) { */ -/* { dg-final { scan-tree-dump "if \\\(P_8 >= P_11 \\\+ 1 && P_11 >= 0\\\) \\\{" "graphite" } } */ +/* { dg-final { scan-tree-dump "if \\\(P_\[0-9\]+ >= P_\[0-9\]+ \\\+ 1 && P_\[0-9\]+ >= 0\\\) \\\{" "graphite" } } */ diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index e9a98b2c035..f4af33c1303 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -1463,7 +1463,8 @@ rewrite_add_phi_arguments (basic_block bb) class rewrite_dom_walker : public dom_walker { public: - rewrite_dom_walker (cdi_direction direction) : dom_walker (direction) {} + rewrite_dom_walker (cdi_direction direction) + : dom_walker (direction, ALL_BLOCKS, NULL) {} virtual edge before_dom_children (basic_block); virtual void after_dom_children (basic_block); @@ -2153,7 +2154,8 @@ rewrite_update_phi_arguments (basic_block bb) class rewrite_update_dom_walker : public dom_walker { public: - rewrite_update_dom_walker (cdi_direction direction) : dom_walker (direction) {} + rewrite_update_dom_walker (cdi_direction direction) + : dom_walker (direction, ALL_BLOCKS, NULL) {} virtual edge before_dom_children (basic_block); virtual void after_dom_children (basic_block); @@ -2322,7 +2324,7 @@ private: }; mark_def_dom_walker::mark_def_dom_walker (cdi_direction direction) - : dom_walker (direction), m_kills (BITMAP_ALLOC (NULL)) + : dom_walker (direction, ALL_BLOCKS, NULL), m_kills (BITMAP_ALLOC (NULL)) { }