RFR: 8275202: C2: optimize out more redundant conditions [v3]
Roland Westrelin
roland at openjdk.org
Fri Jun 6 14:24:55 UTC 2025
On Sat, 21 Dec 2024 16:12:49 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
>> Yes, I'm still working on this. I'll update this PR soon, hopefully. I reworked it quite a bit.
>
> Some more observations: When removing an `IfNode`, not only for `LoadNode`, you will need to pin all nodes that `depends_only_on_test` at that point (e.g. `ConstraintCast`), since the node does not only depend on the immediate dominating test (if any) but on the whole sequence of control nodes leading to that position. This can be done by e.g upgrading a `RegularDependency` `ConstraintCast` to one with `StrongDependency`. However, this action can lead to the node not able to float as freely. So I think before completing all loop opts, you should refrain from removing any `IfNode` of which the taken path has at least 1 node that `depends_only_on_test`. Pruning the untaken branch should still be done to simplify the graph. I think you have probably thought about this but just in case it can help.
Thanks for the observations.
The updated patch does pin a `LoadNode` when a range check it depends on is optimized out. It doesn't pin it at the control that immediately dominates the eliminated range check. Instead, it goes over the dominating controls until it finds the earliest control at which the type of the range check test constant folds and sets the `LoadNode` control to that control. So it pins it at the earliest possible control.
The new constant propagation pass is also run after all loop opts by default so, nodes get pinned late in the compilation process.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14586#discussion_r2132296301
More information about the hotspot-compiler-dev
mailing list