JDK-8317723 : C2: CountedLoopEndNodes and Zero Trip Guards are wrongly treated as Runtime Predicate
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 22
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-10-09
  • Updated: 2023-12-11
  • Resolved: 2023-11-16
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 b25Fixed
Related Reports
Relates :  
Description
The assert introduced by JDK-8316105 triggers with the attached test:

java -Xmx1G -XX:+IgnoreUnrecognizedVMOptions -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,*Test*::* -XX:-TieredCompilation -Xbatch -XX:MaxRAMPercentage=4.16667 Test.java

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/workspace/open/src/hotspot/share/opto/predicates.cpp:120), pid=27455, tid=41475
#  assert(next->is_IfProj() || opcode == Op_If || opcode == Op_RangeCheck) failed: Regular Predicates consist of an IfProj and an If or RangeCheck node
#
# JRE version: Java(TM) SE Runtime Environment (22.0+19) (fastdebug build 22-ea+19-1440)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 22-ea+19-1440, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, bsd-amd64)
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

Current CompileTask:
C2:    790   62 %  b        Test::mainTest @ 119 (677 bytes)

Stack: [0x0000700006808000,0x0000700006908000],  sp=0x0000700006903ce0,  free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.dylib+0x1219b14]  VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x5a4  (predicates.cpp:120)
V  [libjvm.dylib+0x121a2a8]  VMError::report_and_die(Thread*, void*, char const*, int, char const*, char const*, __va_list_tag*)+0x38
V  [libjvm.dylib+0x657404]  report_vm_error(char const*, int, char const*, char const*, ...)+0xb4
V  [libjvm.dylib+0xf59469]  PredicateBlock::verify_block()+0x99
V  [libjvm.dylib+0xd4159c]  PhaseIdealLoop::mark_useful_parse_predicates_for_loop(IdealLoopTree*)+0x7c
V  [libjvm.dylib+0xd41120]  PhaseIdealLoop::eliminate_useless_parse_predicates()+0x80
V  [libjvm.dylib+0xd4355c]  PhaseIdealLoop::build_and_optimize()+0x81c
V  [libjvm.dylib+0x5bcd38]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x58
V  [libjvm.dylib+0x5bd1cd]  Compile::optimize_loops(PhaseIterGVN&, LoopOptsMode)+0x6d
V  [libjvm.dylib+0x5b6897]  Compile::Optimize()+0xb27
V  [libjvm.dylib+0x5b4543]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1593
V  [libjvm.dylib+0x4787d6]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1a6
V  [libjvm.dylib+0x5d358f]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xa9f
V  [libjvm.dylib+0x5d26e7]  CompileBroker::compiler_thread_loop()+0x357
V  [libjvm.dylib+0x9a93b5]  JavaThread::thread_main_inner()+0x1a5
V  [libjvm.dylib+0x116112c]  Thread::call_run()+0xbc
V  [libjvm.dylib+0xeeacf2]  thread_native_entry(Thread*)+0x122
C  [libsystem_pthread.dylib+0x68fc]  _pthread_start+0xe0
C  [libsystem_pthread.dylib+0x2443]  thread_start+0xf
Lock stack of current Java thread (top to bottom):

Comments
Changeset: 2db9ea9b Author: Christian Hagedorn <chagedorn@openjdk.org> Date: 2023-11-16 07:37:45 +0000 URL: https://git.openjdk.org/jdk/commit/2db9ea9bbf6d4b7875b0c62721f76f016fd7257e
16-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16596 Date: 2023-11-10 08:53:29 +0000
10-11-2023

I also attached a simplified test (TestReduced.java). [~chagedorn], please have a look. ILW = Assert during C2 compilation (might be false positive), single generated test, no known workaround but disable loop predication or compilation of affected method = HLM = P3
09-10-2023