besched: Change sched_foreach_from(sched_next(x), y) to sched_foreach_after(x, y).
[libfirm] / ir / be / beschedrand.c
index da3e2f2..0705efe 100644 (file)
@@ -1,20 +1,6 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
- *
  * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
+ * Copyright (C) 2012 University of Karlsruhe.
  */
 
 /**
@@ -48,25 +34,26 @@ static ir_node *random_select(void *block_env, ir_nodeset_t *ready_set)
                }
        }
 
-       ir_node *irn;
+       ir_node *rand_node = NULL;
        if (only_branches_left) {
                /* at last: schedule branches */
-               irn = ir_nodeset_first(ready_set);
+               rand_node = ir_nodeset_first(ready_set);
        } else {
                do {
                        /* take 1 random node */
                        int n = rand() % ir_nodeset_size(ready_set);
                        int i = 0;
                        foreach_ir_nodeset(ready_set, irn, iter) {
+                               rand_node = irn;
                                if (i == n) {
                                        break;
                                }
                                ++i;
                        }
-               } while (is_cfop(irn));
+               } while (is_cfop(rand_node));
        }
 
-       return irn;
+       return rand_node;
 }
 
 static void *random_init_graph(ir_graph *irg)