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

--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
It looks to me another one is in reload1.c, find_reg:

          if (this_cost < best_cost
              /* Among registers with equal cost, prefer caller-saved ones, or
                 use REG_ALLOC_ORDER if it is defined.  */
              || (this_cost == best_cost
#ifdef REG_ALLOC_ORDER
                  && (inv_reg_alloc_order[regno]
                      < inv_reg_alloc_order[best_reg])
#else
                  && crtl->abi->clobbers_full_reg_p (regno)
                  && !crtl->abi->clobbers_full_reg_p (best_reg)
#endif
                  ))
            {
              best_reg = regno;
              best_cost = this_cost;
            }

According to the comment, REG_ALLOC_ORDER has to be defined to use preferences.

As mentioned by Richard in Comment #2, x86 defines ADJUST_REG_ALLOC_ORDER,
where the real allocation order is computed. But the documentation doesn't
mention that REG_ALLOC_ORDER also needs to be defined. It explicitly says even:

     The macro body should not assume anything about the contents of
     'reg_alloc_order' before execution of the macro.

But, we want to use the order from reg_alloc_order, so x86 should define
HONOR_REG_ALLOC_ORDER:

 -- Macro: HONOR_REG_ALLOC_ORDER
     Normally, IRA tries to estimate the costs for saving a register in
     the prologue and restoring it in the epilogue.  This discourages it
     from using call-saved registers.  If a machine wants to ensure that
     IRA allocates registers in the order given by REG_ALLOC_ORDER even
     if some call-saved registers appear earlier than call-used ones,
     then define this macro as a C expression to nonzero.  Default is 0.

But...

x86_order_regs_for_local_alloc lists general call_used_or_fixed_regs first, so
it should not matter anyway as far as call_used regs are concerned.

Reply via email to