+2017-12-26 Alexander Monakov <amonakov@ispras.ru>
+
+ PR rtl-optimization/83513
+ * sel-sched.c (sel_rank_for_schedule): Order by non-zero usefulness
+ before priority comparison.
+
2017-12-25 Jakub Jelinek <jakub@redhat.com>
PR target/83488
else if (control_flow_insn_p (tmp2_insn) && !control_flow_insn_p (tmp_insn))
return 1;
- /* Prefer an expr with greater priority. */
- if (EXPR_USEFULNESS (tmp) != 0 || EXPR_USEFULNESS (tmp2) != 0)
- {
- int p2 = EXPR_PRIORITY (tmp2) + EXPR_PRIORITY_ADJ (tmp2),
- p1 = EXPR_PRIORITY (tmp) + EXPR_PRIORITY_ADJ (tmp);
+ /* Prefer an expr with non-zero usefulness. */
+ int u1 = EXPR_USEFULNESS (tmp), u2 = EXPR_USEFULNESS (tmp2);
- val = p2 * EXPR_USEFULNESS (tmp2) - p1 * EXPR_USEFULNESS (tmp);
+ if (u1 == 0)
+ {
+ if (u2 == 0)
+ u1 = u2 = 1;
+ else
+ return 1;
}
- else
- val = EXPR_PRIORITY (tmp2) - EXPR_PRIORITY (tmp)
- + EXPR_PRIORITY_ADJ (tmp2) - EXPR_PRIORITY_ADJ (tmp);
+ else if (u2 == 0)
+ return -1;
+
+ /* Prefer an expr with greater priority. */
+ val = (u2 * (EXPR_PRIORITY (tmp2) + EXPR_PRIORITY_ADJ (tmp2))
+ - u1 * (EXPR_PRIORITY (tmp) + EXPR_PRIORITY_ADJ (tmp)));
if (val)
return val;