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

8323154: C2: assert(cmp != nullptr && cmp->Opcode() == Op_Cmp(bt)) failed: no exit test #17459

Closed
wants to merge 1 commit into from

Conversation

chhagedorn
Copy link
Member

@chhagedorn chhagedorn commented Jan 17, 2024

This bug is very similar to JDK-8314191 but with long counted loops instead of int counted loops and a with a different manifestation.

The original problem was that JDK-8276162 added transformations for CmpI nodes to use CmpU nodes instead. The transformations were also applied for CmpI nodes of counted loop exit checks which messed pattern matching up. JDK-8314191 and the follow-up fix JDK-8316719 fixed this but only for CountedLoopNodeEndNodes. The newly added is_cloop_condition() method only checks for is_CountedLoopEnd() (int counted loops) instead of is_BaseCountedLoopEnd() (also includes long counted loop). This patch fixes this.

I've had a closer look at other uses of is_CountedLoop* and found that

static bool is_cloop_increment(Node* inc) {
precond(inc->Opcode() == Op_AddI || inc->Opcode() == Op_AddL);
if (!inc->in(1)->is_Phi()) {
return false;
}
const PhiNode* phi = inc->in(1)->as_Phi();
if (!phi->region()->is_CountedLoop()) {
return false;
}
return inc == phi->region()->as_CountedLoop()->incr();
}

and
static bool is_cloop_condition(BoolNode* bol) {
for (DUIterator_Fast imax, i = bol->fast_outs(imax); i < imax; i++) {
Node* out = bol->fast_out(i);
if (out->is_CountedLoopEnd()) {
return true;
}
}
return false;
}

should probably also use the BaseCountedLoop* versions. These methods are used in ok_to_convert() which is used in several places. They try to prevent transformations involving the iv and the increment node of a counted loop to save registers. However, these transformations are still applied before a loop is transformed to a counted loop. This raises the question whether these bailouts should be extended to also work before loop opts. Since this code has been around for such a long time, it would also be interesting to see, if it's still beneficial to block these optimizations in general. If so, it might be good if we could add some IR tests to prove that.

There are more places where we try to prevent such transformations but again only if we already have a counted loop. For example:

// Convert "(x+1)+y" into "(x+y)+1". Push constants down the expression tree.
if (add1_op == this_op && !con_right) {
Node *a12 = add1->in(2);
const Type *t12 = phase->type( a12 );
if (t12->singleton() && t12 != Type::TOP && (add1 != add1->in(1)) &&
!(add1->in(1)->is_Phi() && (add1->in(1)->as_Phi()->is_tripcount(T_INT) || add1->in(1)->as_Phi()->is_tripcount(T_LONG)))) {
assert(add1->in(1) != this, "dead loop in AddNode::Ideal");
add2 = add1->clone();
add2->set_req(2, in(2));
add2 = phase->transform(add2);
set_req_X(1, add2, phase);
set_req_X(2, a12, phase);
progress = this;
add2 = a12;
}
}

or
// Convert "x+(y+1)" into "(x+y)+1". Push constants down the expression tree.
int add2_op = add2->Opcode();
if (add2_op == this_op && !con_left) {
Node *a22 = add2->in(2);
const Type *t22 = phase->type( a22 );
if (t22->singleton() && t22 != Type::TOP && (add2 != add2->in(1)) &&
!(add2->in(1)->is_Phi() && (add2->in(1)->as_Phi()->is_tripcount(T_INT) || add2->in(1)->as_Phi()->is_tripcount(T_LONG)))) {
assert(add2->in(1) != this, "dead loop in AddNode::Ideal");
Node *addx = add2->clone();
addx->set_req(1, in(1));
addx->set_req(2, add2->in(1));
addx = phase->transform(addx);
set_req_X(1, addx, phase);
set_req_X(2, a22, phase);
progress = this;
}
}

It might be a good idea to revisit all of these bailouts in general and check if it's still beneficial to have them around and if they should be extended to also work before loop opts.

I suggest to do this investigation together with fixing CountedLoop* -> BaseCountedLoop* in the methods used in ok_to_convert() in a separate RFE.

Thanks,
Christian


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8323154: C2: assert(cmp != nullptr && cmp->Opcode() == Op_Cmp(bt)) failed: no exit test (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17459/head:pull/17459
$ git checkout pull/17459

Update a local copy of the PR:
$ git checkout pull/17459
$ git pull https://git.openjdk.org/jdk.git pull/17459/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17459

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17459.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 17, 2024

👋 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 17, 2024
@openjdk
Copy link

openjdk bot commented Jan 17, 2024

@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 hotspot-compiler-dev@openjdk.org label Jan 17, 2024
@mlbridge
Copy link

mlbridge bot commented Jan 17, 2024

Webrevs

Copy link
Contributor

@rwestrel rwestrel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@openjdk
Copy link

openjdk bot commented Jan 17, 2024

@chhagedorn This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8323154: C2: assert(cmp != nullptr && cmp->Opcode() == Op_Cmp(bt)) failed: no exit test

Reviewed-by: roland, thartmann, qamai

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 50 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 17, 2024
@chhagedorn
Copy link
Member Author

Thanks Roland for your review!

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me too.

I suggest to do this investigation together with fixing CountedLoop* -> BaseCountedLoop* in the methods used in ok_to_convert() in a separate RFE.

Makes sense.

Copy link
Member

@merykitty merykitty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for fixing this.

@chhagedorn
Copy link
Member Author

Thanks Tobias and Quan for your reviews!

I've filed JDK-8323968 to follow up on the mentioned bailouts.

@chhagedorn
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jan 19, 2024

Going to push as commit 6997bfc.
Since your change was applied there have been 82 commits pushed to the master branch:

  • 16be388: 8322383: G1: Only preserve marks on objects that are actually moved
  • 0081d8c: 8324147: Serial: Remove generation::compute_new_size
  • 5f71419: 8322366: Add IEEE rounding mode corruption check to JNI checks
  • 0533022: 8222719: libperfstat on AIX - cleanup old API versions
  • 05dad67: 8295804: javax/swing/JFileChooser/JFileChooserSetLocationTest.java failed with "setLocation() is not working properly"
  • 9efdd24: 8324053: Use the blessed modifier order for sealed in java.base
  • 81df265: 8320458: Improve structural navigation in API documentation
  • a6c0b10: 8323684: TypeMirror.{getAnnotationsByType, getAnnotation} return uninformative results
  • 5c874c1: 8324161: validate-source fails after JDK-8275338
  • b6233c3: 8321925: sun/security/mscapi/KeytoolChangeAlias.java fails with "Alias <246810> does not exist"
  • ... and 72 more: https://git.openjdk.org/jdk/compare/922f8e44eed74b79a76a3628ebd0bca144e28091...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 19, 2024
@openjdk openjdk bot closed this Jan 19, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 19, 2024
@openjdk
Copy link

openjdk bot commented Jan 19, 2024

@chhagedorn Pushed as commit 6997bfc.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@TobiHartmann
Copy link
Member

/backport jdk22u

@openjdk
Copy link

openjdk bot commented Feb 28, 2024

@TobiHartmann the backport was successfully created on the branch backport-TobiHartmann-6997bfc6 in my personal fork of openjdk/jdk22u. To create a pull request with this backport targeting openjdk/jdk22u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 6997bfc6 from the openjdk/jdk repository.

The commit being backported was authored by Christian Hagedorn on 19 Jan 2024 and was reviewed by Roland Westrelin, Tobias Hartmann and Quan Anh Mai.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk22u:

$ git fetch https://github.com/openjdk-bots/jdk22u.git backport-TobiHartmann-6997bfc6:backport-TobiHartmann-6997bfc6
$ git checkout backport-TobiHartmann-6997bfc6
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk22u.git backport-TobiHartmann-6997bfc6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
4 participants