From: Jeff Law <law@redhat.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com
Subject: Re: [PATCH 4/5] shrink-wrap: Shrink-wrapping for separate components
Date: Wed, 28 Sep 2016 16:36:00 -0000 [thread overview]
Message-ID: <2effb66f-132a-be2d-dcd0-038709eea201@redhat.com> (raw)
In-Reply-To: <20160928090407.GH30477@gate.crashing.org>
On 09/28/2016 03:04 AM, Segher Boessenkool wrote:
>
>>> +static void
>>> +place_prologue_for_one_component (unsigned int which, basic_block head)
>>> +{
>>> + /* The block we are currently dealing with. */
>>> + basic_block bb = head;
>>> + /* Is this the first time we visit this block, i.e. have we just gone
>>> + down the tree. */
>>> + bool first_visit = true;
>>> +
>>> + /* Walk the dominator tree, visit one block per iteration of this loop.
>>> + Each basic block is visited twice: once before visiting any children
>>> + of the block, and once after visiting all of them (leaf nodes are
>>> + visited only once). As an optimization, we do not visit subtrees
>>> + that can no longer influence the prologue placement. */
>>> + for (;;)
>> Is there some reason you wrote this as a loop rather than recursion?
>> IMHO it makes this function (and spread_components) more difficult to
>> reason about than it needs to be.
>
> It would recurse a few thousand frames deep on not terribly big testcases
> (i.e. I've seen it happen). This uses a lot of stack space on some ABIs,
> and is very slow as well (this is the slowest function here by far).
> Unlimited recursion is bad.
I'm surprised the recursion was that deep. Such is life. Thanks for
clarifying. I won't object to the iterative version. :-)
>>> +/* Place code for prologues and epilogues for COMPONENTS where we can put
>>> + that code at the end of basic blocks. */
>>> +static void
>>> +emit_common_tails_for_components (sbitmap components)
>> [ Snip. ]
>>> +
>>> + /* Put the code at the end of the BB, but before any final jump. */
>>> + if (!bitmap_empty_p (epi))
>> So what if the final jump uses hard registers in one way or another? I
>> don't immediately see anything that verifies it is safe to transpose the
>> epilogue and the final jump.
>
> Whoops. Thanks for catching this.
I missed it the first time though the code too.
>
>> Conceptually want the epilogue to occur on the outgoing edge(s). But
>> you want to actually transpose the epilogue and the control flow insn so
>> that you can insert the epilogue in one place.
>
> The same problem happens with prologues, too.
Yea. I guess if a had a jump with an embedded side effect (such as movb
or addb on the PA), then transposing the control flow insn with the
prologue would be problematical as well.
>
> A cc0 target can not use separate shrink-wrapping *anyway* if any of the
> components would clobber cc0, so that is no problem here.
True, but I'd be more comfortable if we filtered out cc0 targets explicitly.
>
>> I think you need to handle the former more cleanly. The latter I'd
>> be comfortable filtering out in try_shrink_wrapping_separate.
>
> I'm thinking to not do the common tail optimisation if BB_END is a
> JUMP_INSN but not simplejump_p (or a return or a sibling call). Do
> you see any problem with that?
Seems reasonable.
Jeff
next prev parent reply other threads:[~2016-09-28 16:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 8:22 [PATCH v3 0/5] Separate shrink-wrapping Segher Boessenkool
2016-09-23 8:22 ` [PATCH 1/5] separate shrink-wrap: New command-line flag, status flag, hooks, and doc Segher Boessenkool
2016-09-26 17:02 ` Jeff Law
2016-09-23 8:22 ` [PATCH 2/5] dce: Don't dead-code delete separately wrapped restores Segher Boessenkool
2016-09-26 16:55 ` Jeff Law
2016-09-23 8:23 ` [PATCH 3/5] regrename: Don't rename restores Segher Boessenkool
2016-09-26 16:44 ` Jeff Law
2016-09-23 8:33 ` [PATCH 4/5] shrink-wrap: Shrink-wrapping for separate components Segher Boessenkool
2016-09-27 21:25 ` Jeff Law
2016-09-28 9:26 ` Segher Boessenkool
2016-09-28 16:36 ` Jeff Law [this message]
2016-09-30 10:14 ` Segher Boessenkool
[not found] ` <20160930102908.GB14933@gate.crashing.org>
2016-09-30 10:52 ` Segher Boessenkool
2016-10-10 21:21 ` Jeff Law
2016-10-10 22:23 ` Segher Boessenkool
2016-09-23 8:44 ` [PATCH 5/5] rs6000: Separate shrink-wrapping Segher Boessenkool
2016-09-26 16:39 ` Jeff Law
2016-09-26 18:16 ` David Edelsohn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2effb66f-132a-be2d-dcd0-038709eea201@redhat.com \
--to=law@redhat.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=segher@kernel.crashing.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).