JDK-8287284 : C2: loop optimization performs split_thru_phi infinitely many times
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,17,18,19,21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-05-25
  • Updated: 2023-11-24
  • Resolved: 2023-11-15
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.
JDK 22
22 b24Fixed
Related Reports
Relates :  
Relates :  
Description
Compile::optimize_loops performs always the same optimization until it reaches the `LoopOptsCount` limit. `Major progress` is set in  `PhaseIdealLoop::split_if_with_blocks` -> `PhaseIdealLoop::split_if_with_blocks_pre` after performing `PhaseIdealLoop::split_thru_phi`. This creates a chain of `phis` in the graph without any benefit for performance. Without the limit of `LoopOptsCount` this would run infinitely many times.

HOW TO REPRODUCE

Run the following command on a debug JDK build:

$ java -Xbatch -XX:-PartialPeelLoop -XX:CompileCommand=compileonly,Test::run Test.java

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (src/hotspot/share/opto/compile.cpp:2065), pid=7080, tid=7093
#  assert(cnt++ < 40) failed: infinite cycle in loop optimization
#
# JRE version: Java(TM) SE Runtime Environment (19.0+23) (fastdebug build 19-ea+23-1706)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 19-ea+23-1706, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0xaba94c]  Compile::Optimize()+0x180c
Comments
Changeset: 4c1540ba Author: Tobias Holenstein <tholenstein@openjdk.org> Date: 2023-11-15 08:31:39 +0000 URL: https://git.openjdk.org/jdk/commit/4c1540baa61e65fc20451a2d9de09b23fb7baf64
15-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/15536 Date: 2023-09-01 13:13:20 +0000
23-10-2023

ILW = performance degradation on release build, assertion failure on debug build; artificial test case with non-default option (-PartialPeelLoop); set LoopOptsCount, to a lower value = MML = P4
25-05-2022