RFR: 8267376: C2: Deduce the result bound of ModXNode
Tobias Hartmann
thartmann at openjdk.java.net
Mon Jul 5 09:27:57 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.
You could try to add an assert that fails if the path is reached, run some more sophisticated testing and extract a simple test case from a failing test.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4179
More information about the hotspot-compiler-dev
mailing list