On 2/13/25 5:12 AM, Vineet Gupta wrote:
On 2/13/25 14:17, Robin Dapp wrote:
Other thoughts?
The docs seem to hint TARGET_SCHED_CAN_SPECULATE_INSN is meant for stuff
we can't/don't model in the pipeline, but I have no idea how to model
the VL=0 case there.
Maybe so, but what Edwin is doing looks sensible enough.  It wouldn't be
the first time a hook got (ab)used in ways that weren't part of the
original intent.
I don't fully understand what's happening.  So the hoisting is being done
speculatively here?  And it just happens to be "bad" because that might
cause a VL=0 case.  But are we sure a lack of speculation cannot cause
such cases?

Exactly. My gut feeling w/o deep dive was this seemed like papering over the 
issue.
Perhaps, but I'm pretty confident that even if this specific situation turns out to be slightly different that the scenario I see can/will happen elsewhere.


BTW what exactly is speculative scheduling ? As in what is it actually trying to
schedule ahead ?
In simplest terms assume we have this kind of graph

    0
   / \
  1-->2


The scheduler knows how to build scheduling regions, essentially extended basic blocks. In this case we have two regions one with the blocks 0,1 the other being just block 2.

In the multi-block region 0,1 we allow insns from block 1 to speculate into block 0.

Let's assume we're on a simple 2-wide in order machine and somewhere in bb0 we there's a slot available for an insn that we couldn't fill with anything useful from bb0. In that case we may speculate an insn from bb1 into bb0 to execute "for free" in that unused slot.

That's the basic idea. It was particularly helpful for in-order cores in the past. It's dramatically less important for an out of order core since those are likely doing the speculation in hardware.

Naturally if you're using icounts for evaluation this kind of behavior is highly undesirable since that kind of evaluation says the transformation is bad, but in reality on certain designs is quite helpful.

Jeff

Reply via email to