Integrated: 8315088: C2: assert(wq.size() - before == EMPTY_LOOP_SIZE) failed: expect the EMPTY_LOOP_SIZE nodes of this body if empty
Roland Westrelin
roland at openjdk.org
Tue Sep 5 07:35:57 UTC 2023
On Thu, 31 Aug 2023 15:54:50 GMT, Roland Westrelin <roland at openjdk.org> wrote:
> The assert fires in code that looks for counted loops that would be
> empty if not part of a loop strip mining nest (that is some nodes in
> the the loop body are kept alive because of the safepoint in the outer
> loop, the loop would otherwise be empty). That logic starts by finding
> the set of `EMPTY_LOOP_SIZE` nodes that are core to all counted loops
> (exit test, iv phi etc) and store them in the `empty_loop_nodes`
> list.
>
> Finding the "core" nodes is performed by
> `IdealLoopTree::collect_loop_core_nodes`. It enqueues the backedge of
> the loop in `empty_loop_nodes` and then iteratively pushes inputs of
> nodes in `empty_loop_nodes` that belongs to the loop until it can't
> make progress. There should be `EMPTY_LOOP_SIZE` of those nodes.
>
> It's possible that that 2 or more loops are involved in the process:
> a node n in loop 1 could be kept alive by the safepoint of loop 2 so
> loop 2 needs to be empty for n to become dead and possibly loop 1 to
> be empty. When that happens while the logic is in the process of
> determining if loop 1 is empty, it needs to also collect the
> `EMPTY_LOOP_SIZE` nodes that make the "core" of loop 2. They are
> enqueued to the `empty_loop_nodes` list too.
>
> The failure happens when `empty_loop_nodes` already has the "core"
> nodes of loop 1 and "core" nodes for loop 2 are collected. In the
> process`IdealLoopTree::collect_loop_core_nodes` iterates on all
> `empty_loop_nodes` (loop 1 nodes included, not just starting from the
> loop 2 backedge). That's inefficient (loop 1 nodes can't help find
> nodes that belong to loop 2) and wrong because there could be an edge
> from a node in loop 1 to a node in the body of loop 2. That node in
> loop 2 is them pushed to the `empty_loop_nodes` list.
>
> The fix I propose is to only iterate over loop 2 nodes when loop 2 is
> processed.
This pull request has now been integrated.
Changeset: fe4f9002
Author: Roland Westrelin <roland at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/fe4f90021ffd44cb0af34f39d4ca0a7e44605c92
Stats: 55 lines in 2 files changed: 54 ins; 0 del; 1 mod
8315088: C2: assert(wq.size() - before == EMPTY_LOOP_SIZE) failed: expect the EMPTY_LOOP_SIZE nodes of this body if empty
Reviewed-by: thartmann, chagedorn
-------------
PR: https://git.openjdk.org/jdk/pull/15520
More information about the hotspot-compiler-dev
mailing list