RFR: 8320649: C2: Optimize scoped values [v9]

Emanuel Peter epeter at openjdk.org
Thu Apr 4 13:42:18 UTC 2024


On Wed, 6 Mar 2024 13:45:31 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> src/hotspot/share/opto/loopTransform.cpp line 3790:
>> 
>>> 3788:         phase->do_peeling(this, old_new);
>>> 3789:         return false;
>>> 3790:       }
>> 
>> Just because I'm curious: why do the other places not already peel these loops? I.e. why do we need this here?
>
> Peeling looks for a loop invariant condition with one branch that exits the loop because then peeling makes the test in the loop body redundant with the one in the peeled iteration. Here, if there's a `ScopedValue.get()` on a loop invariant `ScopedValue` object, peeling one iteration will make `ScopedValue.get()` in the loop body redundant with the one in the peeled iteration. So it's not quite the same, at least, because for `ScopedValue.get()` the optimization applies whether `ScopedValue.get()` causes an exit of the loop or not.

Ah, great, thanks for the explanation!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16966#discussion_r1551659782


More information about the hotspot-compiler-dev mailing list