RFR: 8347499: C2: Make `PhaseIdealLoop` eliminate more redundant safepoints in loops [v3]

Qizheng Xing qxing at openjdk.org
Tue Oct 14 09:53:29 UTC 2025


On Tue, 16 Sep 2025 05:44:08 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Qizheng Xing has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Improve documentation comments
>
> src/hotspot/share/opto/loopnode.cpp line 3818:
> 
>> 3816: //               /   |  |
>> 3817: //              v    +--+
>> 3818: //        exit  4
> 
> This drawing seems a bit confusing. There seem to be 3 edges coming out of 2.
> Do you think you could fix it too, just to create more clarity in the code?

I've re-drawn the graph.

> src/hotspot/share/opto/loopnode.cpp line 3830:
> 
>> 3828: //
>> 3829: // The insights into the problem:
>> 3830: //  A) Counted loops are okay
> 
> What does it mean to be "okay"? Why are they "okay"?

Added more comments.

> It seems the logic was: only outer loops need to mark safepoints for protection, because only loops further in can remove safepoints. Is that still correct?

That's correct. Updated this comment.

> test/hotspot/jtreg/compiler/c2/irTests/TestLoopSafepoint.java line 24:
> 
>> 22:  */
>> 23: 
>> 24: package compiler.c2.irTests;
> 
> We'd like to get away from putting all IR tests in `irTests`, and we'd rather put them into thematic directories.
> Proposal: `compiler/loopopts/TestRedundantSafePointElimination.java`

Moved to `compiler/loopopts/TestRedundantSafepointElimination.java`.

> test/hotspot/jtreg/compiler/c2/irTests/TestLoopSafepoint.java line 33:
> 
>> 31:  * @summary Tests that redundant safepoints can be eliminated in loops.
>> 32:  * @library /test/lib /
>> 33:  * @requires vm.compiler2.enabled
> 
> Is this `@requires` strictly required? If not, remove it so we can run these tests also with C1 and other compilers.

Removed the `@requires`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23057#discussion_r2428559736
PR Review Comment: https://git.openjdk.org/jdk/pull/23057#discussion_r2428561137
PR Review Comment: https://git.openjdk.org/jdk/pull/23057#discussion_r2428563274
PR Review Comment: https://git.openjdk.org/jdk/pull/23057#discussion_r2428564441
PR Review Comment: https://git.openjdk.org/jdk/pull/23057#discussion_r2428565010


More information about the hotspot-compiler-dev mailing list