RFR: 8308994: C2: Re-implement experimental post loop vectorization [v2]

Emanuel Peter epeter at openjdk.org
Mon Jul 3 14:40:13 UTC 2023


On Mon, 3 Jul 2023 07:54:38 GMT, Pengfei Li <pli at openjdk.org> wrote:

>> src/hotspot/share/opto/loopnode.hpp line 143:
>> 
>>> 141:     if (is_vector_masked()) {
>>> 142:       return false;
>>> 143:     }
>> 
>> Does this mean that the post-loop has a `CountedLoop` node, but it does not adhere to the counted-loop assumptions, such as having a `incr`, `limit`, `phi` etc? With the old post-loop-vectorization, the LoopNode would always fold away, so it would disappear after IGVN. But now it would stick around, right? Could that turn out to be a problem?
>
> After being vectorized, the post loop still has `phi`, `incr` and `limit` as before. In other words, the post loop is still a loop now. I think the only difference is that the loop stride value is not a constant any more (as we introduces the `VectorMaskTrueCountNode` for the new stride). The old implementation of post loop vectorization makes the vector-masked post loop run only once so it can optimize the `LoopNode` away. But we cannot do this now without doing multi-versioning. (Without the scalar post loop, loop may run insufficient iterations when the "atomic" post loop is not entered.)

I see. Maybe it would be cleaner to separate the "outside/after" loop uses of the `incr` with what happens inside the loop? If we do take the backedge, the stride is a known constant. Only if we exit do we need to add the unknown number of iterations with `VectorMaskTrueCountNode`. See also this comment https://github.com/openjdk/jdk/pull/14581/files#r1250973547

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14581#discussion_r1250974056


More information about the hotspot-compiler-dev mailing list