RFR: 8347901: C2 should remove unused leaf / pure runtime calls

Vladimir Ivanov vlivanov at openjdk.org
Tue May 6 18:21:13 UTC 2025


On Tue, 6 May 2025 07:43:57 GMT, Marc Chevalier <mchevalier at openjdk.org> wrote:

>> support arbitrary nodes to be lowered into leaf runtime calls.

A leaf runtime call which doesn't depend or change memory state can be inserted at arbitrary points in the graph. So, an arbitrary data node can be lowered into a runtime call once the place to insert it is known/chosen.  


> Overall, I see the weaknesses of my design, but I'm not sure which direction to take instead.

I suggest to experiment with untangling `ModF`/`ModD` from `CallLeaf`, making them expensive nodes (to avoid commoning during GVN) , and still lower them into `CallLeaf`.
(It doesn't have to be part of existing macro expansion. Depending on implementation considerations, earlier or later may be more appropriate. But it should be expanded before RA kicks in.)

The hard part is probably related to picking a point in CFG to insert the call, but the control the node has may be not suitable for that (e.g., if inputs don't dominate control anymore). In that case, updating control input during loop opts may be an option.

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

PR Comment: https://git.openjdk.org/jdk/pull/24966#issuecomment-2855510094


More information about the graal-dev mailing list