RFR: 8280126: C2: detect and remove dead irreducible loops [v2]

Emanuel Peter epeter at openjdk.org
Thu Jan 12 10:57:17 UTC 2023


On Thu, 12 Jan 2023 08:59:41 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Also even if it do not have exit it may have entry from irreducible loop. I don't understand your statement that "it is not nested".
>
> I guess we could use the two fields available directly to the block:
> `_infinite_loop_head` and `_irreducible_loop_secondary_entry`.
> I wonder if that is really worth it, when probably in most cases those flags are not set anyway?
> Now we just have this happen:
> `block->loop()->is_irreducible()`, which goes:
> `Block::_loop -> Loop::_irreducible`
> 
> About `infinite loop`: I can improve the comment like this:
> 
> We have "lp->parent() == nullptr", which happens only for infinite loops, where no parent is attached to the loop.
> We did not find any irreducible loop from this block out to lp.
> Thus lp only has one entry, and no exit (it is infinite and reducible).
> We can always rewrite an infinite loop that is nested inside other loops:
> while(condition) { infinite_loop; }
> with an equivalent program where the infinite loop is an outermost loop that is not nested in any loop:
> while(condition) { break; } infinite_loop;
> Thus, we can understand lp as an outermost loop, and can terminate and conclude:
> this block is in no irreducible loop.
> 
> Would that be more helpful?

I replaced it with that text, also for `PhaseIdealLoop::is_in_irreducible_loop`.

-------------

PR: https://git.openjdk.org/jdk/pull/11764


More information about the hotspot-compiler-dev mailing list