RFR: 8366815: C2: Delay Mod/Div by constant transformation [v2]

Vladimir Ivanov vlivanov at openjdk.org
Mon Oct 27 18:44:15 UTC 2025


On Fri, 24 Oct 2025 09:10:36 GMT, Hannes Greule <hgreule at openjdk.org> wrote:

>> The test cases show examples of code where `Value()` previously wasn't run because idealization took place before, resulting in less precise type analysis.
>> 
>> Please let me know what you think.
>
> Hannes Greule has updated the pull request incrementally with one additional commit since the last revision:
> 
>   expand comments

src/hotspot/share/opto/divnode.cpp line 556:

> 554:   // Less precise comparisons still work after transform_int_divide, e.g.,
> 555:   // comparing with >= 21_476 does not conflict with the off-by-one overapproximation.
> 556:   if (phase->is_IterGVN() == nullptr) {

`can_reshape == true` is equivalent and IMO a bit clearer than a subtype check.

src/hotspot/share/opto/divnode.cpp line 1129:

> 1127:   // After idealizing, we have a subtraction from x, which means without
> 1128:   // recognizing that as a modulo operation, we end up with a range of TypeInt::INT.
> 1129:   if (phase->is_IterGVN() == nullptr) {

Should it go after `!ti->is_con()` check?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27886#discussion_r2466699555
PR Review Comment: https://git.openjdk.org/jdk/pull/27886#discussion_r2466702392


More information about the hotspot-compiler-dev mailing list