This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix shrink-wrap bug with anticipating into loops (PR67778, PR68634)
- From: Bernd Schmidt <bschmidt at redhat dot com>
- To: Segher Boessenkool <segher at kernel dot crashing dot org>, gcc-patches at gcc dot gnu dot org
- Cc: jakub at redhat dot com
- Date: Thu, 3 Dec 2015 12:31:53 +0100
- Subject: Re: [PATCH] Fix shrink-wrap bug with anticipating into loops (PR67778, PR68634)
- Authentication-results: sourceware.org; auth=none
- References: <ebfaeba0a9c98ddf1f8ea795efc2fd3ba082fdfe dot 1449080153 dot git dot segher at kernel dot crashing dot org>
On 12/02/2015 07:21 PM, Segher Boessenkool wrote:
After shrink-wrapping has found the "tightest fit" for where to place
the prologue, it tries move it earlier (so that frame saves are run
earlier) -- but without copying any more basic blocks.
Unfortunately a candidate block we select can be inside a loop, and we
will still allow it (because the loop always exits via our previously
chosen block).
So we need to detect this situation. We can place the prologue at a
previous block PRE only if PRE dominates every block reachable from
it. This is a bit hard / expensive to compute, so instead this patch
allows a block PRE only if PRE does not post-dominate any of its
successors (other than itself).
Are the two conditions equivalent though? I'm not fully convinced. Let's
say the loop has multiple exits, then none of these exit blocks
postdominate the loop entry block, right?
I think I agree with Jakub that we don't want to do unnecessary work in
this piece of code.
/* If we can move PRO back without having to duplicate more blocks, do so.
We can move back to a block PRE if every path from PRE will eventually
- need a prologue, that is, PRO is a post-dominator of PRE. */
+ need a prologue, that is, PRO is a post-dominator of PRE. We might
+ need to duplicate PRE if there is any path from a successor of PRE back
+ to PRE, so don't allow that either (but self-loops are fine, as are any
+ other loops entirely dominated by PRE; this in general seems too
+ expensive to check for, for such an uncommon case). */
The last comment is unclear and I don't know what it wants to tell me.
Bernd