RFR: 8328528: C2 should optimize long-typed parallel iv in an int counted loop [v3]

Kangcheng Xu kxu at openjdk.org
Mon May 13 13:54:05 UTC 2024


On Thu, 18 Apr 2024 09:32:19 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Can you also be consistent with the names all the way through your comments? I suggest you just only use `stride_con`, and not `stride`. You can use `i` and `a`, if you want. But then it would be helpful if you had two lines with identical expressions, but where you make the transition from `i` to `phi`.
>
> Ah. It seems that we require `stride2 / stride` to be a lossless division in the code. A comment about that limitation would be helpful. And I think you should also check if there are tests that cover cases where the division would be lossy.

> ...be consistent with the names...

I had this concern, especially `i` vs `phi`. I didn't think it was reasonable to call the iterator `phi` only because the optimization code calls such a value so by extracting from the phi node. I agree to keep things consistent. The example to trivial to be understood anyway. I updated the naming.

> It seems that we require stride2 / stride to be a lossless division in the code.

Not only lossless division (i.e., rounding-towards-zero) is used, the optimization requires this division to be exact with no remainders. Checks are in place to make sure optimization only happens if this condition is met:

> `if ((ratio_con * stride_con) == stride_con2) { // Check for exact`

I updated the comments to be more expressive regarding this.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18489#discussion_r1598512900


More information about the hotspot-compiler-dev mailing list