Skip to content

Conversation

@Bhavana-Kilambi
Copy link
Contributor

@Bhavana-Kilambi Bhavana-Kilambi commented Nov 2, 2022

C2 miscompiles during auto-vectorization of MinI/MaxI nodes when "short" type operands are involved. When a short and an integer value is compared, C2 generates vector min/max nodes for "short" types which does not result in correct output as it disregards the higher order bits of the integer input. Java API for Math.min/max also only supports the int, long, float and double types but not the subword integer types namely - char, byte and short. Hence, char/short/byte min/max vector instructions should not be generated.
This patch ensures that MaxV and MinV vector nodes are only generated for the "int" type for MaxI and MinI nodes during auto-vectorization.


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-8294816: C2: Math.min/max vectorization miscompilation

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10944

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

Using diff file

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

C2 miscompiles during auto-vectorization of MinI/MaxI nodes when "short"
type operands are involved. When a short and an integer value is
compared, C2 generates vector min/max nodes for "short" types which does
not result in correct output as it disregards the higher order bits of
the integer input. Java API for Math.min/max also only supports the int,
long, float and double types but not the subword integer types namely -
char, byte and short. Hence, char/short/byte min/max vector instructions
should not be generated.
This patch ensures that MaxV and MinV vector nodes are only generated
for the "int" type for MaxI and MinI nodes during auto-vectorization.
@bridgekeeper
Copy link

bridgekeeper bot commented Nov 2, 2022

👋 Welcome back bkilambi! 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 2, 2022
@openjdk
Copy link

openjdk bot commented Nov 2, 2022

@Bhavana-Kilambi 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 2, 2022
@mlbridge
Copy link

mlbridge bot commented Nov 2, 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. I'll run testing and report back once it passed.

@openjdk
Copy link

openjdk bot commented Nov 2, 2022

@Bhavana-Kilambi 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:

8294816: C2: Math.min/max vectorization miscompilation

Reviewed-by: thartmann, ngasson

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

  • c206f28: 8283101: serviceability/jvmti/thread/GetFrameCount/framecnt01/framecnt01.java failing #VirtualThread-Frozen: number of frames expected: 14, got: 9
  • 97c5a64: 8296287: Improve documentation for Types.directSupertypes()
  • f9c7cda: 8294109: JavaDoc search should search whole index
  • 5622b09: 8200337: Generalize see and link tags for user-defined anchors
  • 22347e4: 8277775: Fixup bugids in RemoveDropTargetCrashTest.java - add 4357905
  • 1231682: 8296305: Remove unimplemented deoptimized_wrt_marked_nmethods
  • 3378bfe: 8296224: G1: Remove unnecessary update in VM_G1CollectForAllocation
  • 8ee0f7d: 8296231: Fix MEMFLAGS for CHeapBitMaps
  • bd729e6: 8296380: IGV: Shortcut for quick search not working
  • c116ae7: 8295967: RISC-V: Support negVI/negVL instructions for Vector API
  • ... and 36 more: https://git.openjdk.org/jdk/compare/1a58cb1c023c876594e8a53d00703e564a922d36...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, @nick-arm) 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 2, 2022
// as Java APIs for Math.min/max do not support integer subword types and superword
// should not generate vectorized Min/Max nodes for them.
@Test
@IR(failOn = {IRNode.Min_V})
Copy link
Member

Choose a reason for hiding this comment

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

The test currently fails compilation because the IRNodes were renamed by #10695 to MIN_V.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for letting me know. I have updated the code accordingly. Please review..

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Nov 2, 2022
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.

All tests passed. Looks good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 4, 2022
@Bhavana-Kilambi
Copy link
Contributor Author

/integrate

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

openjdk bot commented Nov 4, 2022

@Bhavana-Kilambi
Your change (at version 74d9886) is now ready to be sponsored by a Committer.

@nick-arm
Copy link
Contributor

nick-arm commented Nov 4, 2022

/sponsor

@openjdk
Copy link

openjdk bot commented Nov 4, 2022

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

  • c206f28: 8283101: serviceability/jvmti/thread/GetFrameCount/framecnt01/framecnt01.java failing #VirtualThread-Frozen: number of frames expected: 14, got: 9
  • 97c5a64: 8296287: Improve documentation for Types.directSupertypes()
  • f9c7cda: 8294109: JavaDoc search should search whole index
  • 5622b09: 8200337: Generalize see and link tags for user-defined anchors
  • 22347e4: 8277775: Fixup bugids in RemoveDropTargetCrashTest.java - add 4357905
  • 1231682: 8296305: Remove unimplemented deoptimized_wrt_marked_nmethods
  • 3378bfe: 8296224: G1: Remove unnecessary update in VM_G1CollectForAllocation
  • 8ee0f7d: 8296231: Fix MEMFLAGS for CHeapBitMaps
  • bd729e6: 8296380: IGV: Shortcut for quick search not working
  • c116ae7: 8295967: RISC-V: Support negVI/negVL instructions for Vector API
  • ... and 36 more: https://git.openjdk.org/jdk/compare/1a58cb1c023c876594e8a53d00703e564a922d36...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 4, 2022
@openjdk openjdk bot closed this Nov 4, 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 4, 2022
@openjdk
Copy link

openjdk bot commented Nov 4, 2022

@nick-arm @Bhavana-Kilambi Pushed as commit b49bdae.

💡 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.

3 participants