RFR(S): 8210152: Optimize integer divisible by power-of-2 check
Vladimir Kozlov
vladimir.kozlov at oracle.com
Fri Aug 31 22:38:23 UTC 2018
Hi Pengfei,
I don't see where negation is coming from for 'X % 2 == 0' expression.
It should be only 2 instructions: 'cmp (X and 1), 0'
I will look on it next week. But it would be nice if you can provide small test to show this issue.
Thanks,
Vladimir
On 8/29/18 3:21 AM, Pengfei Li wrote:
> Hi,
>
> Please help review this C2 compiler patch that optimize the integer divisible by 2^n (power-of-2) check.
>
> In original integer divisible by 2^n check, C2 compiler generates conditional negation instructions before the zero check. But actually the conditional negation is redundant since the negation of a zero (non-zero) is also a zero (non-zero). This patch adds an ideal transformation that change the IR pattern "bool eq/ne (cmp (phi (X -X) 0))" into "bool eq/ne (cmp X 0)". With this optimization, the divisible by 2^n check can be done with only 1 or 2 machine instructions.
>
> JBS: https://bugs.openjdk.java.net/browse/JDK-8210152
> webrev: http://cr.openjdk.java.net/~zyao/8210152/webrev.00/
>
> I've run jtreg full tests with this patch on an x86_64 and an aarch64 server respectively. No new failures were found.
>
> --
> Thanks,
> Pengfei
>
More information about the hotspot-compiler-dev
mailing list