middle-end/108500 - replace recursive domtree DFS traversal
The following replaces the recursive DFS traversal of the dominator tree in assign_dfs_numbers with a tree traversal using the fact that we have recorded parents. Bootstrapped and tested on x86_64-unknown-linux-gnu. This makes r13-5325 somewhat obsolete, though not computing the DFS numbers at all is beneficial in the cases where we perform immediate CFG manipulations. OK for trunk and later branch(es)? Thanks, Richard. PR middle-end/108500 * dominance.cc (assign_dfs_numbers): Replace recursive DFS with tree traversal algorithm.
This commit is contained in:
parent
e2f939d30f
commit
9725848043
1 changed files with 17 additions and 10 deletions
|
@ -639,18 +639,25 @@ dom_info::calc_idoms ()
|
||||||
static void
|
static void
|
||||||
assign_dfs_numbers (struct et_node *node, int *num)
|
assign_dfs_numbers (struct et_node *node, int *num)
|
||||||
{
|
{
|
||||||
struct et_node *son;
|
et_node *n = node;
|
||||||
|
while (1)
|
||||||
node->dfs_num_in = (*num)++;
|
|
||||||
|
|
||||||
if (node->son)
|
|
||||||
{
|
{
|
||||||
assign_dfs_numbers (node->son, num);
|
n->dfs_num_in = (*num)++;
|
||||||
for (son = node->son->right; son != node->son; son = son->right)
|
if (n->son)
|
||||||
assign_dfs_numbers (son, num);
|
n = n->son;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (!n->right || n->right == n->father->son)
|
||||||
|
{
|
||||||
|
n->dfs_num_out = (*num)++;
|
||||||
|
if (n == node)
|
||||||
|
return;
|
||||||
|
n = n->father;
|
||||||
|
}
|
||||||
|
n->dfs_num_out = (*num)++;
|
||||||
|
n = n->right;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node->dfs_num_out = (*num)++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute the data necessary for fast resolving of dominator queries in a
|
/* Compute the data necessary for fast resolving of dominator queries in a
|
||||||
|
|
Loading…
Add table
Reference in a new issue