-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8254872: Optimize Rotate on AArch64 #1199
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
Conversation
This patch is a supplement for https://bugs.openjdk.java.net/browse/JDK-8248830. With the implementation of rotate node in IR, this patch: 1. canonicalizes RotateLeft into RotateRight when shift is a constant, so that GVN could identify the pre-existing node better. 2. implements scalar rotate match rules and removes the original combinations of Or and Shifts on AArch64. This patch doesn't implement vector rotate due to the lack of corresponding vector instructions on AArch64. Test case below is an explanation for this patch. public static int test(int i) { int a = (i >>> 29) | (i << -29); int b = i << 3; int c = i >>> -3; int d = b | c; return a ^ d; } Before: lsl w12, w1, openjdk#3 lsr w10, w1, openjdk#29 add w11, w10, w12 orr w12, w12, w10 eor w0, w11, w12 After: ror w10, w1, openjdk#29 eor w0, w10, w10 Tested jtreg TestRotate.java, hotspot::hotspot_all_no_apps, jdk::jdk_core, langtools::tier1. Change-Id: Id7d00935945f1697247fff7041b0707107862786
|
👋 Welcome back erik1iu! A progress list of the required criteria for merging this PR into |
|
@erik1iu The following label will be automatically applied to this pull request:
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. |
theRealAph
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very nice in general, but please add one more case for the EOR (shifted register) instructions with rotation. At present we only do LSR, ASL, and ASR. You could add ROR to
define(ALL_SHIFT_KINDS', BOTH_SHIFT_INSNS($1, $2, URShift, LSR)
BOTH_SHIFT_INSNS($1, $2, RShift, ASR)
BOTH_SHIFT_INSNS($1, $2, LShift, LSL)')dnl
This is used in, for example, Java code for SHA 3.
|
Mailing list message from John Rose on hotspot-compiler-dev: On Nov 13, 2020, at 2:39 AM, Eric Liu <github.com+10482586+erik1iu at openjdk.java.net> wrote:
Because of shift-count masking, this parses to nodes public static int test(int i) { If we were to work a little harder at canonicalizing In this case the better road is to canonicalize both
Amazingly, w10^w10 does not GVN to zero! Your test appears to rely on that weakness. Anyway, none of these remarks reflects ? John |
|
Mailing list message from Eric Liu on hotspot-compiler-dev: Hi Andrew, Thanks for your review. I will update those cases soon. B&R
Looks very nice in general, but please add one more case for the EOR (shifted register) instructions with rotation. At present we only do LSR, ASL, and ASR. You could add ROR to define(`ALL_SHIFT_KINDS', This is used in, for example, Java code for SHA 3. ------------- Changes requested by aph (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/1199 |
|
Mailing list message from Eric Liu on hotspot-compiler-dev: Hi John, Thanks for your review. I'd like to take some time to investigate the weakness. B&R From: hotspot-compiler-dev <hotspot-compiler-dev-retn at openjdk.java.net> on behalf of John Rose <john.r.rose at oracle.com>
Because of shift-count masking, this parses to nodes ?????? public static int test(int i) { If we were to work a little harder at canonicalizing In this case the better road is to canonicalize both
Amazingly, w10^w10 does not GVN to zero! Your test appears to rely on that weakness. Anyway, none of these remarks reflects ? John |
|
Hi Andrew, I just thought about this a bit more.
I prefer to integrate this patch first.
This patch is basically pure without regressions, and for above tasks I prefer to finish them in the next patch once for all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Fri, 13 Nov 2020 17:54:34 GMT, Andrew Haley aph@openjdk.org wrote:
Looks very nice in general, but please add one more case for the EOR (shifted register) instructions with rotation. At present we only do LSR, ASL, and ASR. You could add ROR to
define(
ALL_SHIFT_KINDS',BOTH_SHIFT_INSNS($1, $2, URShift, LSR)
BOTH_SHIFT_INSNS($1, $2, RShift, ASR)
BOTH_SHIFT_INSNS($1, $2, LShift, LSL)')dnlThis is used in, for example, Java code for SHA 3.
I prefer to integrate this patch first.
- I added those cases for EOR instructions in my local, they work fine in general but I suppose it still needs more strict regressions.
Perhaps so.
- For another rule
dst (AddI (LShiftI src1 lshift) (URShiftI src2 rshift)), I presume it can be transformed to Rotate in middle-end iflshift + rshift = 0
and src1 is the same register as src2.
but I didn't implement it in this patch.
- @vnkozlov (Vladimir Kozlov) left over an issue(https://bugs.openjdk.java.net/browse/JDK-8252776), which asks for refactoring the test cases in TestRotate.java, It's also a good chance to add other new test cases.
I see.
This patch is basically pure without regressions, and for above tasks I prefer to finish them in the next patch once for all.
I suppose that's OK, but it seems to me odd to do half the job.
|
@erik1iu 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: 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 101 new commits pushed to the
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 (@theRealAph, @vnkozlov) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
/integrate |
|
@erik1iu |
vnkozlov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opto/ changes look good to me
|
/sponsor |
|
@nick-arm @erik1iu Since your change was applied there have been 102 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 30a2ad5. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
|
Mailing list message from Eric Liu on hotspot-compiler-dev: Hi John, I thought about this a bit more.
I think this was cased by the lack of Ideal on Xor 1). x ^ x ==> 0, this can solve the above issue.
Thanks, |
This patch is a supplement for
https://bugs.openjdk.java.net/browse/JDK-8248830.
With the implementation of rotate node in IR, this patch:
so that GVN could identify the pre-existing node better.
combinations of Or and Shifts on AArch64.
This patch doesn't implement vector rotate due to the lack of
corresponding vector instructions on AArch64.
Test case below is an explanation for this patch.
Before:
After:
Tested jtreg TestRotate.java, hotspot::hotspot_all_no_apps,
jdk::jdk_core, langtools::tier1.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/1199/head:pull/1199$ git checkout pull/1199