RFR: 8356813: Improve Mod(I|L)Node::Value

Manuel Hässig mhaessig at openjdk.org
Tue May 20 06:59:53 UTC 2025


On Mon, 19 May 2025 16:06:21 GMT, Hannes Greule <hgreule at openjdk.org> wrote:

>> src/hotspot/share/opto/divnode.cpp line 1242:
>> 
>>> 1240:   // The magnitude of the divisor is in range [1, 2^31].
>>> 1241:   // We know it isn't 0 as we handled that above.
>>> 1242:   // That means at least one value is nonzero, so its absolute value is bigger than zero.
>> 
>> Is that really what you checked above? AFAIU, above you check whether the divisor is a zero constant. But if the divisor is not a constant, then its range might still contain zero. You should check this claim using the bounds, otherwise this will not hold.
>
> We only care about the magnitude of the divisor here. `_lo == _hi == 0` can't be the case here anymore, because that means we have a constant 0. As we use the larger absolute value of the bounds, it can't be 0. We don't need to care about a 0 divisor (if we have a range of e.g., -2..2 here), as the node is kept alive as long as we can't prove in `Ideal` that the divisor isn't 0 (https://github.com/openjdk/jdk/blob/20a19bf545dd55f21b71eba2e2313dc12c359157/src/hotspot/share/opto/divnode.cpp#L1095-L1100)

That makes sense. Thank you for the explanation.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25254#discussion_r2097128633


More information about the hotspot-compiler-dev mailing list