RFR(S): 8210152: Optimize integer divisible by power-of-2 check

dean.long at oracle.com dean.long at oracle.com
Fri Aug 31 23:44:35 UTC 2018


Hi Pengfei.  It looks like your matching may allow more patterns than 
expected.  I was expecting it to look for < 0 or >= 0 for the 
conditional negation, but I don't see it.  The code in is_absolute() 
seems to be doing something similar to yours, but takes into account the 
kind of compare being done.

dl


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