RFR: 8254872: Optimize Rotate on AArch64

Andrew Haley aph at openjdk.java.net
Fri Nov 13 17:56:57 UTC 2020


On Fri, 13 Nov 2020 10:33:41 GMT, Eric Liu <github.com+10482586+erik1iu at openjdk.org> wrote:

> 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, #3
>         lsr     w10, w1, #29
>         add     w11, w10, w12
>         orr     w12, w12, w10
>         eor     w0, w11, w12
> 
> After:
> 
>         ror     w10, w1, #29
>         eor     w0, w10, w10
> 
> Tested jtreg TestRotate.java, hotspot::hotspot_all_no_apps,
> jdk::jdk_core, langtools::tier1.

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.

-------------

Changes requested by aph (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/1199


More information about the hotspot-compiler-dev mailing list