summaryrefslogtreecommitdiffhomepage
path: root/ir/opt
diff options
context:
space:
mode:
authorElias Aebi <elias.aebi@student.kit.edu>2018-04-03 11:09:02 +0200
committerJohannes Bucher <johannes.bucher2@student.kit.edu>2019-01-24 17:42:00 +0100
commite999e12a7186c8d520ef1eeda2a41a9fb52d56d6 (patch)
tree02ee2258b357946434a71ca702966adcc10a447a /ir/opt
parent4c37cb7a962f0fb0e65544593ac91f5343970ab2 (diff)
improve the rewire logic
Diffstat (limited to 'ir/opt')
-rw-r--r--ir/opt/loop2.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/ir/opt/loop2.c b/ir/opt/loop2.c
index 27b7d8d..0e13246 100644
--- a/ir/opt/loop2.c
+++ b/ir/opt/loop2.c
@@ -111,16 +111,16 @@ static void rewire_node(ir_node *const node, ir_node *const header)
++new_arity;
}
ir_node **const in = ALLOCAN(ir_node *, new_arity);
- for (int j = 0; j < arity; ++j) {
+ for (int j = 0, k = arity; j < arity; ++j) {
ir_node *const pred = get_irn_n(succ, j);
ir_node *const new_pred = get_irn_link(pred);
in[j] = pred;
if (new_pred && new_pred != pred) {
- in[--new_arity] = new_pred;
+ in[k++] = new_pred;
}
}
- set_irn_in(succ, arity * 2, in);
+ set_irn_in(succ, new_arity, in);
}
}
@@ -147,8 +147,11 @@ static void rewire_node(ir_node *const node, ir_node *const header)
assert(is_backedge(get_nodes_block(node), 1));
ir_node *const pred = get_irn_n(node, 1);
ir_node *const new_pred = get_irn_link(pred);
- assert(new_pred);
- set_irn_n(node, 1, new_pred);
+ if (new_pred) {
+ set_irn_n(node, 1, new_pred);
+ } else {
+ assert(get_irn_n(node, 0) == get_irn_n(node, 1));
+ }
ir_node **const in = ALLOCAN(ir_node *, 1);
in[0] = pred;
set_irn_in(new_node, 1, in);