On 10/5/2021 5:22 AM, Richard Biener wrote:
On Mon, Oct 4, 2021 at 6:29 PM Michael Matz <m...@suse.de> wrote:
Hello,

On Mon, 4 Oct 2021, Jeff Law wrote:

And just in case it got lost.  Here's the analysis on 960218-1 on visium:

We've got this going into ethread:

int f (int x)
{
   int D.1420;
   int a;

;;   basic block 2, loop depth 0, maybe hot
;;    prev block 0, next block 3, flags: (NEW, REACHABLE, VISITED)
;;    pred:       ENTRY (FALLTHRU,EXECUTABLE)
   a_4 = ~x_3(D);
   goto <bb 4>; [INV]
;;    succ:       4 (FALLTHRU,EXECUTABLE)

;;   basic block 3, loop depth 1, maybe hot
;;    prev block 2, next block 4, flags: (NEW, REACHABLE, VISITED)
;;    pred:       4 (TRUE_VALUE,EXECUTABLE)
   gl = a_1;
;;    succ:       4 (FALLTHRU,DFS_BACK,EXECUTABLE)

;;   basic block 4, loop depth 1, maybe hot
;;    prev block 3, next block 5, flags: (NEW, REACHABLE, VISITED)
;;    pred:       2 (FALLTHRU,EXECUTABLE)
;;                3 (FALLTHRU,DFS_BACK,EXECUTABLE)
   # a_1 = PHI <a_4(2), 0(3)>
   if (a_1 != 0)
     goto <bb 3>; [INV]
   else
     goto <bb 5>; [INV]
;;    succ:       3 (TRUE_VALUE,EXECUTABLE)
;;                5 (FALSE_VALUE,EXECUTABLE)

;;   basic block 5, loop depth 0, maybe hot
;;    prev block 4, next block 1, flags: (NEW, REACHABLE, VISITED)
;;    pred:       4 (FALSE_VALUE,EXECUTABLE)
   return;
;;    succ:       EXIT

}
First notice that this doesn't have an empty latch block to start with
(in fact, there is no separate latch block at all), so the loop optimizers
haven't been initialized for simple latches at this point.  Still, I would
say that even then we want to be careful with the latch edge, as putting
code onto it will most probably create a problem downstream once we _do_
want to intialize the loop optimizers for simple latches.  So, that we are
careful here is okay, we are just too careful in this specific case.
Not sure if the argument about empty or not empty latches is important...
There's a pretty obvious jump thread in there.  3->4->5.

We used to allow this, but it's currently being rejected and I'm not
sure it should.

In simplest terms we're threading from inside the loop, through the
latch to a point outside the loop.  At first glance, that seems safe.
All threadings that start inside the loop and end outside of it are OK
in principle.  Even if the path crosses the latch or the header.
I generally agree, but with one caveat.  If the latch is marked as a joiner block, then it will not be OK as that'll create multiple backedges to the top of the loop.


Jeff

Reply via email to