Skip to content

8365570: C2 fails assert(false) failed: Unexpected node in SuperWord truncation: CastII#26827

Closed
jaskarth wants to merge 8 commits intoopenjdk:masterfrom
jaskarth:jdk-8365570
Closed

8365570: C2 fails assert(false) failed: Unexpected node in SuperWord truncation: CastII#26827
jaskarth wants to merge 8 commits intoopenjdk:masterfrom
jaskarth:jdk-8365570

Conversation

@jaskarth
Copy link
Member

@jaskarth jaskarth commented Aug 18, 2025

Hi all,
This is a quick patch for the assert failure in superword truncation with CastII. I've added a check for all constraint cast nodes, and attached a reduced version of the fuzzer test. Thanks!


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-8365570: C2 fails assert(false) failed: Unexpected node in SuperWord truncation: CastII (Bug - P3)(⚠️ The fixVersion in this issue is [26] but the fixVersion in .jcheck/conf is 27, 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/26827/head:pull/26827
$ git checkout pull/26827

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26827

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 18, 2025

👋 Welcome back jkarthikeyan! 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
Copy link

openjdk bot commented Aug 18, 2025

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

8365570: C2 fails assert(false) failed: Unexpected node in SuperWord truncation: CastII

Reviewed-by: chagedorn, thartmann, epeter

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
Copy link

openjdk bot commented Aug 18, 2025

@jaskarth 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 hotspot-compiler hotspot-compiler-dev@openjdk.org rfr Pull request is ready for review labels Aug 18, 2025
@mlbridge
Copy link

mlbridge bot commented Aug 18, 2025

Webrevs

// Vector nodes should not truncate.
if (type->isa_vect() != nullptr || type->isa_vectmask() != nullptr || in->is_Reduction()) {
// Vector nodes and casts should not truncate.
if (type->isa_vect() != nullptr || type->isa_vectmask() != nullptr || in->is_Reduction() || in->is_ConstraintCast()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why should we not truncate a CastII? What can go wrong?

Copy link
Member Author

Choose a reason for hiding this comment

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

My thinking was that since casts specifically change the type of a node, they may not be safe to truncate. In practice it might not matter because after the CastII pack is created, it's discarded because there is no backend implementation for vectorized CastII. I've opted to mark them as non-truncating to stay on the safer side.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Ok. Can you add a comment to the code for that?
Because imagine we come along later and actually implement a backend vectorized version of CastII (no-op?). Maybe because we implement if-conversion. Then it would be nice to know if this was just a "to be on the safe side" check, or if it would run into issues when removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Because the current comment says "should not truncate". That sounds more strong than "to be on the safe side".

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is fair, I've pushed a commit that changes the comment wording. Let me know what you think!

Copy link
Member

Choose a reason for hiding this comment

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

We have CastVV which should be the packed version of CastII. The thing that is I think the most difficult is to properly wire it. In the simplest situation of all elements in the pack having the same control input can be easily handled, though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right. I don't think there is currently any case where CastII would actually be useful to pack in superword. They usually originate from some control-flow. For example a comparison on a variable if (x < 5) and then we can CastII the variable x on the branches. But that only becomes relevant with if-conversion.

Or do you see a case that could happen without if-conversion where CastII needs to be handled?

@eme64
Copy link
Contributor

eme64 commented Aug 22, 2025

@jaskarth Thanks for the fix, it looks good to me now :)
I'm just running some internal testing now, please ping me after the weekend :)

Copy link
Contributor

@eme64 eme64 left a comment

Choose a reason for hiding this comment

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

Testing passed 🟢

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 25, 2025
@jaskarth
Copy link
Member Author

Thanks a lot for the testing @eme64! I think I need another review to merge it.

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

The fix looks good to me, too! I only have one comment about the test.

return new Object[] { in, res };
}

@Test(compLevel = CompLevel.C2)
Copy link
Member

Choose a reason for hiding this comment

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

Any particular reason you've chosen C2 here and not let the IR framework handle it? (by default it's ANY which will compile at the highest available tier). I'm also wondering if this test would fail if someone ran the test with a build without C2.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the comment! I used CompLevel.C2 here to simulate an -Xcomp environment, since unfortunately I couldn't replicate the crash without it with the IR framework. I'll do some investigation to find a way to ensure that it won't fail without C2.

Copy link
Member

Choose a reason for hiding this comment

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

When you specify @Warmup(0), the IR framework should directly compile it at the highest level which should be C2 if you are not running with a client build. So, I would have expected that it makes no difference. Can you double-check if you can reproduce it with CompLevel.C2 but not without?

Copy link
Member Author

Choose a reason for hiding this comment

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

After taking a closer look, I think you're correct- I can reproduce the crash using just @Warmup(0) and @Test. I think I used both while debugging and didn't test whether it worked without CompLevel.C2. I've removed it in the latest commit.
However, I noticed that after that I merged from master neither the test nor the reproducer failed compilation before the fix is added. I think another commit must have changed the generated graph so that it no longer tries to vectorize the CastII, leading to the crash not being triggered. I looked at the JBS entry and saw that there wasn't another reproducer for this, so I was a bit unsure on what to do. Should this patch be merged with the current test?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jaskarth Thanks for looking into it!

I would still add the fix, just in case. And I think the test as well, even if it does not reproduce any more.

I was wondering: before the merge, when the test still reproduced:
If you removed the @Warmup(0) and CompLevel.C2, and instead just do framework.addFlags with -Xcomp, would that reproduce too? If so, you could have a framework run with and one without Xcomp, the one with Xcomp also should have a compileonly. What do you think?

Or we just push the patch as is, to be sure this is done and integrated. What do you think @chhagedorn ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, I can replicate the crash on the old commit with TestFramework.runWithFlags("-Xcomp", "-XX:CompileCommand=compileonly,*TestSubwordTruncation::*"); instead of @Warmup(0). I think this would also be a good option, as it would let you get coverage with Xcomp on the other tests as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've pushed a commit that changes the Warmup(0) to the second test run.

Copy link
Member

Choose a reason for hiding this comment

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

Given the timeout reported by Tobias, I would rather opt for @Warmup(0) with one run() only. We will eventually run the test with -Xcomp on higher tiers, for example at tier6, so we get Xcomp coverage at some point.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's a good point, I've reverted this change.

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 20, 2025

@jaskarth This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 17, 2025

@jaskarth This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this Nov 17, 2025
@TobiHartmann
Copy link
Member

Hi @jaskarth: Any plans to pick this back up? Thanks!

@jaskarth
Copy link
Member Author

Hi @TobiHartmann, I haven't had a chance to take a look at this due to being busy with my studies but I'm hoping to pick it back up in a week.

@jaskarth
Copy link
Member Author

/open

@openjdk openjdk bot reopened this Nov 25, 2025
@openjdk
Copy link

openjdk bot commented Nov 25, 2025

@jaskarth This pull request is now open

@TobiHartmann
Copy link
Member

Sounds good, thanks for the update!

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Dec 5, 2025
@bridgekeeper
Copy link

bridgekeeper bot commented Jan 4, 2026

@jaskarth This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@jaskarth
Copy link
Member Author

jaskarth commented Jan 6, 2026

@TobiHartmann @chhagedorn May I have some reviews on the updated patch? Thank you!

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

Update looks good! Thanks for coming back to this.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 7, 2026
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, thanks! I re-submitted some quick testing and will report back once it passed.

@TobiHartmann
Copy link
Member

I see timeouts with the test in various configurations, maybe the default timeout should be increased?

compiler.lib.ir_framework.driver.TestVMException: There were one or multiple errors. Please check stderr for more information.
	at compiler.lib.ir_framework.driver.TestVMProcess.throwTestVMException(TestVMProcess.java:251)
	at compiler.lib.ir_framework.driver.TestVMProcess.checkTestVMExitCode(TestVMProcess.java:232)
	at compiler.lib.ir_framework.driver.TestVMProcess.<init>(TestVMProcess.java:77)
	at compiler.lib.ir_framework.TestFramework.runTestVM(TestFramework.java:879)
	at compiler.lib.ir_framework.TestFramework.start(TestFramework.java:839)
	at compiler.lib.ir_framework.TestFramework.start(TestFramework.java:431)
	at compiler.lib.ir_framework.TestFramework.runWithFlags(TestFramework.java:257)
	at compiler.vectorization.TestSubwordTruncation.main(TestSubwordTruncation.java:509)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:335)
	at java.base/java.lang.Thread.run(Thread.java:1516)

JavaTest Message: Test threw exception: compiler.lib.ir_framework.driver.TestVMException
JavaTest Message: shutting down test

result: Error. "driver" action timed out with a timeout of 480 seconds on agent 136; but completed after timeout - suppressed status: "Failed. `main' threw exception: compiler.lib.ir_framework.driver.TestVMException: There were one or multiple errors. Please check stderr for more information."


test result: Error. "driver" action timed out with a timeout of 480 seconds on agent 136; but completed after timeout - suppressed status: "Failed. `main' threw exception: compiler.lib.ir_framework.driver.TestVMException: There were one or multiple errors. Please check stderr for more information."

@jaskarth
Copy link
Member Author

jaskarth commented Jan 8, 2026

Thank you for running testing @TobiHartmann! I've pushed a commit that reverts the change made to run with -Xcomp directly, so hopefully the timeout is prevented.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jan 8, 2026
@TobiHartmann
Copy link
Member

Sounds good, I re-submitted testing.

Copy link
Member

@chhagedorn chhagedorn 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, thanks for the update! Let's wait for the testing to be completed.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 8, 2026
@TobiHartmann
Copy link
Member

All tests passed.

@jaskarth
Copy link
Member Author

jaskarth commented Jan 9, 2026

Thank you for the review and testing!

/integrate

@openjdk
Copy link

openjdk bot commented Jan 9, 2026

Going to push as commit 775f48d.
Since your change was applied there have been 42 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 Jan 9, 2026
@openjdk openjdk bot closed this Jan 9, 2026
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 9, 2026
@openjdk
Copy link

openjdk bot commented Jan 9, 2026

@jaskarth Pushed as commit 775f48d.

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

@TobiHartmann
Copy link
Member

/backport :jdk26

@openjdk
Copy link

openjdk bot commented Jan 9, 2026

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

The commit being backported was authored by Jasmine Karthikeyan on 9 Jan 2026 and was reviewed by Christian Hagedorn, Tobias Hartmann and Emanuel Peter.

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-TobiHartmann-775f48de-jdk26:backport-TobiHartmann-775f48de-jdk26
$ git checkout backport-TobiHartmann-775f48de-jdk26
# 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-TobiHartmann-775f48de-jdk26

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.

5 participants