JDK-8287290 : Introduce a check for progress in loop optimizations
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • Submitted: 2022-05-25
  • Updated: 2022-05-25
Related Reports
Relates :  
Relates :  
Description
Compile::optimize_loops performs PhaseIdealLoop::build_and_optimize() 
as long as major_progress() is set or until it reaches the `LoopOptsCount` limit. But loop optimization can get stuck in an infinite loop of performing always the same optimization(s) as happened in JDK-8287284. To detect such cases there used to be an assert, but it was broken and removed in JDK-8284944. In reality we get out of the infinite loop because we hit `LoopOptsCount`. We should introduce a check that detects such cases since it means something gone wrong. 

Things to consider: 
- Increase the limit of `LoopOptsCount` since there are valid cases (TestMaxLoopOptsCountReached.java) where we could still improve the loop further
- To detect if we are stuck in a cycle it would be good somehow verify that the graph is improving and not just bloating up.