RFR: 8350756: C2 SuperWord Multiversioning: remove useless slow loop when the fast loop disappears [v2]

Emanuel Peter epeter at openjdk.org
Tue Mar 4 09:40:52 UTC 2025


On Tue, 4 Mar 2025 08:41:46 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> Emanuel Peter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   for Christian v1
>
> src/hotspot/share/opto/loopnode.cpp line 6653:
> 
>> 6651:   if (!_verify_only && n->Opcode() == Op_OpaqueMultiversioning) {
>> 6652:     _multiversion_opaque_nodes.push(n);
>> 6653:   }
> 
> I'm wondering if we should do it here or as a list in `Compile`, similar to what we do with Parse and Template Assertion Predicates:
> https://github.com/openjdk/jdk/blob/1f10ffba88119caab169b1fc43ccfd143e3b85a6/src/hotspot/share/opto/compile.hpp#L372-L374
> 
> Doing it in `PhaseIdealLoop` has the advantage that we limit the lifetime of the list whereas in `Compile` it's live until the entire compilation is done - which is a little too long. The disadvantage with having the list in `PhaseIdealLoop` is that you reallocate and reinitialize the list over and over again. So, I'm not entirely clear which one is better.
> 
> Since we also do it like that for zero trip guards, we can also move forward with this and revisit it again later if we decide that we should move it to `Compile`.
> 
> While thinking about this, it would have been great to have a class `LoopOpts` where we can store all such things that should be live over multiple loop opts pass but which is then not used anymore. Anyway, that's definitely out of scope.

Yes, I just worked from `_zero_trip_guard_opaque_nodes` / `PhaseIdealLoop::eliminate_useless_zero_trip_guard` as I was suggested.

I don't think that the life-time makes such a big difference, the array is quite small.

Also: would we ever remove elements from that list if it is in `Compile`? Or would we just keep adding things, and iterate over more and more elements, even those that are long removed from the graph?

If there is no clear reason to change the code, I'd prefer to leave it as is 😅

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23865#discussion_r1979016556


More information about the hotspot-compiler-dev mailing list