+ if (be->sched_env->sel_strategy & BE_SCHED_SELECT_HEUR) {
+ int max_prio = INT_MIN;
+ int cur_prio = INT_MIN;
+ int cur_pressure = get_cur_reg_pressure(be);
+ int reg_fact, cand_reg_fact;
+
+ /* priority based selection, heuristic inspired by mueller diss */
+ foreach_nodeset(ns, irn) {
+ /* make sure that branches are scheduled last */
+ if (! arch_irn_class_is(be->sched_env->arch_env, irn, branch)) {
+ int rdiff = get_irn_reg_diff(be, irn);
+ int sign = rdiff < 0;
+ int chg = (rdiff < 0 ? -rdiff : rdiff) << PRIO_CHG_PRESS;
+
+ reg_fact = chg << cur_pressure;
+ if (reg_fact < chg)
+ reg_fact = INT_MAX - 2;
+ reg_fact = sign ? -reg_fact : reg_fact;
+
+ cur_prio = (get_irn_critical_path_len(be, irn) << PRIO_LEVEL)
+ //- (get_irn_delay(be, irn) << PRIO_LEVEL)
+ + (get_irn_num_user(be, irn) << PRIO_NUMSUCCS)
+ - (get_irn_etime(be, irn) << PRIO_TIME)
+// - ((get_irn_reg_diff(be, irn) >> PRIO_CHG_PRESS) << ((cur_pressure >> PRIO_CUR_PRESS) - 3))
+ - reg_fact
+ + (get_irn_preorder(be, irn) << PRIO_PREORD); /* high preorder means early schedule */
+ if (cur_prio > max_prio) {
+ cand = irn;
+ max_prio = cur_prio;
+ cand_reg_fact = reg_fact;
+ }
+
+ DBG((be->dbg, LEVEL_4, "checked NODE %+F\n", irn));
+ DBG((be->dbg, LEVEL_4, "\tpriority: %d\n", cur_prio));
+ DBG((be->dbg, LEVEL_4, "\tpath len: %d (%d)\n", get_irn_critical_path_len(be, irn), get_irn_critical_path_len(be, irn) << PRIO_LEVEL));
+ DBG((be->dbg, LEVEL_4, "\tdelay: %d (%d)\n", get_irn_delay(be, irn), get_irn_delay(be, irn) << PRIO_LEVEL));
+ DBG((be->dbg, LEVEL_4, "\t#user: %d (%d)\n", get_irn_num_user(be, irn), get_irn_num_user(be, irn) << PRIO_NUMSUCCS));
+ DBG((be->dbg, LEVEL_4, "\tetime: %d (%d)\n", get_irn_etime(be, irn), -(get_irn_etime(be, irn) << PRIO_TIME)));
+ DBG((be->dbg, LEVEL_4, "\tpreorder: %d (%d)\n", get_irn_preorder(be, irn), get_irn_preorder(be, irn) << PRIO_PREORD));
+ DBG((be->dbg, LEVEL_4, "\treg diff: %d (%d)\n", get_irn_reg_diff(be, irn), -cand_reg_fact));
+ DBG((be->dbg, LEVEL_4, "\tpressure: %d\n", cur_pressure));
+ }
+ }
+
+ if (cand) {
+ DBG((be->dbg, LEVEL_4, "heuristic selected %+F:\n", cand));
+ }
+ else {
+ cand = nodeset_first(ns);
+ }
+ }
+ else {
+ /* use backend selector */
+ cand = be->selector->select(be->selector_block_env, ns);
+ }
+
+ return cand;