Commit e37240b0 by Richard Biener Committed by Richard Biener

re PR tree-optimization/46590 (long compile time with -O2 and many loops)

2019-04-01  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/46590
	* domwalk.h (dom_walker::dom_walker): Consolidate constructors.
	(dom_walker::m_reachability): Add in place of...
	(dom_walker::m_skip_unreachable_blocks): ...this.
	* domwalk.c (dom_walker::dom_walker): Consoliate constructors.
	Move complex initialization ...
	(dom_walker::walk): Here.  Especially compute m_bb_to_rpo
	lazily and initialize edge flags on each invocation.
	(dom_walker::bb_reachable): Use m_reachability.

From-SVN: r270055
parent 90f14305
2019-04-01 Richard Biener <rguenther@suse.de>
PR tree-optimization/46590
* domwalk.h (dom_walker::dom_walker): Consolidate constructors.
(dom_walker::m_reachability): Add in place of...
(dom_walker::m_skip_unreachable_blocks): ...this.
* domwalk.c (dom_walker::dom_walker): Consoliate constructors.
Move complex initialization ...
(dom_walker::walk): Here. Especially compute m_bb_to_rpo
lazily and initialize edge flags on each invocation.
(dom_walker::bb_reachable): Use m_reachability.
2019-04-01 Martin Liska <mliska@suse.cz> 2019-04-01 Martin Liska <mliska@suse.cz>
PR driver/89861 PR driver/89861
......
...@@ -190,69 +190,11 @@ dom_walker::dom_walker (cdi_direction direction, ...@@ -190,69 +190,11 @@ dom_walker::dom_walker (cdi_direction direction,
enum reachability reachability, enum reachability reachability,
int *bb_index_to_rpo) int *bb_index_to_rpo)
: m_dom_direction (direction), : m_dom_direction (direction),
m_skip_unreachable_blocks (reachability != ALL_BLOCKS), m_reachability (reachability),
m_user_bb_to_rpo (true), m_user_bb_to_rpo (bb_index_to_rpo != NULL),
m_unreachable_dom (NULL), m_unreachable_dom (NULL),
m_bb_to_rpo (bb_index_to_rpo) m_bb_to_rpo (bb_index_to_rpo)
{ {
/* 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,
true);
m_bb_to_rpo = XNEWVEC (int, last_basic_block_for_fn (cfun));
for (int i = 0; i < postorder_num; ++i)
m_bb_to_rpo[postorder[i]] = i;
free (postorder);
}
/* 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;
}
} }
/* Destructor. */ /* Destructor. */
...@@ -270,7 +212,7 @@ dom_walker::bb_reachable (struct function *fun, basic_block bb) ...@@ -270,7 +212,7 @@ dom_walker::bb_reachable (struct function *fun, basic_block bb)
{ {
/* If we're not skipping unreachable blocks, then assume everything /* If we're not skipping unreachable blocks, then assume everything
is reachable. */ is reachable. */
if (!m_skip_unreachable_blocks) if (m_reachability == ALL_BLOCKS)
return true; return true;
/* If any of the predecessor edges that do not come from blocks dominated /* If any of the predecessor edges that do not come from blocks dominated
...@@ -331,6 +273,23 @@ const edge dom_walker::STOP = (edge)-1; ...@@ -331,6 +273,23 @@ const edge dom_walker::STOP = (edge)-1;
void void
dom_walker::walk (basic_block bb) dom_walker::walk (basic_block bb)
{ {
/* Compute the basic-block index to RPO mapping lazily. */
if (!m_bb_to_rpo
&& m_dom_direction == CDI_DOMINATORS)
{
int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
int postorder_num = pre_and_rev_post_order_compute (NULL, postorder,
true);
m_bb_to_rpo = XNEWVEC (int, last_basic_block_for_fn (cfun));
for (int i = 0; i < postorder_num; ++i)
m_bb_to_rpo[postorder[i]] = i;
free (postorder);
}
/* Set up edge flags if need be. */
if (m_reachability == REACHABLE_BLOCKS)
set_all_edges_as_executable (cfun);
basic_block dest; basic_block dest;
basic_block *worklist = XNEWVEC (basic_block, basic_block *worklist = XNEWVEC (basic_block,
n_basic_blocks_for_fn (cfun) * 2); n_basic_blocks_for_fn (cfun) * 2);
......
...@@ -60,13 +60,12 @@ public: ...@@ -60,13 +60,12 @@ public:
REACHABLE_BLOCKS_PRESERVING_FLAGS 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 /* You can provide a mapping of basic-block index to RPO if you
have that readily available or you do multiple walks. 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 specify NULL as BB_INDEX_TO_RPO dominator children will not be
walked in RPO order. */ walked in RPO order. */
dom_walker (cdi_direction direction, enum reachability, int *bb_index_to_rpo); dom_walker (cdi_direction direction, enum reachability = ALL_BLOCKS,
int *bb_index_to_rpo = NULL);
~dom_walker (); ~dom_walker ();
...@@ -94,7 +93,7 @@ private: ...@@ -94,7 +93,7 @@ private:
if it is set to CDI_POST_DOMINATORS, then we walk the post if it is set to CDI_POST_DOMINATORS, then we walk the post
dominator tree. */ dominator tree. */
const ENUM_BITFIELD (cdi_direction) m_dom_direction : 2; const ENUM_BITFIELD (cdi_direction) m_dom_direction : 2;
bool m_skip_unreachable_blocks; const ENUM_BITFIELD (reachability) m_reachability : 2;
bool m_user_bb_to_rpo; bool m_user_bb_to_rpo;
basic_block m_unreachable_dom; basic_block m_unreachable_dom;
int *m_bb_to_rpo; int *m_bb_to_rpo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment