RFR: 8350756: C2 SuperWord Multiversioning: remove useless slow loop when the fast loop disappears [v7]
Vladimir Kozlov
kvn at openjdk.org
Tue Mar 4 18:50:05 UTC 2025
On Tue, 4 Mar 2025 16:01:17 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> @rwestrel asked me for this here:
>> https://github.com/openjdk/jdk/pull/22016#issuecomment-2684365921
>>
>> The idea: an unused `multiversion_if` (i.e. one where the `slow_loop` is still delayed, i.e. where the `fast_loop` has not yet added a runtime-check to the `multiversion_if`) can be constant-folded if the main `fast_loop` disappears. Because at that point we know that we will never add a new condition to the `multiversion_if`, and it will constant fold to true (towards the `fast_loop`) after loop-opts anyway.
>>
>> It also seems to fix a bug, where all multiversioned loops (fast / slow, pre/main/post) disappear, and then we are left with a if-diamond with the multiversion_if. This then hits assertion code in `PhaseIdealLoop::conditional_move`. This issue is also addressed with this patch here. I adjusted the code around that assert slightly to give better reporting and ensure we bail out of the optimization if we see an unexpected pattern.
>
> Emanuel Peter has updated the pull request incrementally with one additional commit since the last revision:
>
> pre loop not reliably folded, adapt IR rule
src/hotspot/share/opto/loopnode.cpp line 4566:
> 4564: if (lpt->_child == nullptr && lpt->is_counted()) {
> 4565: CountedLoopNode* head = lpt->_head->as_CountedLoop();
> 4566: if (head->is_main_loop() && head->is_multiversion_fast_loop()) {
Can any other than `main` loop marked as `is_multiversion_fast_loop`?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23865#discussion_r1980035523
More information about the hotspot-compiler-dev
mailing list