RFR: 8267376: C2: Deduce the result bound of ModXNode

Nils Eliasson neliasso at openjdk.java.net
Wed Jun 2 08:06:32 UTC 2021


On Tue, 25 May 2021 03:16:37 GMT, Yi Yang <yyang at openjdk.org> wrote:

> if the divisor is a constant and not equal to 0, it's possible to deduce the final bound of ModXNode given that the following rules:
> 
>        x % -y ==> [0, y - 1]
>        x % y ==> [0, y - 1]
>        -x % y ==> [-y + 1, 0]
>        -x % -y ==> [-y + 1, 0]
> 
> 
> FYI: The original purpose of this patch is to eliminate array access range check(e.g. `arr[val%5]`) which discussed in https://github.com/openjdk/jdk/pull/4083#issuecomment-846971247, because ModXNode would be transformed to other nodes during IGVN, RangeCheckNode is still generated when accessing array element. Regardless of eliminating array access range check, it's still reasonable to deduce the bound of % operation if the divisor is known constant.

Can you add a test that exercises this code path?

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

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


More information about the hotspot-compiler-dev mailing list