Skip to content

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)

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: 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 90 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 [email protected] 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler [email protected] ready Pull request is ready to be integrated rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants