This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How do I delete redundant prologue/epilogue instructions?


Daniel Towner wrote:
> register renaming is able to change the registers used by the function
> from callee-save to caller-save, removing any need for the
> save/restore/stack adjust code in the prologue/epilogue. However, the
> instructions which perform these operations are still emitted.

I doubt that any port does this optimization.  You would have to redo
the bulk of reload: register elimination, assigning stack slot
addresses, recomputing frame size and register save offsets, etc.  Gcc
isn't set up to do this.

In the simplest case, if you have no locals, no frame pointer, no
alloca, no outgoing args on the stack, etc, then a simple RTL scan of
the function may prove that SP/FP/AP are never used, allowing us to
remove code in the prologue and epilogue.  However, I'm skeptical that
this would occur often enough to be useful.  And it would require some
target dependent code to figure out how to do the rewrites, which may
make this complicated.

It is probably easier to try to avoid this situation, by getting better
register allocation earlier.  Make sure that the caller-save registers
occur before the callee-save registers in REG_ALLOC_ORDER.  Verify that
the caller-save.c code which is used in reload is working for your
target.  We could try moving some of the regrename optimizations to
before reload.
-- 
Jim Wilson, GNU Tools Support, http://www.specifix.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]