JDK-8313672 : C2: PhaseCCP does not correctly track analysis dependencies involving shift, convert, and mask
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 21,22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-08-03
  • Updated: 2023-11-21
  • Resolved: 2023-11-15
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 b24Fixed
Related Reports
Relates :  
Description
### Failure analysis ###
The failure appears because `PhaseCCP::push_and` does not capture all patterns from `MulNode::AndIL_shift_and_mask_is_always_zero` (called from `AndLNode::Value`). As a consequence, some nodes which need re-analysis in `PhaseCCP` are not re-added to the worklist.

### Original report ###
The attached fuzzer test fails with the following assertion since the assert was added in JDK-8257197 (most likely also affects earlier version where the assert is missing):

To reproduce:
$ java -XX:CompileCommand=RepeatCompilation,Test::mainTest,1000 -XX:-TieredCompilation -XX:+StressIGVN -Xcomp -XX:CompileOnly=Test::* Test.java
$ java -XX:RepeatCompilation=1000 -XX:-TieredCompilation -XX:+StressIGVN -Xcomp -XX:CompileCommand=compileonly,Reduced::test Reduced.java

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/cd627e65-f015-4fb1-a1d2-b6c9b8127f98-S107234/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/3f6d0df7-2217-4a65-bfa3-1294b5554df9/runs/b8ed7f9d-165b-4b78-86e8-e4c923096d65/workspace/open/src/hotspot/share/opto/phaseX.cpp:1826), pid=472204, tid=472226
#  assert(!failure) failed: Missed optimization opportunity in PhaseCCP
#
# JRE version: Java(TM) SE Runtime Environment (21.0+1) (fastdebug build 21-galahadeestaging+1-LTS-60)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 21-galahadeestaging+1-LTS-60, compiled mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-aarch64)
# Problematic frame:
# V  [libjvm.so+0x13d4610]  PhaseCCP::analyze()+0x6e0
.........
Command Line: -XX:-TieredCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+StressLCM -XX:+StressGCM -XX:+StressIGVN -XX:+StressCCP -XX:StressSeed=1464539141 -Xmx1G -Xcomp -Xbatch -XX:CompileOnly=Test -XX:CompileCommand=quiet -XX:MaxRAMPercentage=6.25 -Dtest.boot.jdk=/opt/mach5/mesos/work_dir/jib-master/install/jdk/20/36/bundles/linux-aarch64/jdk-20_linux-aarch64_bin.tar.gz/jdk-20 -Djava.io.tmpdir=/opt/mach5/mesos/work_dir/slaves/cd627e65-f015-4fb1-a1d2-b6c9b8127f98-S119357/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/4ce1ae21-d8a4-4dd7-bc28-ae5d04951013/runs/ee39a676-757e-4f39-8eb7-2849b60f23a9/testoutput/test-support/jtreg_closed_test_hotspot_jtreg_applications_javafuzzer_BigTest_java/tmp Test
.........
Current CompileTask:
C2:    500   71    b        Test::mainTest (562 bytes)

Stack: [0x0000ffff9ad8e000,0x0000ffff9af8c000],  sp=0x0000ffff9af86e80,  free space=2019k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x13d4610]  PhaseCCP::analyze()+0x6e0  (phaseX.cpp:1826)
V  [libjvm.so+0x907494]  Compile::Optimize()+0x490  (compile.cpp:2364)
V  [libjvm.so+0x9095b4]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x14e4  (compile.cpp:842)
V  [libjvm.so+0x7600d8]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x328  (c2compiler.cpp:118)
V  [libjvm.so+0x9156e4]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x8e4  (compileBroker.cpp:2276)
V  [libjvm.so+0x916114]  CompileBroker::compiler_thread_loop()+0x594  (compileBroker.cpp:1944)
V  [libjvm.so+0xda8dcc]  JavaThread::thread_main_inner()+0xec  (javaThread.cpp:719)
V  [libjvm.so+0x15f7b24]  Thread::call_run()+0xb0  (thread.cpp:217)
V  [libjvm.so+0x13537e0]  thread_native_entry(Thread*)+0x130  (os_linux.cpp:778)
C  [libpthread.so.0+0x7908]  start_thread+0x188
Comments
Changeset: bad69996 Author: Daniel Lundén <daniel.lunden@oracle.com> Committer: Roberto Castañeda Lozano <rcastanedalo@openjdk.org> Date: 2023-11-15 09:19:15 +0000 URL: https://git.openjdk.org/jdk/commit/bad6999634686dcfd04c88ddab855aa202cf35b9
15-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16429 Date: 2023-10-31 07:14:07 +0000
31-10-2023

ILW = Missing optimization opportunity in CCP - harmless in product, single Java Fuzzer test, disable compilation of affected method = MLM = P4
03-08-2023