Supposedly clauses can be formed up until vmcnt/lgkmcnt are
saturated.
The limit for vmcnt on gfx9 is pretty big, so this requires
looking ahead 64 instructions. I don't know how much of an
impact this has on compile time. Reducing it should be
conservatively correct at the cost of extra nops inserted
into unreasonably large clauses.
Another issue is this doesn't account for how some
instructions increase the counter by more than 1,
but this should be conservatively correct.
We must also not put stores in the same clause if they may write the same address. Putting stores in their own clause will trivially satisfy this requirement.
How does this code ensure multiple consecutive stores are not put in the same clause? Seems it will only break the clause if a read is before a store. How is a store before a read broken into a separate clause?
This code seems to be per single basic block? What ensures that a clause cannot straddle across basic blocks (due to fall through)? Since no checking is being done across basic blocks the conservative action is to break clauses that end a basic block.