In http://gcc.gnu.org/ml/gcc/2005-11/msg01163.html, Ian Lance Taylor wrote:
Either way, register elimination can cause addresses which were valid to become invalid, typically because valid offsets from the frame pointer become invalid offsets from the stack pointer. So that needs to be cleaned up somewhere.
This is not just about some requiring some cleanup somewhere. Register elimination and stack slot allocation determine the exact addresses that are used, which in turn determine what reload inheritance is possible for address reloads that are for stack slots which are close together on the stack. Getting this right is essential to avoid performance degradation on some platforms. These targets typically use LEGITIMIZE_RELOAD_ADDRESS to split out-of-range addresses into a normal form with a base address load and a memory access using this base with a small offset. On the other hand, the hard register spills appear to offer a new opportunity: we have talked about shrink-wrapping code in the past, but have never implemented this in gcc. I think that register saves/restores can be considered special cases of hard register spills. In order to do this efficiently, there would have to be some interface with the target to exploit insn sequences that can save/restore multiple registers more efficiently in bulk, .e.g load/store multiple, or auto-increment use on targets that are otherwise ACCUMULATE_OUTGOING_ARGS. On the other hand, these techniques can also help when we need to spill multiple hard registers around a tight loop.