Adapted some issues noticed during removal of unused variables.
[libfirm] / ir / opt / loop.c
index a731042..8bc39fa 100644 (file)
@@ -378,7 +378,7 @@ static ir_node *search_def_and_create_phis(ir_node *block, ir_mode *mode, int fi
 {
        int i;
        int n_cfgpreds;
-       ir_graph *irg;
+       ir_graph *irg = get_irn_irg(block);
        ir_node *phi;
        ir_node **in;
 
@@ -388,7 +388,7 @@ static ir_node *search_def_and_create_phis(ir_node *block, ir_mode *mode, int fi
         * Dead and bad blocks. */
        if (get_irn_arity(block) < 1 || is_Bad(block)) {
                DB((dbg, LEVEL_5, "ssa bad %N\n", block));
-               return new_Bad();
+               return new_r_Bad(irg, mode);
        }
 
        if (block == ssa_second_def_block && !first) {
@@ -403,7 +403,6 @@ static ir_node *search_def_and_create_phis(ir_node *block, ir_mode *mode, int fi
                return value;
        }
 
-       irg = get_irn_irg(block);
        assert(block != get_irg_start_block(irg));
 
        /* a Block with only 1 predecessor needs no Phi */
@@ -956,7 +955,7 @@ static void get_head_outs(ir_node *node, void *env)
  * (Some blocks need to be removed once again.)
  * Returns 1 if the given block belongs to the condition chain.
  */
-static unsigned find_condition_chain(ir_node *block)
+static void find_condition_chain(ir_node *block)
 {
        const    ir_edge_t *edge;
        unsigned mark = 0;
@@ -979,7 +978,7 @@ static unsigned find_condition_chain(ir_node *block)
         * continuing with another subtree. */
        if (loop_info.cc_size + nodes_n > opt_params.max_cc_size) {
                set_Block_mark(block, 0);
-               return 0;
+               return;
        }
 
        /* Check if block only has a jmp instruction. */
@@ -1042,8 +1041,6 @@ static unsigned find_condition_chain(ir_node *block)
                if (is_in_loop(src) && ! irn_visited(src))
                        find_condition_chain(src);
        }
-
-       return mark;
 }
 
 /**
@@ -1287,7 +1284,6 @@ static void loop_inversion(void)
        int      depth_adaption = opt_params.depth_adaption;
 
        unsigned do_inversion = 1;
-       unsigned has_cc = 0;
 
        /* Depth of 0 is the procedure and 1 a topmost loop. */
        loop_depth = get_loop_depth(cur_loop) - 1;
@@ -1349,7 +1345,7 @@ static void loop_inversion(void)
        /* Search for condition chains and temporarily save the blocks in an array. */
        cc_blocks = NEW_ARR_F(ir_node *, 0);
        inc_irg_visited(current_ir_graph);
-       has_cc = find_condition_chain(loop_head);
+       find_condition_chain(loop_head);
 
        unmark_not_allowed_cc_blocks();
        DEL_ARR_F(cc_blocks);
@@ -1395,10 +1391,6 @@ static void loop_inversion(void)
 
                /* Duplicated blocks changed doms */
                set_irg_doms_inconsistent(current_ir_graph);
-               /* Loop content changed */
-               set_irg_loopinfo_inconsistent(current_ir_graph);
-               /* TODO are they? Depends on set_irn_in and set_irn_n exchange and new_node. */
-               set_irg_outs_inconsistent(current_ir_graph);
 
                count_stats(stats.inverted);
        }
@@ -2146,7 +2138,7 @@ static unsigned get_unroll_decision_invariant(void)
 {
 
        ir_node   *projres, *loop_condition, *iteration_path;
-       unsigned   success, is_latest_val;
+       unsigned   success;
        ir_tarval *step_tar;
        ir_mode   *mode;
 
@@ -2175,9 +2167,6 @@ static unsigned get_unroll_decision_invariant(void)
         * Until now we only have end_val. */
        if (is_Add(iteration_path) || is_Sub(iteration_path)) {
 
-               /* We test against the latest value of the iv. */
-               is_latest_val = 1;
-
                loop_info.add = iteration_path;
                DB((dbg, LEVEL_4, "Case 1: Got add %N (maybe not sane)\n", loop_info.add));
 
@@ -2204,9 +2193,6 @@ static unsigned get_unroll_decision_invariant(void)
        } else if (is_Phi(iteration_path)) {
                ir_node *new_iteration_phi;
 
-               /* We compare with the value the iv had entering this run. */
-               is_latest_val = 0;
-
                loop_info.iteration_phi = iteration_path;
                DB((dbg, LEVEL_4, "Case 2: Got phi %N\n", loop_info.iteration_phi));
 
@@ -2633,9 +2619,6 @@ static void unroll_loop(void)
                        count_stats(stats.invariant_unroll);
 
                set_irg_doms_inconsistent(current_ir_graph);
-               set_irg_loopinfo_inconsistent(current_ir_graph);
-               /* TODO is it? */
-               set_irg_outs_inconsistent(current_ir_graph);
 
                DEL_ARR_F(loop_entries);
        }