Skip to content
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

8271883: Math CopySign optimization for x86 #5005

Closed
wants to merge 6 commits into from

Conversation

@mgkwill
Copy link
Contributor

@mgkwill mgkwill commented Aug 4, 2021

Intrinsic for Math.copySign is disabled on x86_64.

We can improve on generated c2 instructions for float and double, and this change adds optimized intrinsics for float and double Math.copySign.

Math.copySign(double)

From:
0x00007f7d606e5dac: vmovq %xmm1,%r10
0x00007f7d606e5db1: vmovq %xmm0,%r11
0x00007f7d606e5db6: movabs $0x7fffffffffffffff,%r8
0x00007f7d606e5dc0: and %r8,%r11
0x00007f7d606e5dc3: movabs $0x8000000000000000,%r8
0x00007f7d606e5dcd: and %r8,%r10
0x00007f7d606e5dd0: or %r11,%r10
0x00007f7d606e5dd3: vmovq %r10,%xmm0

To:
0x00007fc3c14c63ac: movabs $0x7fffffffffffffff,%r10
0x00007fc3c14c63b6: vmovq %r10,%xmm2
0x00007fc3c14c63bb: vpternlogq $0xe4,%xmm2,%xmm1,%xmm0

Math.copySign(float)

From:
0x00007ff8886e60ac: vmovd %xmm1,%r11d
0x00007ff8886e60b1: vmovd %xmm0,%r10d
0x00007ff8886e60b6: and $0x80000000,%r11d
0x00007ff8886e60bd: and $0x7fffffff,%r10d
0x00007ff8886e60c4: or %r10d,%r11d
0x00007ff8886e60c7: vmovd %r11d,%xmm0
To:
0x00007fc7d94c63ac: mov $0x7fffffff,%r10d
0x00007fc7d94c63b2: vmovd %r10d,%xmm3
0x00007fc7d94c63b7: vpternlogd $0xe4,%xmm3,%xmm1,%xmm0

Performance of patch using updated test/micro/org/openjdk/bench/vm/compiler/Signum.java:

BEFORE

Signum._5_copySignFloatTest avgt 5 2.442 ? 0.024 ns/op
Signum._7_copySignDoubleTest avgt 5 2.400 ? 0.033 ns/op

PATCH

Signum._5_copySignFloatTest avgt 5 2.029 ? 0.011 ns/op
Signum._7_copySignDoubleTest avgt 5 2.029 ? 0.024 ns/op

JTREG that covers this case:

test/hotspot/jtreg/compiler/intrinsics/math/TestSignumIntrinsic.java

Signed-off-by: Marcus G K Williams marcus.williams@intel.com


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5005/head:pull/5005
$ git checkout pull/5005

Update a local copy of the PR:
$ git checkout pull/5005
$ git pull https://git.openjdk.java.net/jdk pull/5005/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5005

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5005.diff

Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Aug 4, 2021

👋 Welcome back mgkwill! 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.

Loading

@openjdk openjdk bot added the rfr label Aug 4, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 4, 2021

@mgkwill The following label will be automatically applied to this pull request:

  • hotspot

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.

Loading

@openjdk openjdk bot added the hotspot label Aug 4, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Aug 4, 2021

Loading

@mgkwill
Copy link
Contributor Author

@mgkwill mgkwill commented Aug 4, 2021

/label hotspot-compiler

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Aug 4, 2021

@mgkwill
The hotspot-compiler label was successfully added.

Loading

src/hotspot/cpu/x86/x86.ad Outdated Show resolved Hide resolved
Loading
src/hotspot/cpu/x86/x86.ad Outdated Show resolved Hide resolved
Loading
src/hotspot/cpu/x86/x86.ad Outdated Show resolved Hide resolved
Loading
src/hotspot/cpu/x86/x86.ad Outdated Show resolved Hide resolved
Loading
src/hotspot/cpu/x86/x86.ad Outdated Show resolved Hide resolved
Loading
src/hotspot/cpu/x86/x86.ad Outdated Show resolved Hide resolved
Loading
src/hotspot/cpu/x86/x86.ad Show resolved Hide resolved
Loading
src/hotspot/cpu/x86/x86.ad Outdated Show resolved Hide resolved
Loading
mgkwill added 3 commits Aug 9, 2021
Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
src/hotspot/cpu/x86/x86.ad Outdated Show resolved Hide resolved
Loading
src/hotspot/cpu/x86/x86.ad Outdated Show resolved Hide resolved
Loading
src/hotspot/cpu/x86/x86.ad Show resolved Hide resolved
Loading
Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
@openjdk
Copy link

@openjdk openjdk bot commented Aug 13, 2021

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

8271883: Math CopySign optimization for x86

Reviewed-by: jbhateja, sviswanathan, 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 103 new commits pushed to the master branch:

  • 6b8b160: 8272396: mismatching debug output streams
  • 0af645a: 8205138: Remove Applet references from Font2DTest
  • bd7f9b4: 8272459: ProblemList compiler/codecache/TestStressCodeBuffers.java on aarch64
  • 717792c: 8263940: NPE when creating default file system when default file system provider is packaged as JAR file on class path
  • d06d0b9: 8272112: Arena code simplifications
  • 0c4be76: 8058704: Nimbus does not honor JTextPane background color
  • 020aec5: 8271366: [REDO] JDK-8266054 VectorAPI rotate operation optimization
  • 4d4ba5c: 8272116: Update PerfDisableSharedMem with FLAG_SET_ERGO in PerfMemory::create_memory_region
  • 09ab86b: 8269909: getStack method in hprof.parser.Reader should use try-with-resource
  • e4766ee: 8272391: Undeleted debug information
  • ... and 93 more: https://git.openjdk.java.net/jdk/compare/ff7431eafea8bd763250f929aa35edcaae2fbc58...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 (@jatin-bhateja, @sviswa7, @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).

Loading

@openjdk openjdk bot added the ready label Aug 13, 2021
@mgkwill
Copy link
Contributor Author

@mgkwill mgkwill commented Aug 13, 2021

/integrate

Loading

@openjdk openjdk bot added the sponsor label Aug 13, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 13, 2021

@mgkwill
Your change (at version 1399d57) is now ready to be sponsored by a Committer.

Loading

@sviswa7
Copy link

@sviswa7 sviswa7 commented Aug 13, 2021

Could we please get second review from a reviewer? Also need help running this through Oracle's testing.

Loading

@mgkwill
Copy link
Contributor Author

@mgkwill mgkwill commented Aug 13, 2021

@vnkozlov any chance you have time to run this through Oracle Testing?

I tested tier1-3 on cascade lake Linux x86_64.

Loading

@vnkozlov
Copy link
Contributor

@vnkozlov vnkozlov commented Aug 13, 2021

I started our testing.

Loading

@vnkozlov
Copy link
Contributor

@vnkozlov vnkozlov commented Aug 13, 2021

Testing passed clean.

Loading

@sviswa7
Copy link

@sviswa7 sviswa7 commented Aug 13, 2021

@vnkozlov Thanks a lot Vladimir. Jatin and I have reviewed the patch. Could we integrate or should we wait for another review.

Loading

@mgkwill
Copy link
Contributor Author

@mgkwill mgkwill commented Aug 13, 2021

Testing passed clean.

Thanks @vnkozlov!

Loading

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Yes, you can push it,

Loading

@sviswa7
Copy link

@sviswa7 sviswa7 commented Aug 14, 2021

/sponsor

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Aug 14, 2021

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

  • 6b8b160: 8272396: mismatching debug output streams
  • 0af645a: 8205138: Remove Applet references from Font2DTest
  • bd7f9b4: 8272459: ProblemList compiler/codecache/TestStressCodeBuffers.java on aarch64
  • 717792c: 8263940: NPE when creating default file system when default file system provider is packaged as JAR file on class path
  • d06d0b9: 8272112: Arena code simplifications
  • 0c4be76: 8058704: Nimbus does not honor JTextPane background color
  • 020aec5: 8271366: [REDO] JDK-8266054 VectorAPI rotate operation optimization
  • 4d4ba5c: 8272116: Update PerfDisableSharedMem with FLAG_SET_ERGO in PerfMemory::create_memory_region
  • 09ab86b: 8269909: getStack method in hprof.parser.Reader should use try-with-resource
  • e4766ee: 8272391: Undeleted debug information
  • ... and 93 more: https://git.openjdk.java.net/jdk/compare/ff7431eafea8bd763250f929aa35edcaae2fbc58...master

Your commit was automatically rebased without conflicts.

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Aug 14, 2021

@sviswa7 @mgkwill Pushed as commit 87d2761.

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

Loading

@mgkwill mgkwill deleted the copySign branch Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants