summaryrefslogtreecommitdiffhomepage
path: root/ir/opt
diff options
context:
space:
mode:
authorElias Aebi <elias.aebi@student.kit.edu>2018-04-05 14:24:51 +0200
committerJohannes Bucher <johannes.bucher2@student.kit.edu>2019-01-24 17:42:00 +0100
commitee05308675743bc225dada8c0f37b7613cd1c0da (patch)
treed46139eddae3c94063702b2eb8a3a092b4e30c44 /ir/opt
parentf10554a40d83cf9676a56ddea0c2064473b62eba (diff)
only visit each successor once
Diffstat (limited to 'ir/opt')
-rw-r--r--ir/opt/loop2.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ir/opt/loop2.c b/ir/opt/loop2.c
index 87a28b8..aa06407 100644
--- a/ir/opt/loop2.c
+++ b/ir/opt/loop2.c
@@ -100,7 +100,7 @@ static void rewire_node(ir_node *const node, ir_node *const header)
int n;
ir_node *const succ = get_irn_out_ex(node, i, &n);
// TODO: revisit this condition
- if (get_irn_link(succ) == NULL && (is_Block(succ) || is_Phi(succ))) {
+ if (get_irn_link(succ) == NULL && (is_Block(succ) || is_Phi(succ)) && !irn_visited(succ)) {
int const arity = get_irn_arity(succ);
int new_arity = arity;
for (int j = 0; j < arity; ++j) {
@@ -120,6 +120,7 @@ static void rewire_node(ir_node *const node, ir_node *const header)
}
}
set_irn_in(succ, new_arity, in);
+ mark_irn_visited(succ);
}
}
@@ -221,6 +222,7 @@ static void duplicate_loop(ir_loop *const loop)
if (header == NULL)
return;
size_t const n_elements = get_loop_n_elements(loop);
+
// step 1: duplicate blocks
for (size_t i = 0; i < n_elements; ++i) {
loop_element const element = get_loop_element(loop, i);
@@ -229,7 +231,9 @@ static void duplicate_loop(ir_loop *const loop)
duplicate_block(element.node);
}
}
+
// step 2: rewire the edges
+ inc_irg_visited(get_irn_irg(header));
for (size_t i = 0; i < n_elements; ++i) {
loop_element const element = get_loop_element(loop, i);
if (*element.kind == k_ir_node) {