RFR: 8349139: C2: Div looses dependency on condition that guarantees divisor not null in counted loop
Roland Westrelin
roland at openjdk.org
Thu Feb 13 17:06:15 UTC 2025
On Thu, 13 Feb 2025 16:54:18 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
> My understanding here is that when the backedge is removed, the loop head (which is a merge) is idealized out, and as a result, the `Phi` is idealized to its only live input. I think the idealization of the `Phi` is the issue here, the `Phi` is pinned at the control input it is at, so the result of the idealization cannot float freely. As a result, I propose fixing the idealization of `Phi` to become a `CastNode` that has `UnknownControlDependency` on its input. What do you think?
For any `Phi`? This seems like an issue that's specific to the counted loop iv. I don't think we want to add `CastII` nodes unless we're sure they are needed.
I thought about adding the `CastII` when the loop backedge disappears but I think when this happens it's too late to find which of the `Phi` is the loop phi.
> I think this may be true for other kind of merge points as well. For example, if you perform conditional elimination (the patch you have worked at) on this code:
Are you talking about https://bugs.openjdk.org/browse/JDK-8275202 ?
But then wouldn't we want to add the `CastII` only if one is needed, that is when that pass runs, so we don't end up with those casts all over the place?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23617#issuecomment-2657227412
More information about the hotspot-compiler-dev
mailing list