summaryrefslogtreecommitdiffhomepage
path: root/ir/opt
diff options
context:
space:
mode:
authorElias Aebi <elias.aebi@student.kit.edu>2018-01-30 10:44:56 +0100
committerJohannes Bucher <johannes.bucher2@student.kit.edu>2019-01-24 17:42:00 +0100
commit639f01caa47a564e4086eec35c1aede3dc0e06cf (patch)
treefeda71c996f4cf814e8e5568e75168ce465872fa /ir/opt
parent861e1c9546a762ad66a2ebb17ed93cb128dbddcd (diff)
implement assure_loop_lcssa
Diffstat (limited to 'ir/opt')
-rw-r--r--ir/opt/loop2.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/ir/opt/loop2.c b/ir/opt/loop2.c
index cd68a8e..b5b46e0 100644
--- a/ir/opt/loop2.c
+++ b/ir/opt/loop2.c
@@ -73,6 +73,43 @@ static void insert_phis_for_node(ir_node *const node, void *const env)
}
}
+static void insert_phis_for_node_out(ir_node *const node)
+{
+ if (irn_visited(node))
+ return;
+ unsigned int const n_outs = get_irn_n_outs(node);
+ for (unsigned int i = 0; i < n_outs; ++i) {
+ int n;
+ ir_node *const succ = get_irn_out_ex(node, i, &n);
+ insert_phis_for_edge(succ, n);
+ }
+}
+
+static void insert_phis_for_block(ir_node *const block)
+{
+ // iterate over the nodes of the block
+ unsigned int const n_outs = get_irn_n_outs(block);
+ for (unsigned int i = 0; i < n_outs; ++i) {
+ ir_node *const node = get_irn_out(block, i);
+ assert(!is_Block(node));
+ insert_phis_for_node_out(node);
+ }
+}
+
+static void insert_phis_for_loop(ir_loop *const loop)
+{
+ size_t const n_elements = get_loop_n_elements(loop);
+ for (size_t i = 0; i < n_elements; ++i) {
+ loop_element const element = get_loop_element(loop, i);
+ if (*element.kind == k_ir_node) {
+ assert(is_Block(element.node));
+ insert_phis_for_block(element.node);
+ } else if (*element.kind == k_ir_loop) {
+ insert_phis_for_loop(element.son);
+ }
+ }
+}
+
#ifdef DEBUG_libfirm
static bool is_inner_loop(ir_loop *const outer_loop, ir_loop *inner_loop)
@@ -118,6 +155,15 @@ static void assure_lcssa(ir_graph *const irg)
DEBUG_ONLY(verify_lcssa(irg);)
}
+static void assure_loop_lcssa(ir_graph *const irg, ir_loop *const loop)
+{
+ FIRM_DBG_REGISTER(dbg, "firm.opt.lcssa");
+ assure_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO | IR_GRAPH_PROPERTY_CONSISTENT_OUTS | IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
+ inc_irg_visited(irg);
+ insert_phis_for_loop(loop);
+ clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO | IR_GRAPH_PROPERTY_CONSISTENT_OUTS | IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
+}
+
void do_loop_unrolling2(ir_graph *const irg)
{
assure_lcssa(irg);