summaryrefslogtreecommitdiffhomepage
path: root/ir/opt
diff options
context:
space:
mode:
authorElias Aebi <elias.aebi@student.kit.edu>2018-04-06 10:39:44 +0200
committerJohannes Bucher <johannes.bucher2@student.kit.edu>2019-01-24 17:42:00 +0100
commitf10d4d5733d204306067676ecd2c45bcf374f4c0 (patch)
tree151497d000383eab7bcc6e3f8147148bf321adfe /ir/opt
parent0173f48c162e5bda060f4130ab489f087f6a7615 (diff)
use the link to detect backedges
Diffstat (limited to 'ir/opt')
-rw-r--r--ir/opt/loop2.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/ir/opt/loop2.c b/ir/opt/loop2.c
index da081b3..e90620f 100644
--- a/ir/opt/loop2.c
+++ b/ir/opt/loop2.c
@@ -165,16 +165,17 @@ static void rewire_node(ir_node *const node, ir_node *const header)
int const arity = get_irn_arity(node);
int new_arity = 0;
for (int i = 0; i < arity; ++i) {
- if (is_backedge(node, i)) {
+ ir_node *const pred = get_irn_n(header, i);
+ ir_node *const new_pred = get_irn_link(pred);
+ if (new_pred) {
++new_arity;
}
}
ir_node **const in = ALLOCAN(ir_node *, new_arity);
for (int i = 0, j = 0; i < arity; ++i) {
- if (is_backedge(node, i)) {
- ir_node *const pred = get_irn_n(new_node, i);
- ir_node *const new_pred = get_irn_link(pred);
- assert(new_pred);
+ ir_node *const pred = get_irn_n(header, i);
+ ir_node *const new_pred = get_irn_link(pred);
+ if (new_pred) {
// jump to the old node from outside and from the new node
set_irn_n(node, i, new_pred);
// jump to the new node only from the old node
@@ -188,15 +189,16 @@ static void rewire_node(ir_node *const node, ir_node *const header)
// phi node inside loop header
if (is_Phi(node) && get_nodes_block(node) == header) {
int const arity = get_irn_arity(node);
+ assert(arity == get_irn_arity(header));
int new_arity = 0;
for (int i = 0; i < arity; ++i) {
- if (is_backedge(get_nodes_block(node), i)) {
+ if (get_irn_link(get_irn_n(header, i))) {
++new_arity;
}
}
ir_node **const in = ALLOCAN(ir_node *, 1);
for (int i = 0, j = 0; i < arity; ++i) {
- if (is_backedge(get_nodes_block(node), i)) {
+ if (get_irn_link(get_irn_n(header, i))) {
ir_node *const pred = get_irn_n(node, i);
ir_node *const new_pred = get_irn_link(pred);
if (new_pred) {
@@ -256,6 +258,9 @@ static void duplicate_loop(ir_loop *const loop)
ir_node *const header = get_loop_header(loop);
if (header == NULL)
return;
+
+ DB((dbg, LEVEL_3, "found loop header %N\n", header));
+ irg_walk_graph(get_irn_irg(header), firm_clear_link, NULL, NULL);
size_t const n_elements = get_loop_n_elements(loop);
// step 1: duplicate blocks
@@ -299,7 +304,6 @@ void do_loop_unrolling2(ir_graph *const irg)
assure_lcssa(irg);
assure_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO | IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK);
- irg_walk_graph(irg, firm_clear_link, NULL, NULL);
duplicate_one_loop(get_irg_loop(irg), true);
ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
dump_ir_graph(irg, "loop-unrolling");