Simplify x87_dump_stack().
[libfirm] / ir / opt / ifconv.c
index 87cb43d..d56b723 100644 (file)
@@ -21,7 +21,6 @@
  * @file    ir/opt/ifconv.c
  * @brief   If conversion
  * @author  Christoph Mallon
- * @version $Id$
  */
 #include "config.h"
 
@@ -40,7 +39,6 @@
 #include "array_t.h"
 #include "irpass_t.h"
 #include "be.h"
-#include "opt_manage.h"
 
 #include "irdump.h"
 #include "debug.h"
@@ -53,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.
@@ -335,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;
                                        }
@@ -465,11 +467,17 @@ static void collect_phis(ir_node *node, void *env)
        }
 }
 
-static ir_graph_state_t do_ifconv(ir_graph *irg)
+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;
@@ -494,18 +502,9 @@ static ir_graph_state_t do_ifconv(ir_graph *irg)
 
        free_cdep(irg);
 
-       return IR_GRAPH_STATE_NO_CRITICAL_EDGES | IR_GRAPH_STATE_ONE_RETURN;
-}
-
-optdesc_t opt_ifconv = {
-       "if-conversion",
-       IR_GRAPH_STATE_NO_CRITICAL_EDGES | IR_GRAPH_STATE_NO_UNREACHABLE_BLOCKS | IR_GRAPH_STATE_NO_BAD_BLOCKS | IR_GRAPH_STATE_ONE_RETURN,
-       do_ifconv,
-};
-
-void opt_if_conv(ir_graph *irg)
-{
-       perform_irg_optimization(irg, &opt_ifconv);
+       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)