RFR: 8349139: C2: Div looses dependency on condition that guarantees divisor not null in counted loop [v2]
Quan Anh Mai
qamai at openjdk.org
Fri Mar 21 17:43:08 UTC 2025
On Fri, 21 Mar 2025 16:37:44 GMT, Roland Westrelin <roland at openjdk.org> wrote:
>> Hmmm, may be you are right. I think adding a comment at `PhiNode` saying that people must not rely on it being pinned at the `Region` for dependencies would be a wise move, I can't think of any reason for that besides value narrowing right now but being pinned is a property of `Phi` regardless and we should tell people not to rely on this behaviour.
>>
>> For this bug, I think a more general fix is to try to compare the type of the `Phi` with that of the input it is going to be replaced with. If the former is not wider than the latter then we add a `CastNode`, since the cast is only about value range, not strict dependency, we can use `CarryDependency` instead of `UnconditionalDependency`. Am I right?
>
> @merykitty see above my late reply to your comments if you missed it.
@rwestrel I have thought about this issue for a while and come to the conclusion that we do depend on a loop phi being a pinned node when doing optimizations (e.g `init <= iv < limit`). As a result, it seems logical to insert a pinned cast here so that the `Phi` does not freely float away when the loop disappears. I agree with your patch then.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23617#issuecomment-2744037407
More information about the hotspot-compiler-dev
mailing list