JDK-8323652 : C2: PhaseIdeal::build_loop_late_post_work() does not treat DivL/ModL as unpinned
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8,11,17,21,22,23
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2024-01-12
  • Updated: 2024-08-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
While working on JDK-8323101, I've noticed that the test case triggers with DivI/ModI cases but not with DivL/ModL cases even though the graph looks exactly the same (apart from using *L instead of *I nodes). 

I had a closer look and found that the DivL/ModL nodes have a different late control compared to the DivI/ModI in the same test. In fact, early and late control are exactly the same for the DivL/ModL nodes while they are different for the DivI/ModI nodes  The reason is that DivL/ModL nodes are not treated as unpinned in PhaseIdeal::build_loop_late_post_work() while DivI/ModI nodes are.

I think we just miss DivL/ModL nodes in this switch statement where we treat nodes as unpinned:
https://github.com/openjdk/jdk/blob/82a63a03c0155288e8e43b9f766c8be70be50b6a/src/hotspot/share/opto/loopnode.cpp#L6091-L6125

I dug deeper and found that DivL/ModL nodes were added later after the switch statement was already there. We probably just forgot back there to adjust the switch statement to also special case them.

We should try to add an IR test which shows that it is beneficial to treat them unpinned in PhaseIdeal::build_loop_late_post_work(). This can most likely be done by utilizing the Split If optimization.