JDK-8361140 : Missing OptimizePtrCompare check in ConnectionGraph::reduce_phi_on_cmp
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 23
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-07-01
  • Updated: 2025-07-14
  • Resolved: 2025-07-14
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 26
26 masterFixed
Related Reports
Causes :  
Description
After JDK-8316991, ConnectionGraph::reduce_phi_on_cmp calls ConnectionGraph::optimize_ptr_compare without checking OptimizePtrCompare:

java -XX:-OptimizePtrCompare -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,"java.lang.String::<init>" -Xbatch Test.java

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (workspace/open/src/hotspot/share/opto/escape.cpp:3275), pid=3094462, tid=3094480
#  assert(OptimizePtrCompare) failed: sanity
#
# JRE version: Java(TM) SE Runtime Environment (26.0+5) (fastdebug build 26-ea+5-394)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 26-ea+5-394, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0xd3f75b]  ConnectionGraph::optimize_ptr_compare(Node*, Node*)+0x38b

Current CompileTask:
C2:1097   91    b  4       java.lang.String::<init> (86 bytes)

Stack: [0x00007f202b3f5000,0x00007f202b4f5000],  sp=0x00007f202b4ef4f0,  free space=1001k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0xd3f75b]  ConnectionGraph::optimize_ptr_compare(Node*, Node*)+0x38b  (escape.cpp:3275)
V  [libjvm.so+0xd3f894]  ConnectionGraph::reduce_phi_on_cmp(Node*)+0xf4
V  [libjvm.so+0xd49878]  ConnectionGraph::reduce_phi(PhiNode*, GrowableArray<Node*>&, GrowableArray<Node*>&)+0x828
V  [libjvm.so+0xd4d4f9]  ConnectionGraph::split_unique_types(GrowableArray<Node*>&, GrowableArray<ArrayCopyNode*>&, GrowableArray<MergeMemNode*>&, Unique_Node_List&)+0x789
V  [libjvm.so+0xd590cf]  ConnectionGraph::compute_escape()+0x264f
V  [libjvm.so+0xd5985a]  ConnectionGraph::do_analysis(Compile*, PhaseIterGVN*)+0x15a
V  [libjvm.so+0xb45607]  Compile::Optimize()+0x1397
V  [libjvm.so+0xb48013]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1ec3
V  [libjvm.so+0x96d097]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x467
V  [libjvm.so+0xb57438]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xb58
V  [libjvm.so+0xb58608]  CompileBroker::compiler_thread_loop()+0x578
V  [libjvm.so+0x10abc4b]  JavaThread::thread_main_inner()+0x13b
V  [libjvm.so+0x1b12166]  Thread::call_run()+0xb6
V  [libjvm.so+0x178c218]  thread_native_entry(Thread*)+0x128
Comments
Changeset: 14c79be1 Branch: master Author: han gq <hanguanqiang@kylinos.cn> Committer: Christian Hagedorn <chagedorn@openjdk.org> Date: 2025-07-14 07:39:04 +0000 URL: https://git.openjdk.org/jdk/commit/14c79be1613c9d737a9536087ac48914ee4ba8d9
14-07-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/26125 Date: 2025-07-04 02:49:27 +0000
04-07-2025

ILW = Assert due to missing guard for optimization, with -XX:-OptimizePtrCompare, no -XX:-ReduceAllocationMerges = MLH = P4
01-07-2025