https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110071

            Bug ID: 110071
           Summary: improve_allocation() routine should consider
                    save/restore cost of callee-save registers
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jskumari at gcc dot gnu.org
  Target Milestone: ---

For the following test:

long
foo (long i, long cond)
{
  if (cond)
    bar ();
  return i+1;
}

Input RTL to IRA:

BB2:
  set r123, r4
  set r122, r3
  set r120, compare(r123, 0)
  set r118, r122
  if r120 jump BB4 else jump BB3
BB3:
  call bar()
BB4:
  set r3, r118+1
  return r3

IRA assigns r31 to r118.
Since r31 is a callee save register in powerpc, we need to generate
spill/restore code.

This assignment of r31 to r118 causes shrink wrap to fail for this test.
Since r31 is assigned to r118, BB2 requires a prolog and shrink wrap fails.

In the IRA pass, after graph coloring, r118 gets assigned to r3.
The routine improve_allocation() is called after graph coloring. This routine
changes the assignment of r118 to r31.

In improve_allocation() routine, IRA checks for each allocno if spilling any
conflicting allocnos can improve the allocation of this allocno. This routine
computes the cost improvement for usage of each profitable hard register for a
given allocno.

The existing code in improve_allocation() does not consider the save/restore
costs of callee save registers while computing the cost improvement.

This bug is for adding save/restore costs while computing cost improvement.

Save/restore costs should be considered only for the first assignment of a
callee save register. Subsequent assignments of the same register do not need
to consider this cost.

Reply via email to