ia32: cleanup handling of 8/16bit operations
[libfirm] / ir / be / beschednormal.c
index 777bfe8..cff3a87 100644 (file)
@@ -20,7 +20,6 @@
 /**
  * @brief   Use the strong normal form theorem (though it does not hold)
  * @author  Christoph Mallon
- * @version $Id$
  */
 #include "config.h"
 
@@ -60,7 +59,6 @@ static ir_node *normal_select(void *block_env, ir_nodeset_t *ready_set)
        ir_node*    irn;
        ir_node*    next;
        ir_node*    last = NULL;
-       ir_nodeset_iterator_t iter;
 
        for (irn = inst->curr_list; irn != NULL; last = irn, irn = next) {
                next = (ir_node*)get_irn_link(irn);
@@ -76,9 +74,7 @@ static ir_node *normal_select(void *block_env, ir_nodeset_t *ready_set)
                }
        }
 
-       ir_nodeset_iterator_init(&iter, ready_set);
-       irn = ir_nodeset_iterator_next(&iter);
-       return irn;
+       return ir_nodeset_first(ready_set);
 }
 
 
@@ -288,15 +284,19 @@ static int root_cmp(const void* a, const void* b)
        const irn_cost_pair* const a1 = (const irn_cost_pair*)a;
        const irn_cost_pair* const b1 = (const irn_cost_pair*)b;
        int ret;
-       if (is_irn_forking(a1->irn)) {
+       if (is_irn_forking(a1->irn) && !is_irn_forking(b1->irn)) {
                ret = 1;
-       } else if (is_irn_forking(b1->irn)) {
+       } else if (is_irn_forking(b1->irn) && !is_irn_forking(a1->irn)) {
                ret = -1;
        } else {
                ret = b1->cost - a1->cost;
                if (ret == 0) {
                        /* place live-out nodes later */
                        ret = (count_result(a1->irn) != 0) - (count_result(b1->irn) != 0);
+                       if (ret == 0) {
+                               /* compare node idx */
+                               ret = get_irn_idx(a1->irn) - get_irn_idx(b1->irn);
+                       }
                }
        }
 #if defined NORMAL_DBG