Combo: Ensure split by partition for Phi nodes.
[libfirm] / ir / opt / ifconv.c
index 78184ee..d56b723 100644 (file)
@@ -21,7 +21,6 @@
  * @file    ir/opt/ifconv.c
  * @brief   If conversion
  * @author  Christoph Mallon
- * @version $Id$
  */
 #include "config.h"
 
@@ -52,7 +51,7 @@ typedef struct walker_env {
        bool                   changed; /**< Set if the graph was changed. */
 } walker_env;
 
-DEBUG_ONLY(static firm_dbg_module_t *dbg);
+DEBUG_ONLY(static firm_dbg_module_t *dbg;)
 
 /**
  * Returns non-zero if a Block can be emptied.
@@ -334,7 +333,11 @@ restart:
                                                mux_true  = get_Phi_pred(p, i);
                                                mux_false = get_Phi_pred(p, j);
                                        }
-                                       if (!env->allow_ifconv(sel, mux_false, mux_true)) {
+                                       if (mux_true == mux_false)
+                                               continue;
+                                       ir_mode *mode = get_irn_mode(mux_true);
+                                       if (mode == mode_M
+                                               || !env->allow_ifconv(sel, mux_false, mux_true)) {
                                                supported = false;
                                                break;
                                        }
@@ -469,6 +472,12 @@ void opt_if_conv(ir_graph *irg)
        walker_env            env;
        const backend_params *be_params = be_get_backend_param();
 
+       assure_irg_properties(irg,
+               IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES
+               | IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE
+               | IR_GRAPH_PROPERTY_NO_BADS
+               | IR_GRAPH_PROPERTY_ONE_RETURN);
+
        /* get the parameters */
        env.allow_ifconv = be_params->allow_ifconv;
        env.changed      = false;
@@ -477,11 +486,6 @@ void opt_if_conv(ir_graph *irg)
 
        DB((dbg, LEVEL_1, "Running if-conversion on %+F\n", irg));
 
-       env.changed |= remove_bads(irg);
-
-       normalize_one_return(irg);
-       remove_critical_cf_edges(irg);
-
        compute_cdep(irg);
 
        ir_reserve_resources(irg, IR_RESOURCE_BLOCK_MARK | IR_RESOURCE_PHI_LIST);
@@ -494,13 +498,13 @@ void opt_if_conv(ir_graph *irg)
 
        if (env.changed) {
                local_optimize_graph(irg);
-
-               /* graph has changed, invalidate analysis info */
-               set_irg_extblk_inconsistent(irg);
-               set_irg_doms_inconsistent(irg);
        }
 
        free_cdep(irg);
+
+       confirm_irg_properties(irg,
+               IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES
+               | IR_GRAPH_PROPERTY_ONE_RETURN);
 }
 
 ir_graph_pass_t *opt_if_conv_pass(const char *name)