RFR: 8256438: AArch64: Implement match rules with ROR shift register value
Eric Liu
github.com+10482586+therealeliu at openjdk.java.net
Fri Jan 29 08:35:40 UTC 2021
On Thu, 28 Jan 2021 14:26:32 GMT, Andrew Haley <aph at openjdk.org> wrote:
>> This patch transforms '(x >>> rshift) + (x << lshift)' into
>> 'RotateRight(x, rshift)' during GVN phase when both the shift exponents
>> are constants and their sum equals to the number of bits for the type
>> of shift base.
>>
>> This patch implements some new match rules for AArch64 instructions
>> which can take ROR as the optional shift. Such instructions are 'and',
>> 'or', 'eor', 'eon', 'bic' and 'orn'.
>>
>> ror w11, w2, #5
>> eor w0, w1, w11
>>
>> With this patch, above code could be optimized to below:
>>
>> eor w0, w1, w2, ror #5
>>
>> Finally, the patch refactors TestRotate.java[1][2].
>>
>> Tested jtreg TestRotate.java, hotspot::hotspot_all_no_apps,
>> jdk::jdk_core, langtools::tier1.
>>
>> [1] https://bugs.openjdk.java.net/browse/JDK-8252776
>> [2] https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2020-September/039911.html
>
> All that remains to do is the benchmarks.
I benchmarked on 7 platforms with jmh test[1], most of them were hard to see any performance changes. On one platform the performance become bad, and seems a little unstable.
Before:
Benchmark Mode Cnt Score Error Units
Rotation.addRotateRight avgt 15 270.080 ± 0.630 ns/op
Rotation.andRotateRight avgt 15 269.000 ± 0.226 ns/op
Rotation.bicRotateRight avgt 15 269.269 ± 0.769 ns/op
Rotation.eonRotateRight avgt 15 269.456 ± 0.056 ns/op
Rotation.ornRotateRight avgt 15 269.681 ± 1.028 ns/op
Rotation.xorRotateRight avgt 15 270.953 ± 2.764 ns/op
After:
Benchmark Mode Cnt Score Error Units
Rotation.addRotateRight avgt 15 399.995 ± 10.702 ns/op
Rotation.andRotateRight avgt 15 399.517 ± 7.933 ns/op
Rotation.bicRotateRight avgt 15 396.602 ± 2.038 ns/op
Rotation.eonRotateRight avgt 15 401.978 ± 17.371 ns/op
Rotation.ornRotateRight avgt 15 431.052 ± 73.711 ns/op
Rotation.xorRotateRight avgt 15 410.447 ± 42.929 ns/op
------------------
[1] http://cr.openjdk.java.net/~xgong/rfr/8256438/Rotation.java
-------------
PR: https://git.openjdk.java.net/jdk/pull/1858
More information about the hotspot-compiler-dev
mailing list