JDK-8297951 : C2: Create skeleton predicates for all If nodes in loop predication
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,17,18,19,20
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-12-01
  • Updated: 2023-01-12
  • Resolved: 2022-12-06
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 11 JDK 17 JDK 20
11.0.19-oracleFixed 17.0.7-oracleFixed 20 b27Fixed
Related Reports
Relates :  
Description
We currently only create skeleton predicates for RangeCheck nodes and not for normal If nodes. But it is possible to also create range check predicates in loop predication for If nodes if they have the right pattern checked in IdealLoopTree::is_range_check_if(). This, however, is much more rare. 

Without skeleton predicates for these If nodes, we could run into the same problems already fixed for RangeCheck nodes (JDK-8193130 and related bugs). This is almost impossible to trigger in practice but the attached test case shows a case where we hit an assert due to a broken memory graph.

To reproduce:
$ java -Xbatch -XX:CompileOnly=Test -XX:-TieredCompilation -XX:-RangeCheckElimination -XX:+BailoutToInterpreterForThrows NoSkeleton.java


#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S8340/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/ed07585a-43b8-4680-b23d-20b58c0a9937/runs/e4f38489-0635-4100-a63a-1f0cdb37a23a/workspace/open/src/hotspot/share/opto/loopopts.cpp:1601), pid=45173, tid=45186
#  assert(!n->is_Store() && !n->is_LoadStore()) failed: no node with a side effect
.......
Command Line: -XX:+BailoutToInterpreterForThrows -XX:CompileOnly=Test -XX:-TieredCompilation -Xbatch -XX:-RangeCheckElimination --add-modules=ALL-DEFAULT jdk.compiler/com.sun.tools.javac.launcher.Main NoSkeleton.java
.......
Current CompileTask:
C2:    950   82    b        Test::test (84 bytes)

Stack: [0x00007f526c555000,0x00007f526c655000],  sp=0x00007f526c64eec0,  free space=999k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x14d03a5]  PhaseIdealLoop::try_sink_out_of_loop(Node*)+0x9f5  (loopopts.cpp:1601)
V  [libjvm.so+0x14d0538]  PhaseIdealLoop::split_if_with_blocks_post(Node*)+0x58
V  [libjvm.so+0x14d11a9]  PhaseIdealLoop::split_if_with_blocks(VectorSet&, Node_Stack&)+0x209
V  [libjvm.so+0x14c27cf]  PhaseIdealLoop::build_and_optimize()+0x11bf
V  [libjvm.so+0xafe601]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x261
V  [libjvm.so+0xafa05f]  Compile::Optimize()+0xe2f
V  [libjvm.so+0xafc66e]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x18ce
V  [libjvm.so+0x90d7b7]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x4e7
V  [libjvm.so+0xb09b3c]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xa7c
V  [libjvm.so+0xb0a948]  CompileBroker::compiler_thread_loop()+0x608
V  [libjvm.so+0x107d656]  JavaThread::thread_main_inner()+0x206
V  [libjvm.so+0x1a852c0]  Thread::call_run()+0x100
V  [libjvm.so+0x1715463]  thread_native_entry(Thread*)+0x103
Comments
Fix request [17u] I backport this for parity with 17.0.7-oracle. Typical risk of changing C2, Clean backport. Test passes. SAP nightly testing passed
12-01-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/1052 Date: 2023-01-11 06:51:30 +0000
11-01-2023

Changeset: 0bd04a65 Author: Christian Hagedorn <chagedorn@openjdk.org> Date: 2022-12-06 07:18:44 +0000 URL: https://git.openjdk.org/jdk/commit/0bd04a658963c1126faa776cb8a96c23beb5e3e6
06-12-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/11454 Date: 2022-12-01 14:17:47 +0000
01-12-2022

ILW = C2 assertion due to broken memory graph, rare edge case, disable compilation of affected method or use -XX:-UseLoopPredicate = HLM = P3
01-12-2022