RFR: 8328528: C2 should optimize long-typed parallel iv in an int counted loop [v23]
Kangcheng Xu
kxu at openjdk.org
Fri Oct 18 21:10:55 UTC 2024
On Fri, 18 Oct 2024 16:21:33 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
>> Kangcheng Xu has updated the pull request incrementally with one additional commit since the last revision:
>>
>> requires c2 enabled for IR tests
>
> src/hotspot/share/opto/loopnode.cpp line 3951:
>
>> 3949: // int a = init2
>> 3950: // for (int phi = init; phi < limit; phi += stride_con) {
>> 3951: // a = init2 + (phi - init) * (stride_con2 / stride_con)
>
> A nit but in this pseudo code, shouldn't it be the post-incremented iv (i.e. `phi + stride_con`)? Because at that point, `phi` is not incremented, yet. You eventually replace the "parallel iv" (`phi2` in the actual code) which in the graph is the pre-incremented iv. Maybe naming the iv `phi` is a little bit confusing.
>
> You could also extend this to make it more explicit:
>
> int iv2 = init2
> int iv = init
> loop:
> if (phi >= limit) goto exit
> phi += stride_con
> iv2 = init2 + (iv - init) * (stride_con2 / stride_con)
> goto loop
> exit:
> ...
Good catch! I found it quite difficult to write pseudo code expressing the IR structure after transformation. I've updated the comment (mostly taking your example). Thanks!
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18489#discussion_r1807017876
More information about the hotspot-compiler-dev
mailing list