CreateEx nodes that are initially ready in LCM (that is, do not have any input dependency in their basic block) must be scheduled at the beginning of their block, right after Phi and Parm nodes. This is currently enforced by placing them at the beginning of the initial ready list [1] so that they are selected before any other node [2]. Relying on the order of the ready list for correctness is fragile, and forces a tie between projections and other CreateEx nodes that are not initially ready in LCM node selection [2]. This tie can potentially lead to projections not being scheduled next to their parents, thus breaking an invariant of LCM [3].
A more robust solution would be to pre-schedule CreateEx nodes that are initially ready in a similar manner to how Phi and Parm nodes are handled, and break the tie between projections and other CreateEx nodes in favor of projections.
[1] https://github.com/openjdk/jdk/blob/89392fb15e9652b7b562b3511f79bda725c5499c/src/hotspot/share/opto/lcm.cpp#L1079-L1082
[2] https://github.com/openjdk/jdk/blob/89392fb15e9652b7b562b3511f79bda725c5499c/src/hotspot/share/opto/lcm.cpp#L534-L542
[3] https://github.com/openjdk/jdk/blob/89392fb15e9652b7b562b3511f79bda725c5499c/src/hotspot/share/opto/block.cpp#L1277-L1278
A more robust solution would be to pre-schedule CreateEx nodes that are initially ready in a similar manner to how Phi and Parm nodes are handled, and break the tie between projections and other CreateEx nodes in favor of projections.
[1] https://github.com/openjdk/jdk/blob/89392fb15e9652b7b562b3511f79bda725c5499c/src/hotspot/share/opto/lcm.cpp#L1079-L1082
[2] https://github.com/openjdk/jdk/blob/89392fb15e9652b7b562b3511f79bda725c5499c/src/hotspot/share/opto/lcm.cpp#L534-L542
[3] https://github.com/openjdk/jdk/blob/89392fb15e9652b7b562b3511f79bda725c5499c/src/hotspot/share/opto/block.cpp#L1277-L1278
- relates to
-
JDK-8285820 C2: LCM prioritizes locally dependent CreateEx nodes over projections after 8270090
- Resolved