public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* How do I delete redundant prologue/epilogue instructions?
@ 2005-08-16 15:10 Daniel Towner
  2005-08-17 19:13 ` James E Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Towner @ 2005-08-16 15:10 UTC (permalink / raw)
  To: gcc

Hi all,

I'm trying to overcome an optimisation problem in my port of gcc. When 
the prologue and epilogue are generated as RTL lists, the compiler 
notices that certain registers are live, and emits save/restore 
sequences for them, with the appropriate stack adjustments. Later on, 
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.

How do I delete these redundant instructions? Can anyone point me at 
another port which solves this problem?

thanks,

dan.

============================================================================
Daniel Towner
picoChip Designs Ltd., Riverside Buildings, 108, Walcot Street, BATH,
BA1 5BG
daniel.towner@picochip.com
07786 702589 


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How do I delete redundant prologue/epilogue instructions?
  2005-08-16 15:10 How do I delete redundant prologue/epilogue instructions? Daniel Towner
@ 2005-08-17 19:13 ` James E Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: James E Wilson @ 2005-08-17 19:13 UTC (permalink / raw)
  To: Daniel Towner; +Cc: gcc

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-08-17 19:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-16 15:10 How do I delete redundant prologue/epilogue instructions? Daniel Towner
2005-08-17 19:13 ` James E Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).