During fuzzer work of JDK-8280126, I found the same assert but with irreducible loops. I suspected it would also be possible to trigger the same bug but without irreducible loops, so I went and constructed an R3.java, using various tricks.
To reproduce, use either:
$ java -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:+PrintOptoAssembly -XX:+TraceLoopOpts -XX:+PrintInlining -Xcomp -XX:CompileCommand=compileonly,R3::test -XX:-TieredCompilation -XX:PerMethodTrapLimit=0 R3.java
$ java -Xcomp -XX:CompileCommand=compileonly,R3::test -XX:PerMethodTrapLimit=0 R3.java
# Internal Error (/home/emanuel/Documents/fork2-jdk/open/src/hotspot/share/opto/node.cpp:830), pid=111698, tid=111711
# assert(idx < _cnt) failed: oob
#
# JRE version: Java(TM) SE Runtime Environment (20.0) (slowdebug build 20-internal-2022-10-06-1045569.emanuel...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (slowdebug 20-internal-2022-10-06-1045569.emanuel..., compiled mode, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x1095a1e] Node::del_req(unsigned int)+0x26
Current CompileTask:
C2: 5472 83 b R3::test (96 bytes)
Stack: [0x00007f3430cdc000,0x00007f3430ddd000], sp=0x00007f3430dd7f90, free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x1095a1e] Node::del_req(unsigned int)+0x26 (node.cpp:830)
V [libjvm.so+0x656230] PhaseCFG::convert_NeverBranch_to_Goto(Block*)+0x232 (block.cpp:653)
V [libjvm.so+0x65669c] PhaseCFG::remove_empty_blocks()+0x100 (block.cpp:744)
V [libjvm.so+0x89bb42] Compile::Code_Gen()+0x354 (compile.cpp:2978)
V [libjvm.so+0x8920fd] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x159f (compile.cpp:863)
V [libjvm.so+0x780a29] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x179 (c2compiler.cpp:113)
V [libjvm.so+0x8b0c56] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x916 (compileBroker.cpp:2240)
V [libjvm.so+0x8af8bf] CompileBroker::compiler_thread_loop()+0x3ed (compileBroker.cpp:1916)
V [libjvm.so+0x8d0008] CompilerThread::thread_entry(JavaThread*, JavaThread*)+0x72 (compilerThread.cpp:58)
V [libjvm.so+0xc5df2a] JavaThread::thread_main_inner()+0x144 (javaThread.cpp:699)
V [libjvm.so+0xc5dde2] JavaThread::run()+0x182 (javaThread.cpp:684)
V [libjvm.so+0x132fe8f] Thread::call_run()+0x195 (thread.cpp:224)
V [libjvm.so+0x10dd81b] thread_native_entry(Thread*)+0x19b (os_linux.cpp:710)
TraceLoopOpts:
PHASE_PHASEIDEALLOOP1 start
Counted Loop: N237/N231 counted [76,0),-1 (-1 iters)
Parallel IV: 59 Loop: N237/N231 counted [76,0),-1 (-1 iters) has_sfpt strip_mined
Counted Loop: N252/N136 counted [0,4),+1 (-1 iters)
Loop: N0/N0 has_sfpt
Loop: N236/N235
Loop: N237/N231 counted [76,0),-1 (-1 iters) has_sfpt strip_mined
Loop: N251/N250
Loop: N252/N136 counted [0,4),+1 (-1 iters) has_sfpt strip_mined
Empty with zero trip guard Loop: N237/N231 counted [76,0),-1 (-1 iters) has_sfpt strip_mined
MaxUnroll 4 Loop: N252/N136 counted [0,4),+1 (2147483648 iters) has_sfpt strip_mined
Unroll 2( 4) Loop: N252/N136 counted [0,4),+1 (2147483648 iters) has_sfpt strip_mined
PHASE_PHASEIDEALLOOP1 end
PHASE_PHASEIDEALLOOP2 start
Loop: N0/N0 has_sfpt
Loop: N251/N250 sfpts={ 253 }
Loop: N277/N136 counted [0,4),+2 (2147483648 iters) has_sfpt strip_mined
Loop: N309/N170 sfpts={ 170 }
MaxUnroll 2 Loop: N277/N136 counted [0,4),+2 (2147483648 iters) has_sfpt strip_mined
Unroll 4( 2) Loop: N277/N136 counted [0,4),+2 (2147483648 iters) has_sfpt strip_mined
Peel Loop: N309/N170 sfpts={ 170 }
PHASE_PHASEIDEALLOOP2 end
PHASE_PHASEIDEALLOOP3 start
Loop: N0/N0 has_sfpt
Loop: N309/N170 sfpts={ 170 }
PHASE_PHASEIDEALLOOP3 end
Loop: N0/N0 has_sfpt
Loop: N309/N170 sfpts={ 170 }