public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Shrink-wrapping: Introduction
@ 2011-03-23 14:44 Bernd Schmidt
  2011-03-23 14:46 ` [PATCH 1/6] Disallow predicating the prologue Bernd Schmidt
                   ` (5 more replies)
  0 siblings, 6 replies; 73+ messages in thread
From: Bernd Schmidt @ 2011-03-23 14:44 UTC (permalink / raw)
  To: GCC Patches

I'll be posting a series of patches that add an implementation of
shrink-wrapping to gcc. I've used the algorithm in Muchnick's book as a
guideline, but ended up with an implementation that is somewhat more
conservative.

One of my goals was to reuse the existing prologue/epilogue
infrastructure as much as possible so that it is relatively easy to add
shrink-wrapping capability to a new port, rather than having to rewrite
prologue/epilogue generation for each. This implies that we still only
generate one prologue per function, rather than saving individual
registers at exactly the location where it becomes necessary. Still,
this is good enough to detect and optimize many early-exit cases.

There's a new comment at the top of thread_prologue_and_epilogue_insns
which describes the algorithm in some detail.

For now, the targets that can make use of this are ARM, MIPS and i386.
This turned out to be a fortunate choice, as these cover a large range
of situations. ARM has conditional return instructions, and requires a
distinction between return (which may pop lots of registers) and
simple_return (which just branches). MIPS has delay slots, so making it
work required fixing up reorg.c for the JUMP_LABEL changes.

One of the nastiest problems I ran into is that various RTL-level CFG
functions interpret a branch target of NULL to be the exit block, and
create branches using "return". This needed surgery to distinguish
between return and simple_return exits. JUMP_LABEL is now set and
maintained for return jumps.

A possible future enhancement is to add a targetm.gen_epilogue hook,
rather than using instruction patterns, and use that to pass information
about the set of registers that need to be saved. Epilogues for
tail-calls can be generated in multiple places, and it isn't always
necessary to restore the entire set of registers.

The patch has been in our local tree as well as the Linaro gcc tree for
a while now. That hasn't entirely been without pain, but most of the
issues we had should be ironed out by now. For this submission, I've
rested the patch (in some cases slightly earlier versions) on arm-linux,
mips64-elf and i686-linux (the latter including bootstraps).


Bernd

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

end of thread, other threads:[~2011-08-27 19:35 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-23 14:44 Shrink-wrapping: Introduction Bernd Schmidt
2011-03-23 14:46 ` [PATCH 1/6] Disallow predicating the prologue Bernd Schmidt
2011-03-31 13:20   ` Jeff Law
2011-04-01 18:59   ` H.J. Lu
2011-04-01 21:08     ` Bernd Schmidt
2011-03-23 14:48 ` [PATCH 2/6] Unique return rtx Bernd Schmidt
2011-03-31 13:23   ` Jeff Law
2011-05-03 11:54     ` Bernd Schmidt
2011-03-23 14:51 ` [PATCH 3/6] Allow jumps in epilogues Bernd Schmidt
2011-03-23 16:46   ` Richard Henderson
2011-03-23 16:49     ` Bernd Schmidt
2011-03-23 17:19       ` Richard Henderson
2011-03-23 17:24         ` Bernd Schmidt
2011-03-23 17:27           ` Richard Henderson
2011-03-24 10:30             ` Bernd Schmidt
2011-03-25 17:51         ` Bernd Schmidt
2011-03-26  5:33           ` Richard Henderson
2011-03-31 20:09             ` Bernd Schmidt
2011-03-31 21:51               ` Richard Henderson
2011-03-31 22:36                 ` Bernd Schmidt
2011-03-31 23:57                   ` Richard Henderson
2011-04-05 21:59                 ` Bernd Schmidt
2011-04-11 17:10                   ` Richard Henderson
2011-04-13 14:16                     ` Bernd Schmidt
2011-04-13 15:14                       ` Bernd Schmidt
2011-04-13 15:16                       ` Bernd Schmidt
2011-04-13 15:17                       ` Bernd Schmidt
2011-04-13 15:28                     ` Bernd Schmidt
2011-04-13 14:44                       ` Richard Henderson
2011-04-13 14:54                         ` Jakub Jelinek
2011-04-15 16:29                       ` Bernd Schmidt
2011-03-23 14:56 ` [PATCH 4/6] Shrink-wrapping Bernd Schmidt
2011-07-07 14:51   ` Richard Sandiford
2011-07-07 15:40     ` Bernd Schmidt
2011-07-07 17:00       ` Paul Koning
2011-07-07 17:02         ` Jeff Law
2011-07-07 17:05           ` Paul Koning
2011-07-07 17:08             ` Jeff Law
2011-07-07 17:30             ` Bernd Schmidt
2011-07-08 22:59             ` [pdp11] Emit prologue as rtl Richard Henderson
2011-07-09 13:46               ` Paul Koning
2011-07-09 16:53                 ` Richard Henderson
2011-07-07 15:57     ` [PATCH 4/6] Shrink-wrapping Richard Earnshaw
2011-07-07 20:19       ` Richard Sandiford
2011-07-08  8:30         ` Richard Earnshaw
2011-07-08 13:57         ` Bernd Schmidt
2011-07-11 11:24           ` Richard Sandiford
2011-07-11 11:42             ` Bernd Schmidt
2011-07-21  3:57     ` Bernd Schmidt
2011-07-21 11:25       ` Richard Sandiford
2011-07-28 11:48         ` Bernd Schmidt
2011-07-28 12:45           ` Richard Sandiford
2011-07-28 23:30           ` Richard Earnshaw
2011-07-29 12:40             ` Bernd Schmidt
2011-08-03 10:42           ` Alan Modra
2011-08-03 11:19             ` Bernd Schmidt
2011-08-02  8:40     ` Bernd Schmidt
2011-08-03 15:39       ` Richard Sandiford
2011-08-24 19:23         ` Bernd Schmidt
2011-08-24 20:48           ` Richard Sandiford
2011-08-24 20:55             ` Bernd Schmidt
2011-08-26 14:49               ` Ramana Radhakrishnan
2011-08-26 14:58                 ` Bernd Schmidt
2011-08-26 15:06                   ` Ramana Radhakrishnan
2011-08-28 10:58           ` H.J. Lu
2011-07-07 21:41   ` Michael Hope
2011-03-23 14:56 ` [PATCH 5/6] Generate more shrink-wrapping opportunities Bernd Schmidt
2011-03-23 15:03   ` Jeff Law
2011-03-23 15:05     ` Bernd Schmidt
2011-03-23 15:18       ` Jeff Law
2011-03-31 13:26   ` Jeff Law
2011-03-31 13:34     ` Bernd Schmidt
2011-03-23 14:57 ` [PATCH 6/6] A testcase Bernd Schmidt

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).