Skip to content

Conversation

@jatin-bhateja
Copy link
Member

@jatin-bhateja jatin-bhateja commented Nov 27, 2025

This bug patch fixes a crash seen while querying the bottom type of MachTempNode corresponding to rxmm0 operand of blend pattern during late scheduling. Here, MaxVectorSize is contrainted to 8 bytes thus during C2 type system initialization, TypeVect::VECTX guarded by target supprted vector size remains uninitialized.

Its better to reject matching of VectorBlend in such a scenario.

All exisitng VectorAPI jtreg tests are passing with -XX:UseAVX=0 and -XX:MaxVectorSize=8

Kindly review and share your feedback.

Best Regards,
Jatin


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-8337791: VectorAPI jtreg ABSMaskedByteMaxVectorTests crashes with UseAVX=0 -XX:MaxVectorSize=8 (Bug - P3)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28533

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 27, 2025

👋 Welcome back jbhateja! 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 Nov 27, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Nov 27, 2025

@jatin-bhateja 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 rfr Pull request is ready for review label Nov 27, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 27, 2025

@openjdk
Copy link

openjdk bot commented Nov 27, 2025

@jatin-bhateja Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@jatin-bhateja jatin-bhateja changed the title 8337791: VectorAPI jtreg ABSMaskedByteMaxVectorTests crashes with UseAVXX=0 -XX:MaxVectorSize=8 8337791: VectorAPI jtreg ABSMaskedByteMaxVectorTests crashes with UseAVX=0 -XX:MaxVectorSize=8 Nov 27, 2025
Copy link
Member Author

@jatin-bhateja jatin-bhateja left a comment

Choose a reason for hiding this comment

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

@sviswa7, @eme64 , kindly check and approve.

}
break;
case Op_VectorBlend:
if (UseAVX == 0 && MaxVectorSize < 16) {
Copy link
Member Author

Choose a reason for hiding this comment

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

While its technically fesable to create a 64-bit wide byte vector blend for AVX level 0 using blendvp selection pattern and emit pblendv instruction for it, but the machine nodes inputs will not be iso-morphic, ie. MachTemp node for xmm0 will be 128 bit wide TypeVect::VECTX and other input will be of type 64bit TypeVect::VECTD type. Given that blend is a lanewise operation hence IR type must be compatible with input types. Its better to use size_in_bits rather than MaxVectorSize in guard check.

We could have pushed this check to actual pattern predicate but its better to uplift the checks to match_rule_supported_vector since it prevents creation non-matchable IR during construction.

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.

@jatin-bhateja Thanks for looking into this!

I think it is fine to just disable the small vector size for AVX=0. Those platforms are quite rare now anyway.

Should we also adjust the predicate in the matching rule here?

  22509 instruct blendvp(vec dst, vec src, vec mask, rxmm0 tmp) %{
  22510   predicate(UseAVX == 0);   
  22511   match(Set dst (VectorBlend (Binary dst src) mask));                                                                                                                                                                                 
  22512   format %{ "vector_blend  $dst,$src,$mask\t! using $tmp as TEMP" %}
  22513   effect(TEMP tmp);  
  22514   ins_encode %{
  22515     assert(UseSSE >= 4, "required");
  22516 
  22517     if ($mask$$XMMRegister != $tmp$$XMMRegister) {
  22518       __ movdqu($tmp$$XMMRegister, $mask$$XMMRegister);
  22519     }
  22520     __ pblendvb($dst$$XMMRegister, $src$$XMMRegister); // uses xmm0 as mask
  22521   %}
  22522   ins_pipe( pipe_slow );
  22523 %}

@jatin-bhateja
Copy link
Member Author

@jatin-bhateja Thanks for looking into this!

I think it is fine to just disable the small vector size for AVX=0. Those platforms are quite rare now anyway.

Should we also adjust the predicate in the matching rule here?

As mentioned above #28533 (comment)
Its better to lift predicates to match rule supported vector i.e. AVX == 0 and size_in_bits < 128.

@eme64
Copy link
Contributor

eme64 commented Nov 27, 2025

Ok, that's fine with me too.

It would be nice if you could also attach a regression test, or maybe add an additional run to the existing test, with the required flags for reproducing this issue.

@jatin-bhateja
Copy link
Member Author

Ok, that's fine with me too.

It would be nice if you could also attach a regression test, or maybe add an additional run to the existing test, with the required flags for reproducing this issue.

@eme64 addressed.

Comment on lines 47 to 48
@IR(failOn = {IRNode.ABS_VB}, applyIfAnd={"MaxVectorSize", " <= 8 ", "UseAVX", "0"})
@IR(counts = {IRNode.ABS_VB, "1"}, applyIf={"MaxVectorSize", " > 8 "})
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this is going to pass on all platforms? Does this test run ok on aarch64 where there is no UseAVX flag?

Copy link
Member Author

@jatin-bhateja jatin-bhateja Dec 1, 2025

Choose a reason for hiding this comment

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

Thanks, fixed

I intend to pass UseAVX=0 as a run flag to reproduce exact bug scenario, our framework is not sensitive to IgnoreUnrecoginzedVMOptions.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could also just limit the rules to sse4.1 platforms. Then you can run the tests everywhere, but limit IR rules to what is easy to test for you ;)

Platform features get tested before flags, so that helps with platform specific flags ;)

Copy link
Member Author

@jatin-bhateja jatin-bhateja Dec 1, 2025

Choose a reason for hiding this comment

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

@openjdk
Copy link

openjdk bot commented Dec 1, 2025

@jatin-bhateja Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@openjdk
Copy link

openjdk bot commented Dec 1, 2025

@jatin-bhateja Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@openjdk
Copy link

openjdk bot commented Dec 1, 2025

@jatin-bhateja Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@jatin-bhateja
Copy link
Member Author

Hi @eme64 , kindly verify latest changes.

@eme64
Copy link
Contributor

eme64 commented Dec 2, 2025

Testing submitted! Code looks good to me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-compiler [email protected] rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants