- fixed signed/unsigned warning
[libfirm] / ir / opt / condeval.c
index d3b29d7..54ddc5a 100644 (file)
@@ -24,9 +24,7 @@
  * @author  Christoph Mallon, Matthias Braun
  * @version $Id$
  */
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include "iroptimize.h"
 
@@ -85,12 +83,6 @@ static ir_node *search_def_and_create_phis(ir_node *block, ir_mode *mode,
        if(is_Bad(block))
                return new_Bad();
 
-       /* already processed this block? */
-       if(irn_visited(block)) {
-               ir_node *value = (ir_node*) get_irn_link(block);
-               return value;
-       }
-
        /* the other defs can't be marked for cases where a user of the original
         * value is in the same block as the alternative definition.
         * In this case we mustn't use the alternative definition.
@@ -100,6 +92,12 @@ static ir_node *search_def_and_create_phis(ir_node *block, ir_mode *mode,
                return ssa_second_def;
        }
 
+       /* already processed this block? */
+       if(irn_visited(block)) {
+               ir_node *value = (ir_node*) get_irn_link(block);
+               return value;
+       }
+
        irg = get_irn_irg(block);
        assert(block != get_irg_start_block(irg));
 
@@ -147,6 +145,10 @@ static void construct_ssa(ir_node *orig_block, ir_node *orig_val,
        const ir_edge_t *edge;
        const ir_edge_t *next;
 
+       /* no need to do anything */
+       if (orig_val == second_val)
+               return;
+
        irg = get_irn_irg(orig_val);
        inc_irg_visited(irg);
 
@@ -409,9 +411,8 @@ static ir_node *find_const_or_confirm(condeval_env_t *env, ir_node *jump, ir_nod
 {
        ir_node *block = get_nodes_block(jump);
 
-       if (irn_visited(value))
+       if (irn_visited_else_mark(value))
                return NULL;
-       mark_irn_visited(value);
 
        if (is_Const_or_Confirm(value)) {
                if (eval_cmp(env, value) <= 0) {
@@ -474,10 +475,9 @@ static ir_node *find_candidate(condeval_env_t *env, ir_node *jump,
 {
        ir_node *block = get_nodes_block(jump);
 
-       if(irn_visited(value)) {
+       if (irn_visited_else_mark(value)) {
                return NULL;
        }
-       mark_irn_visited(value);
 
        if (is_Const_or_Confirm(value)) {
                tarval *tv = get_Const_or_Confirm_tarval(value);