besched: Change sched_foreach_reverse_from(sched_prev(x), y) to sched_foreach_reverse...
authorChristoph Mallon <christoph.mallon@gmx.de>
Thu, 13 Dec 2012 20:11:21 +0000 (21:11 +0100)
committerChristoph Mallon <christoph.mallon@gmx.de>
Fri, 14 Dec 2012 23:06:58 +0000 (00:06 +0100)
ir/be/belive.c
ir/be/belower.c
ir/be/beprefalloc.c
ir/be/besched.h
ir/be/ia32/ia32_optimize.c
ir/be/sparc/sparc_emitter.c
ir/be/sparc/sparc_finish.c

index 4177813..a381fd5 100644 (file)
@@ -452,7 +452,7 @@ void be_liveness_end_of_block(const be_lv_t *lv,
 
 void be_liveness_nodes_live_before(be_lv_t const *const lv, arch_register_class_t const *const cls, ir_node const *const pos, ir_nodeset_t *const live)
 {
-       ir_node const *const bl = get_nodes_block(pos);
+       ir_node *const bl = get_nodes_block(pos);
        be_liveness_end_of_block(lv, cls, bl, live);
        sched_foreach_reverse(bl, irn) {
                be_liveness_transfer(cls, irn, live);
index 655d3ce..5354b7f 100644 (file)
@@ -833,7 +833,7 @@ static int push_through_perm(ir_node *perm)
         * the former dead operand would be live now at the point of
         * the Perm, increasing the register pressure by one.
         */
-       sched_foreach_reverse_from(sched_prev(perm), irn) {
+       sched_foreach_reverse_before(perm, irn) {
                be_foreach_use(irn, cls, in_req_, op, op_req_,
                        if (!be_values_interfere(lv, op, one_proj)) {
                                frontier = irn;
index d65455a..3c6cf50 100644 (file)
@@ -381,26 +381,20 @@ static void create_congruence_class(ir_node *block, void *data)
        be_liveness_end_of_block(lv, cls, block, &live_nodes);
 
        /* check should be same constraints */
-       ir_node *last_phi = NULL;
        sched_foreach_reverse(block, node) {
-               if (is_Phi(node)) {
-                       last_phi = node;
+               if (is_Phi(node))
                        break;
-               }
 
                be_foreach_definition(node, cls, value, req,
                        congruence_def(&live_nodes, value, req);
                );
                be_liveness_transfer(cls, node, &live_nodes);
        }
-       if (!last_phi) {
-               ir_nodeset_destroy(&live_nodes);
-               return;
-       }
 
        /* check phi congruence classes */
-       sched_foreach_reverse_from(last_phi, phi) {
-               assert(is_Phi(phi));
+       sched_foreach(block, phi) {
+               if (!is_Phi(phi))
+                       break;
 
                if (!arch_irn_consider_in_reg_alloc(cls, phi))
                        continue;
index 6451ab0..7b21400 100644 (file)
@@ -159,8 +159,8 @@ static inline bool sched_comes_after(const ir_node *n1, const ir_node *n2)
 #define sched_foreach_after(after, irn) \
        for (ir_node *irn = (after); !sched_is_end(irn = sched_next(irn));)
 
-#define sched_foreach_reverse_from(from, irn) \
-  for (ir_node *irn = from; !sched_is_begin(irn); irn = sched_prev(irn))
+#define sched_foreach_reverse_before(before, irn) \
+       for (ir_node *irn = (before); !sched_is_begin(irn = sched_prev(irn));)
 
 /**
  * A shorthand macro for iterating over a schedule.
@@ -176,7 +176,7 @@ static inline bool sched_comes_after(const ir_node *n1, const ir_node *n2)
  * @param irn A ir node pointer used as an iterator.
  */
 #define sched_foreach_reverse(block,irn) \
-  sched_foreach_reverse_from(sched_last(block), irn)
+       sched_foreach_reverse_before((assert(is_Block(block)), block), irn)
 
 /**
  * Type for a function scheduling a graph
index 1b07593..b934698 100644 (file)
@@ -330,11 +330,8 @@ static void peephole_ia32_Return(ir_node *node)
                return;
 
        /* check if this return is the first on the block */
-       sched_foreach_reverse_from(node, irn) {
+       sched_foreach_reverse_before(node, irn) {
                switch (get_irn_opcode(irn)) {
-               case beo_Return:
-                       /* the return node itself, ignore */
-                       continue;
                case iro_Start:
                case beo_Start:
                        /* ignore no code generated */
index 8ac088b..71ed341 100644 (file)
@@ -482,7 +482,7 @@ static ir_node *pick_delay_slot_for(ir_node *node)
        }
 
        unsigned tries = 0;
-       sched_foreach_reverse_from(sched_prev(node), schedpoint) {
+       sched_foreach_reverse_before(node, schedpoint) {
                if (has_delay_slot(schedpoint))
                        break;
                if (tries++ >= PICK_DELAY_SLOT_MAX_DISTANCE)
index e30e550..ce762c4 100644 (file)
@@ -557,7 +557,7 @@ static void peephole_sparc_RestoreZero(ir_node *node)
 static void finish_sparc_Return(ir_node *node)
 {
        /* Ensure that the restore is directly before the return. */
-       sched_foreach_reverse_from(sched_prev(node), restore) {
+       sched_foreach_reverse_before(node, restore) {
                if (is_sparc_Restore(restore) || is_sparc_RestoreZero(restore)) {
                        sched_remove(restore);
                        sched_add_before(node, restore);