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

Emanuel Peter epeter at openjdk.org
Tue Jul 4 12:01:17 UTC 2023


On Mon, 3 Jul 2023 09:20:19 GMT, Pengfei Li <pli at openjdk.org> wrote:

>> Or is there a clear reason why the two are too different?
>
> We need more investigation and discussions about this. Will discuss with you later.

Sounds good.

>> Write:
>> Vector element size does not match of the store in the statement.
>
> Yes, we have tried supporting type conversions (between different type sizes) but current solution is not mature and not included in this patch. So this limitation is added here.

Ok, fine. Leave that for the future.

>> Does that not prevent `a[i+1]` from being accepted?
>
> That's a really corner case. In C2's ideal graph, most loop statements eventually uses the loop induction variable `phi` node as a input. That's good. But, there is one exception that a loop statement has a sub-expression of `iv + stride`. In this kind of cases, IGVN may do common sub-expression elimination and the inputs may come from the loop increment node thereafter. As the final step of vector masked transformation replaces the loop increment node, the calculation for `iv + stride` will also be replaced as well and it causes mis-compilation. In current patch, I duplicate the loop increment pattern for update (that's why we have `is_loop_incr_pattern()`, see commit 2) to avoid this issue, but currently it only applies to the expression not in array indices, such as `a[i] = i + 1`. For the patterns like `a[i+1] = i`, I'm still looking for a better approach to handle.

Ok yes. You will have to find a way to separate out all these kinds of cases:

Using incr on backedge
Using incr as "i + stride" inside loop
Using incr outside/after loop -> final value + 1 -> count iterations


BTW: what happens if you use the `phi` directly after/outside the loop? Do you properly count the final value?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14581#discussion_r1251930727
PR Review Comment: https://git.openjdk.org/jdk/pull/14581#discussion_r1251930451
PR Review Comment: https://git.openjdk.org/jdk/pull/14581#discussion_r1251926315


More information about the hotspot-compiler-dev mailing list