Skip to content

8295407: C2 crash: Error: ShouldNotReachHere() in multiple vector tests with -XX:-MonomorphicArrayCheck -XX:-UncommonNullCast #11034

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

Closed
wants to merge 3 commits into from

Conversation

fg1417
Copy link

@fg1417 fg1417 commented Nov 8, 2022

For unsupported CMove patterns, JDK-8293833 helps remove unused CMove and related packs from superword candidate packset by the function remove_cmove_and_related_packs(), but it only works when -XX:+UseVectorCmov is enabled[1]. When the option is not enabled, these unsupported CMove packs are still kept in the superword packset, causing the same failure.

Actually, the function filter_packs() in superword is to filter out unsupported packs but it can't work as expected currently for these CMove cases. As we know, not all CMove packs can be vectorized. merge_packs_to_cmovd()[2] looks through all packs in the superword packset and generates a CMove candidate packset to collect all qualified CMove packs. Hence, only CMove packs in the CMove candidate packset are our target patterns and can be vectorized. But filter_packs() thinks, if the CMove pack is in a superword packset and its vector node is implemented in the current platform, then it can be vectorized. Therefore, the function doesn't remove these unsupported packs.

We can adjust the function implemented() in the stage of filter_packs() to check if the current CMove pack is in the CMove candidate packset. If not, filter_packs() considers it not to be vectorized and then remove it. After the fix, whether
-XX:+UseVectorCmov is enabled or not, these unsupported packs can be removed by filter_packs(). In this way, we don't need the functionremove_cmove_and_related_packs() anymore and thus the patch also cleans related code.

[1]

if (UseVectorCmov) {

[2]
_cmovev_kit.make_cmove_pack(pk);


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-8295407: C2 crash: Error: ShouldNotReachHere() in multiple vector tests with -XX:-MonomorphicArrayCheck -XX:-UncommonNullCast

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11034

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

Using diff file

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

…ts with -XX:-MonomorphicArrayCheck -XX:-UncommonNullCast

For unsupported `CMove` patterns, JDK-8293833 helps remove unused
`CMove` and related packs from superword candidate packset by the
function `remove_cmove_and_related_packs()`, but it only works
when `-XX:+UseVectorCmov` is enabled[1]. When the option is not
enabled, these unsupported `CMove` packs are still kept in the
superword packset, causing the same failure.

Actually, the function `filter_packs()` in superword is to filter
out unsupported packs but it can't work as expected currently for
these `CMove` cases. As we know, not all `CMove` packs can be
vectorized. `merge_packs_to_cmovd()`[2] looks through all packs
in the superword packset and generates a `CMove` candidate
packset to collect all qualified `CMove` packs. Hence, only
`CMove` packs in the `CMove` candidate packset are our target
patterns and can be vectorized. But `filter_packs()` thinks,
if the `CMove` pack is in a superword packset and its vector
node is implemented in the current platform, then it can
be vectorized. Therefore, the function doesn't remove
these unsupported packs.

We can adjust the function `implemented()` in the stage of
`filter_packs()` to check if the current `CMove` pack is in
the `CMove` candidate packset. If not, `filter_packs()` considers
it not to be vectorized and then remove it. After the fix,
whether `-XX:+UseVectorCmov` is enabled or not, these
unsupported packs can be removed by `filter_packs()`. In this
way, we don't need the function`remove_cmove_and_related_packs()`
anymore and thus the patch also cleans related code.

[1] https://github.com/openjdk/jdk/blob/9b9be88bcaa35c89b6915ff0c251e5a04b10b330/src/hotspot/share/opto/superword.cpp#L537
[2] https://github.com/openjdk/jdk/blob/9b9be88bcaa35c89b6915ff0c251e5a04b10b330/src/hotspot/share/opto/superword.cpp#L1892
[3] https://github.com/openjdk/jdk/blob/9b9be88bcaa35c89b6915ff0c251e5a04b10b330/src/hotspot/share/opto/superword.cpp#L2701
@bridgekeeper
Copy link

bridgekeeper bot commented Nov 8, 2022

👋 Welcome back fgao! 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 Nov 8, 2022
@openjdk
Copy link

openjdk bot commented Nov 8, 2022

@fg1417 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 Nov 8, 2022
@mlbridge
Copy link

mlbridge bot commented Nov 8, 2022

Webrevs

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 otherwise but someone more familiar with superword should look at this as well.

* @test
* @bug 8295407
* @summary C2 crash: Error: ShouldNotReachHere() in multiple vector tests with
* -XX:-MonomorphicArrayCheck -XX:-UncommonNullCast
Copy link
Member

Choose a reason for hiding this comment

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

MonomorphicArrayCheck and UncommonNullCast are debug flags, the test will fail with a release build.

Copy link
Author

Choose a reason for hiding this comment

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

@TobiHartmann, thanks for your review! The options added here is commented as part of summary title, not as JVM options. I suppose it should be fine for a release build, right? :-)

Copy link
Member

Choose a reason for hiding this comment

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

Right, I missed that. Does the test reproduce the issue without these flags? In any case, I think a more descriptive summary would be good.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, the added testcase here can reproduce the issue even without these flags and I suppose those flags help C2 vectorize more hot loops in the reported testcases. I updated the summary part in the new commit. Thanks for your suggestion @TobiHartmann!

Copy link
Member

Choose a reason for hiding this comment

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

Great, thanks for confirming and updating the summary!

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

I have request since you are touching this code.
8192846 changes were a little sloppy and did not rename some methods which causing confusion.
Please, rename is_CmpD_candidate, merge_packs_to_cmpd and others you find to general fp as you did with is_cmove_fo_opcode.

@vnkozlov
Copy link
Contributor

Or may be simply remove D: is_Cmp_candidate(), merge_packs_to_cmove(), test_cmp_pack().
There are also comments which describes only CMoveD.

@vnkozlov
Copy link
Contributor

Do we have IR tests to verify cmove vectorization?

@fg1417
Copy link
Author

fg1417 commented Nov 16, 2022

I have request since you are touching this code. 8192846 changes were a little sloppy and did not rename some methods which causing confusion. Please, rename is_CmpD_candidate, merge_packs_to_cmpd and others you find to general fp as you did with is_cmove_fo_opcode.
Or may be simply remove D: is_Cmp_candidate(), merge_packs_to_cmove(), test_cmp_pack(). There are also comments which describes only CMoveD.

@vnkozlov, thanks for point it out. I cleaned up related code and comments in the new commit. Could you please help review it? Thanks!

Do we have IR tests to verify cmove vectorization?

Yes, we do. I added compiler/c2/irTests/TestVectorConditionalMove.java in JDK-8289422.

Copy link
Contributor

@vnkozlov vnkozlov 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. I submitted testing.

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. Let's wait for Vladimir's testing to finish.

@openjdk
Copy link

openjdk bot commented Nov 16, 2022

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

8295407: C2 crash: Error: ShouldNotReachHere() in multiple vector tests with -XX:-MonomorphicArrayCheck -XX:-UncommonNullCast

Reviewed-by: thartmann, kvn

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 70 new commits pushed to the master branch:

  • e2269fd: 8296968: Update langtools tests to use @enablePreview
  • 2159170: 8296453: Simplify resource_area uses in ClassPathDirEntry::open_stream
  • 95c390e: 8296956: [JVMCI] HotSpotResolvedJavaFieldImpl.getIndex returns wrong value
  • 68d3ed5: 8296442: EncryptedPrivateKeyInfo can be created with an uninitialized AlgorithmParameters
  • 37848a9: 8296967: [JVMCI] rationalize relationship between getCodeSize and getCode in ResolvedJavaMethod
  • b3ef337: 8296960: [JVMCI] list HotSpotConstantPool.loadReferencedType to ConstantPool
  • f0474b8: 8283238: make/scripts/compare.sh should show the diff when classlist does not match
  • 04a4d34: 8297006: JFR: AbstractEventStream should not hold thread instance
  • 5db1b58: 8296961: [JVMCI] Access to j.l.r.Method/Constructor/Field for ResolvedJavaMethod/ResolvedJavaField
  • 4ce4f38: 8296958: [JVMCI] add API for retrieving ConstantValue attributes
  • ... and 60 more: https://git.openjdk.org/jdk/compare/8eb90e2d9c4ab5975f4301dbfdb0a6d9fa036af3...master

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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@TobiHartmann, @vnkozlov) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 16, 2022
@vnkozlov
Copy link
Contributor

I got 2 failures. Description in the bug report. One could be not related. But Vector512ConversionTests.java test failure with flags from the bug report is suspicious.

@vnkozlov
Copy link
Contributor

vnkozlov commented Nov 16, 2022

Digging in JBS shows that Vector512ConversionTests.java failure is most likely JDK-8276064. So it is not new failure.

Looks like your changes are fine.

@fg1417
Copy link
Author

fg1417 commented Nov 17, 2022

Thanks for your kind review and test work, @TobiHartmann @vnkozlov. I'll integrate it.

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Nov 17, 2022
@openjdk
Copy link

openjdk bot commented Nov 17, 2022

@fg1417
Your change (at version bcf6a21) is now ready to be sponsored by a Committer.

@pfustc
Copy link
Member

pfustc commented Nov 17, 2022

/sponsor

@openjdk
Copy link

openjdk bot commented Nov 17, 2022

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

  • e2269fd: 8296968: Update langtools tests to use @enablePreview
  • 2159170: 8296453: Simplify resource_area uses in ClassPathDirEntry::open_stream
  • 95c390e: 8296956: [JVMCI] HotSpotResolvedJavaFieldImpl.getIndex returns wrong value
  • 68d3ed5: 8296442: EncryptedPrivateKeyInfo can be created with an uninitialized AlgorithmParameters
  • 37848a9: 8296967: [JVMCI] rationalize relationship between getCodeSize and getCode in ResolvedJavaMethod
  • b3ef337: 8296960: [JVMCI] list HotSpotConstantPool.loadReferencedType to ConstantPool
  • f0474b8: 8283238: make/scripts/compare.sh should show the diff when classlist does not match
  • 04a4d34: 8297006: JFR: AbstractEventStream should not hold thread instance
  • 5db1b58: 8296961: [JVMCI] Access to j.l.r.Method/Constructor/Field for ResolvedJavaMethod/ResolvedJavaField
  • 4ce4f38: 8296958: [JVMCI] add API for retrieving ConstantValue attributes
  • ... and 60 more: https://git.openjdk.org/jdk/compare/8eb90e2d9c4ab5975f4301dbfdb0a6d9fa036af3...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 17, 2022
@openjdk openjdk bot closed this Nov 17, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Nov 17, 2022
@openjdk
Copy link

openjdk bot commented Nov 17, 2022

@pfustc @fg1417 Pushed as commit cc44419.

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

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.

4 participants