This crash happens for compiler.loopopts.TestMainNeverExecuted.java and compiler.c2.TestCMoveHasTopInput.java with -XX:+TraceLoopOpts.
CountedLoopEnd's incr node expected be AddI, but is ConI, this causes crash when printing counted loop info with -XX:+TraceLoopOpts.
# SIGSEGV (0xb) at pc=0x00002abc249ab2b8, pid=8589, tid=8606
#
# JRE version: OpenJDK Runtime Environment (18.0) (fastdebug build 18-internal+0-adhoc.shihui.jdkmaster)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 18-internal+0-adhoc.shihui.jdkmaster, compiled mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x11412b8] CountedLoopNode::stride_con() const+0x98
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
#
Current CompileTask:
C2: 193 3 b TestMainNeverExecuted::vMeth (106 bytes)
Stack: [0x00002abc3be06000,0x00002abc3bf07000], sp=0x00002abc3bf01280, free space=1004k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x11412b8] CountedLoopNode::stride_con() const+0x98
V [libjvm.so+0x1146c4e] IdealLoopTree::dump_head() const+0x3be
V [libjvm.so+0x1146e04] IdealLoopTree::dump() const+0x14
V [libjvm.so+0x1146e25] IdealLoopTree::dump() const+0x35
V [libjvm.so+0x1146e25] IdealLoopTree::dump() const+0x35
V [libjvm.so+0x11580b9] PhaseIdealLoop::build_and_optimize(LoopOptsMode)+0x9e9
V [libjvm.so+0x935734] PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x1b4
V [libjvm.so+0x932e06] Compile::Optimize()+0xfe6
V [libjvm.so+0x9343ae] Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, bool, DirectiveSet*)+0x132e
V [libjvm.so+0x7875cd] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x12d
V [libjvm.so+0x941e96] CompileBroker::invoke_compiler_on_method(CompileTask*)+0xc56
V [libjvm.so+0x9429b8] CompileBroker::compiler_thread_loop()+0x468
V [libjvm.so+0x178ccd7] JavaThread::thread_main_inner()+0x2e7
V [libjvm.so+0x178d00a] JavaThread::run()+0x27a
V [libjvm.so+0x1791d18] Thread::call_run()+0xf8
V [libjvm.so+0x1393e49] thread_native_entry(Thread*)+0x109