[jdk18] RFR: 8279837: C2: assert(is_Loop()) failed: invalid node class: Region
Vladimir Kozlov
kvn at openjdk.java.net
Tue Jan 11 18:57:23 UTC 2022
On Tue, 11 Jan 2022 14:53:59 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
> In the test case, we are attempting to apply `iteration_split_impl()` to a loop head which is a `RegionNode` and not a `LoopNode`. We then fail with an assertion when attempting to cast it.
>
> This is quite an edge case. `build_loop_tree()` is initially adding a `NeverBranch` to an infinite inner loop. Afterwards, `beautify_loop()` makes progress on some other loop nest where the inner and outer loop share the same loop head. As a result, `build_loop_tree()` is called again:
> https://github.com/openjdk/jdk/blob/2bbeae3f056243a224b0bda021f16cdcbee3b3d6/src/hotspot/share/opto/loopnode.cpp#L4184-L4189
>
> Through `Root` -> `Halt` -> `CProj` -> `NeverBranch`, the infinite loop is now reachable and is built as child of `_ltree_root`. However, the `Region` is not yet a `Loop` node. This will only happen in the next iteration of loop opts when `beautify_loop()` is called again. We then fail with the assertion assuming that loop tree head nodes are always `LoopNodes`. Some more details can be found in the comments of the test.
>
> The fix is straight forward to bail out of `iteration_split_impl()` for non-`LoopNodes`. We already do a similar bailout in other optimizations like loop predication:
> https://github.com/openjdk/jdk/blob/2bbeae3f056243a224b0bda021f16cdcbee3b3d6/src/hotspot/share/opto/loopPredicate.cpp#L1427-L1430
>
> Thanks,
> Christian
Good. This reminds me similar fix I did in JDK 11u: [JDK-8268360](https://bugs.openjdk.java.net/browse/JDK-8268360)
-------------
Marked as reviewed by kvn (Reviewer).
PR: https://git.openjdk.java.net/jdk18/pull/94
More information about the hotspot-compiler-dev
mailing list