RFR: 8275202: C2: optimize out more redundant conditions

Quan Anh Mai qamai at openjdk.org
Sat Dec 21 16:15:52 UTC 2024


On Wed, 18 Dec 2024 13:38:20 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> src/hotspot/share/opto/loopConditionalPropagation.cpp line 519:
>> 
>>> 517:           Node* cmp2 = cmp->in(2);
>>> 518:           sync(iff);
>>> 519:           // narrowing the type of a LoadRange could cause a range check to optimize out and a Load to be hoisted above
>> 
>> Not sure if you are still working on this one. Here you can remove the range check if you pin all the nodes that depend on this check. Similar logic can be found in range check smearing.
>
> 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.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14586#discussion_r1894652183


More information about the hotspot-compiler-dev mailing list