RFR: 8356813: Improve Mod(I|L)Node::Value [v4]
Emanuel Peter
epeter at openjdk.org
Mon Jun 2 11:46:54 UTC 2025
On Mon, 2 Jun 2025 11:34:22 GMT, Hannes Greule <hgreule at openjdk.org> wrote:
>> src/hotspot/share/opto/divnode.cpp line 1247:
>>
>>> 1245: // JVMS lrem bytecode: "the magnitude of the result is always less than the magnitude of the divisor"
>>> 1246: // "less than" means we can subtract 1 to get an inclusive upper bound in [0, 2^63-1]
>>> 1247: jlong hi = static_cast<jlong>(divisor_magnitude - 1);
>>
>> Hmm, this also looks confusing for the `T_INT` case. What about `-5`, does that then not become `max_julong - 5`, but it should have been `max_juint - 1`?
>
> We use `g_uabs()` to get the absolute value, that should't exceed 2^31 for int values (i.e., `g_uabs(min_jint) == 2^31`). So we should get into the right range here again. But I guess I can expand the comment to better explain that part.
@SirYwell I'm not 100% sure here, so please correct me if I'm wrong.
You are now always passing in a `jlong` value, so you always use `static inline julong g_uabs(jlong n) { return g_uabs((julong)n); }`, even for `T_INT`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25254#discussion_r2120898799
More information about the hotspot-compiler-dev
mailing list