8244926: Add absolute check for int/long to generate Abs nodes
Yang Zhang
Yang.Zhang at arm.com
Fri Jun 12 05:28:12 UTC 2020
Hi Nils
Thanks a lot for your review.
Hi reviewers
Any other comments?
Regards,
Yang
-----Original Message-----
From: hotspot-compiler-dev <hotspot-compiler-dev-bounces at openjdk.java.net> On Behalf Of Nils Eliasson
Sent: Thursday, June 11, 2020 5:21 PM
To: hotspot-compiler-dev at openjdk.java.net
Subject: Re: 8244926: Add absolute check for int/long to generate Abs nodes
Hi Yang,
The patch looks good.
Reviewed.
Best regards,
Nils Eliasson
On 2020-06-11 07:36, Yang Zhang wrote:
> Hi,
>
> Ping it again. Could anyone help to review this patch?
>
> Regards
> Yang
>
> -----Original Message-----
> From: hotspot-compiler-dev
> <hotspot-compiler-dev-bounces at openjdk.java.net> On Behalf Of Yang
> Zhang
> Sent: Thursday, June 4, 2020 4:28 PM
> To: hotspot-compiler-dev at openjdk.java.net
> Cc: nd <nd at arm.com>
> Subject: RFR: 8244926: Add absolute check for int/long to generate Abs
> nodes
>
> Hi,
>
> May I have a review of this enhancement of absolute check for int/long?
>
> JBS: https://bugs.openjdk.java.net/browse/JDK-8244926
> Webrev: http://cr.openjdk.java.net/~yzhang/8244926/webrev.00/
>
> There is absolute value check for float/double already [1]. In this patch, absolute value check for integer/long is added. The following patterns can be matched to AbsI/L nodes:
> ((a < 0) ? -a : a)
> ((a <= 0) ? -a : a)
> ((a > 0) ? a : -a)
> ((a >= 0) ? a : -a)
>
> Test case:
> public static int absi(int a) {
> return ((a < 0) ? -a : a);
> }
>
> With c2, AbsI node is generated and matched. The following snippet is generated on x86:
> 0x00007f67c8b6155b: mov %ecx,%r11d
> 0x00007f67c8b6155e: sar $0x1f,%r11d
> 0x00007f67c8b61562: mov %ecx,%r10d
> 0x00007f67c8b61565: xor %r11d,%r10d
> 0x00007f67c8b61568: sub %r11d,%r10d
>
> On AArch64:
> 0x0000ffffa8b878e4: cmp w3, wzr
> 0x0000ffffa8b878e8: cneg w17, w3, lt // lt = tstop
>
> Note: AArch64 result is based on this patch which is in review [2].
>
> Test:
> Full jtreg on x86 and AArch64, no new failure
>
> Performance:
> Jmh test is uploaded.
> http://cr.openjdk.java.net/~yzhang/8244926/TestScalar.java
>
> X86
> Before:
> Benchmark (size) Mode Cnt Score Error Units
> TestScalar.testAbsI1 1024 avgt 25 2648.235 ± 0.810 us/op
> TestScalar.testAbsI2 1024 avgt 25 2647.702 ± 0.431 us/op
> TestScalar.testAbsI3 1024 avgt 25 2647.605 ± 0.346 us/op
> TestScalar.testAbsI4 1024 avgt 25 2647.574 ± 0.651 us/op
> TestScalar.testAbsL1 1024 avgt 25 3165.787 ± 0.976 us/op
> TestScalar.testAbsL2 1024 avgt 25 3166.582 ± 2.217 us/op
> TestScalar.testAbsL3 1024 avgt 25 3168.097 ± 4.071 us/op
> TestScalar.testAbsL4 1024 avgt 25 3167.222 ± 2.573 us/op
>
> After:
> Benchmark (size) Mode Cnt Score Error Units
> TestScalar.testAbsI1 1024 avgt 25 2264.637 ± 1.164 us/op
> TestScalar.testAbsI2 1024 avgt 25 2264.318 ± 0.427 us/op
> TestScalar.testAbsI3 1024 avgt 25 2264.998 ± 0.903 us/op
> TestScalar.testAbsI4 1024 avgt 25 2264.602 ± 0.625 us/op
> TestScalar.testAbsL1 1024 avgt 25 2376.513 ± 0.345 us/op
> TestScalar.testAbsL2 1024 avgt 25 2376.681 ± 0.565 us/op
> TestScalar.testAbsL3 1024 avgt 25 2377.012 ± 0.643 us/op
> TestScalar.testAbsL4 1024 avgt 25 2376.921 ± 0.699 us/op
>
> AArch64:
> Before:
> Benchmark (size) Mode Cnt Score Error Units
> TestScalar.testAbsI1 1024 avgt 25 1858.831 ± 1.249 us/op
> TestScalar.testAbsI2 1024 avgt 25 1860.248 ± 1.365 us/op
> TestScalar.testAbsI3 1024 avgt 25 1859.571 ± 1.177 us/op
> TestScalar.testAbsI4 1024 avgt 25 1859.970 ± 0.882 us/op
> TestScalar.testAbsL1 1024 avgt 25 1871.520 ± 2.592 us/op
> TestScalar.testAbsL2 1024 avgt 25 1872.728 ± 2.301 us/op
> TestScalar.testAbsL3 1024 avgt 25 1872.852 ± 2.455 us/op
> TestScalar.testAbsL4 1024 avgt 25 1872.720 ± 2.652 us/op
>
> After:
> Benchmark (size) Mode Cnt Score Error Units
> TestScalar.testAbsI1 1024 avgt 25 1422.781 ± 1.788 us/op
> TestScalar.testAbsI2 1024 avgt 25 1423.778 ± 2.612 us/op
> TestScalar.testAbsI3 1024 avgt 25 1424.327 ± 2.065 us/op
> TestScalar.testAbsI4 1024 avgt 25 1423.269 ± 1.437 us/op
> TestScalar.testAbsL1 1024 avgt 25 1434.279 ± 2.312 us/op
> TestScalar.testAbsL2 1024 avgt 25 1433.900 ± 2.341 us/op
> TestScalar.testAbsL3 1024 avgt 25 1435.967 ± 2.270 us/op
> TestScalar.testAbsL4 1024 avgt 25 1437.495 ± 0.957 us/op
>
> [1]
> http://hg.openjdk.java.net/jdk/jdk/file/dd652a1b2a39/src/hotspot/share
> /opto/cfgnode.cpp#l1519 [2]
> https://mail.openjdk.java.net/pipermail/aarch64-port-dev/2020-May/0088
> 61.html
>
>
> Regards,
> Yang
>
More information about the hotspot-compiler-dev
mailing list