Analyzing code generated for PPC with LRA, I found that sometimes call-saved registers are overused. It creates long prologs/epilogs. The following patch fixes it.

The problem was in that BB frequency might be zero.

Committed to trunk as rev. 198792.

The same patch was committed into lra-mike branch.

2013-05-10  Vladimir Makarov  <vmaka...@redhat.com>

        * lra-assigns.c (find_hard_regno_for): Add 1 to the cost of call
        saved registers.

Index: lra-assigns.c
===================================================================
--- lra-assigns.c       (revision 198780)
+++ lra-assigns.c       (working copy)
@@ -598,7 +598,7 @@ find_hard_regno_for (int regno, int *cos
                && ! df_regs_ever_live_p (hard_regno + j))
              /* It needs save restore.  */
              hard_regno_costs[hard_regno]
-               += 2 * ENTRY_BLOCK_PTR->next_bb->frequency;
+               += 2 * ENTRY_BLOCK_PTR->next_bb->frequency + 1;
          priority = targetm.register_priority (hard_regno);
if (best_hard_regno < 0 || hard_regno_costs[hard_regno] < best_cost
              || (hard_regno_costs[hard_regno] == best_cost

Reply via email to