Skip to content

8382536: C2: sharpen_type_after_if: assert(val->find_edge(con) > 0) failed: mismatch#31798

Closed
iwanowww wants to merge 3 commits into
openjdk:masterfrom
iwanowww:8382536.con
Closed

8382536: C2: sharpen_type_after_if: assert(val->find_edge(con) > 0) failed: mismatch#31798
iwanowww wants to merge 3 commits into
openjdk:masterfrom
iwanowww:8382536.con

Conversation

@iwanowww

@iwanowww iwanowww commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

The shape of instanceof check matched by JDK-8372634 expects a constant to be a Con node. But it turns out it's not always the case: it can be a CastII when a value is provably constant after a runtime check.

The fix enhances the logic to properly match such IR shape.

Testing: hs-tier1 - hs-tier5


Progress

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

Issue

  • JDK-8382536: C2: sharpen_type_after_if: assert(val->find_edge(con) > 0) failed: mismatch (Bug - P3)(⚠️ The fixVersion in this issue is [27] but the fixVersion in .jcheck/conf is 28, a new backport will be created when this pr is integrated.)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31798

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Jul 6, 2026

Copy link
Copy Markdown

👋 Welcome back vlivanov! 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 commented Jul 6, 2026

Copy link
Copy Markdown

@iwanowww 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:

8382536: C2: sharpen_type_after_if: assert(val->find_edge(con) > 0) failed: mismatch

Reviewed-by: chagedorn, mchevalier

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 26 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 hotspot-compiler hotspot-compiler-dev@openjdk.org label Jul 6, 2026
@openjdk

openjdk Bot commented Jul 6, 2026

Copy link
Copy Markdown

@iwanowww 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 commented Jul 6, 2026

Copy link
Copy Markdown

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot-compiler. This can be overridden with the /reviewers command.

@iwanowww iwanowww marked this pull request as ready for review July 7, 2026 17:38
@openjdk openjdk Bot added the rfr Pull request is ready for review label Jul 7, 2026
@mlbridge

mlbridge Bot commented Jul 7, 2026

Copy link
Copy Markdown

Webrevs

@chhagedorn chhagedorn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Otherwise, the fix looks good to me, thanks!

Comment thread src/hotspot/share/opto/parse2.cpp Outdated
Comment thread src/hotspot/share/opto/parse2.cpp Outdated
Comment on lines +1811 to +1812
if ((btest == BoolTest::eq && tcon == success_tval) ||
(btest == BoolTest::ne && tcon->join(success_tval)->empty())) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe a small comment like this would help here:

// gen_instanceof() emits 1 on success and 0 on failure. 
// Check whether the current outer comparison selects the success value.

Optionally, we could also assert that the success and failure phi inputs are 1 and 0, respectively.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Optionally, we could also assert that the success and failure phi inputs are 1 and 0, respectively.

I'm not sure it always holds. It's part of IR shape matching: we know the shape of con/tcon and the check extends it to val (Phi) inputs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see, then let's leave it like that.

@marc-chevalier marc-chevalier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That looks good to me, but I agree with @chhagedorn comments. They helped me when reviewing.

Comment thread test/hotspot/jtreg/compiler/types/TestSubTypeCheckConstantCastII.java Outdated

@chhagedorn chhagedorn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That looks good to me, thanks for the update!

Comment on lines +1811 to +1812
if ((btest == BoolTest::eq && tcon == success_tval) ||
(btest == BoolTest::ne && tcon->join(success_tval)->empty())) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see, then let's leave it like that.

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Jul 9, 2026
@iwanowww

iwanowww commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews, Christian and Marc.

/integrate

@openjdk

openjdk Bot commented Jul 9, 2026

Copy link
Copy Markdown

Going to push as commit 4d3723b.
Since your change was applied there have been 32 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk Bot added the integrated Pull request has been integrated label Jul 9, 2026
@openjdk openjdk Bot closed this Jul 9, 2026
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 9, 2026
@openjdk

openjdk Bot commented Jul 9, 2026

Copy link
Copy Markdown

@iwanowww Pushed as commit 4d3723b.

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

@iwanowww

Copy link
Copy Markdown
Contributor Author

/backport :jdk27

@openjdk

openjdk Bot commented Jul 10, 2026

Copy link
Copy Markdown

@iwanowww the backport was successfully created on the branch backport-iwanowww-4d3723b8-jdk27 in my personal fork of openjdk/jdk. To create a pull request with this backport targeting openjdk/jdk:jdk27, 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 4d3723b8 from the openjdk/jdk repository.

The commit being backported was authored by Vladimir Ivanov on 9 Jul 2026 and was reviewed by Christian Hagedorn and Marc Chevalier.

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/jdk:

$ git fetch https://github.com/openjdk-bots/jdk.git backport-iwanowww-4d3723b8-jdk27:backport-iwanowww-4d3723b8-jdk27
$ git checkout backport-iwanowww-4d3723b8-jdk27
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk.git backport-iwanowww-4d3723b8-jdk27

⚠️ @iwanowww You are not yet a collaborator in my fork openjdk-bots/jdk. An invite will be sent out and you need to accept it before you can proceed.

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

Development

Successfully merging this pull request may close these issues.

3 participants