RFR: 8345766: C2 should emit macro nodes for ModF/ModD instead of calls during parsing [v7]

Emanuel Peter epeter at openjdk.org
Fri Jan 17 08:27:40 UTC 2025


On Fri, 17 Jan 2025 08:14:20 GMT, Theo Weidmann <tweidmann at openjdk.org> wrote:

>> C2 currently emits runtime calls if the platform rules do not support lowering floating point remainder operations. For example, for float:
>> 
>> https://github.com/openjdk/jdk/blob/fbbc7c35f422294090b8c7a02a19ab2fb67c7070/src/hotspot/share/opto/parse2.cpp#L2305-L2318
>> 
>> https://github.com/openjdk/jdk/blob/fbbc7c35f422294090b8c7a02a19ab2fb67c7070/src/hotspot/share/opto/parse2.cpp#L1099-L1109
>> 
>> The only platform, which currently supports this, however, is x86_32. On all other platforms, runtime calls are generated directly during parsing, which prevent any constant folding or other idealizations. Even C1 can perform these optimizations, resulting in significantly lower C2 performance compared to C1 for simple test cases. This function was observed to be around 15x slower with C2 compared to C1 due to redundant runtime calls:
>> 
>> 
>> public static double process(final double x) {
>>         double w = (double) 0.1;
>>         double p = 0;
>>         p = (double) (3.109615012413746E307 % (w % Z));
>>         p = (double) (7.614949555185036E307 / (x % x)); // <- return value only dependends on this line
>>         return (double) (x * p);
>> }
>> 
>> 
>> To fix this, this PR turns ModFNode and ModDNode into macros, which are always created during parsing. They support idealization (constant folding) and are lowered to runtime calls during macro expansion. For simplicity, these operations will now also call into the runtime on x86_32, as this platform is deprecated.
>
> Theo Weidmann has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update copyright year

Changes requested by epeter (Reviewer).

test/hotspot/jtreg/compiler/c2/irTests/ModDNodeTests.java line 32:

> 30: /*
> 31:  * @test
> 32:  * @bug 8332268

You should probably add the bug id of this issue.
Suggestion:

 * @bug 8332268 8345766

test/hotspot/jtreg/compiler/c2/irTests/ModFNodeTests.java line 32:

> 30: /*
> 31:  * @test
> 32:  * @bug 8332268

Suggestion:

 * @bug 8332268 8345766

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

PR Review: https://git.openjdk.org/jdk/pull/22786#pullrequestreview-2558238022
PR Review Comment: https://git.openjdk.org/jdk/pull/22786#discussion_r1919731672
PR Review Comment: https://git.openjdk.org/jdk/pull/22786#discussion_r1919731906


More information about the hotspot-compiler-dev mailing list