JDK-8298019 : Investigate: reduce register pressure by avoiding use of pre-incremented Phi after loop
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 20
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2022-12-02
  • Updated: 2022-12-05
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
Was originally implemented with Opaque2 node, but the optimization broke once we performed IGVN rounds after Opaque2 were removed from graph.

JDK-8294540: removed Opaque2 nodes as the implementation was now broken, and triggered an assert.

Idea:
Loops often use the un-incremented Phi trip-count after the loop-exit. For example one might track the last index in a loop. This means we have two registers used for the trip-count, one for the pre-incremented value, and one for the incremented value.
This is unnecessary, we can simply decrement the incremented value after loop exit, and save a register in the loop.

This optimization made sense many years ago, investigate if it still makes sense today with modern Processors that do many more advanced optimizations with registers.

The question is if one should take the old approach of Opaque2 nodes (please use a more descriptive name!), where we block optimizations explicitly during the whole compilation, or if we can detect such patterns at the end of all optimizations. Maybe this has to be done before matching / mach graph, but this is up to the person taking on this task.