RFR: 8304049: C2 can not merge trivial Ifs due to CastII

Yi Yang yyang at openjdk.org
Wed Mar 15 12:48:20 UTC 2023


On Wed, 15 Mar 2023 12:13:21 GMT, Roland Westrelin <roland at openjdk.org> wrote:

> Why not do this (and the other similar #12978) by extending the logic where the merge happens in `PhaseIdealLoop::identical_backtoback_ifs()`?
> 
> I see a few reasons why that would be preferable:
> 
> * if the motivation is only to merge ifs, is it a good thing to transform the graph blindly during GVN when we don't know if the ifs are even candidates for merging?
> * having that code far away from where the merge transformation happens makes understanding what's going on harder
> * dropping a Cast node is risky, in general, because they sometimes carry a dependence that's required for correctness. So it should be done with care.

Hi @rwestrel, extending identical_backtoback_ifs is another candidate, but these IR shapes(this and #12978, ) are common cases(tty tells me in newly added Identity):
- Bool (Cmp A B) and Bool (Cmp B A)
- Bool (Cmp (Cast P1) P2) and Bool (Cmp P1 P2)
They affect split_if but they are not related to split_if. Intuitively, Bool (Cmp A B) and Bool (Cmp B A) are identical shapes and could be transformed locally.

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

PR: https://git.openjdk.org/jdk/pull/13039


More information about the hotspot-compiler-dev mailing list