Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8279837: C2: assert(is_Loop()) failed: invalid node class: Region #7029

wants to merge 1 commit into from


Copy link

@chhagedorn chhagedorn commented Jan 11, 2022

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:

if( _ltree_root->_child->beautify_loops( this ) ) {
// Re-build loop tree!
_ltree_root->_child = NULL;

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:

if (!loop->_head->is_Loop()) {
// Could be a simple region when irreducible loops are present.
return false;



  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed


  • JDK-8279837: C2: assert(is_Loop()) failed: invalid node class: Region


Using git

Checkout this PR locally:
$ git fetch pull/7029/head:pull/7029
$ git checkout pull/7029

Update a local copy of the PR:
$ git checkout pull/7029
$ git pull pull/7029/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7029

View PR using the GUI difftool:
$ git pr show -t 7029

Using diff file

Download this PR as a diff file:

Copy link

bridgekeeper bot commented Jan 11, 2022

👋 Welcome back chagedorn! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 11, 2022
Copy link

openjdk bot commented Jan 11, 2022

@chhagedorn The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-compiler label Jan 11, 2022
Copy link

mlbridge bot commented Jan 11, 2022


Copy link
Member Author

This should actually go into JDK 18 - I'm closing this and re-open a PR for the JDK 18 fork.

@chhagedorn chhagedorn closed this Jan 11, 2022
@chhagedorn chhagedorn deleted the JDK-8279837 branch August 8, 2022 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
hotspot-compiler rfr Pull request is ready for review
1 participant