JDK-8351635 : C2 ROR/ROL: assert(cnt->bottom_type()->isa_long() && cnt->bottom_type()->is_long()->is_con()) failed: Long constant expected
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 25
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2025-03-11
  • Updated: 2025-05-19
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 25
25Unresolved
Related Reports
Relates :  
Description
Found with Template Framework JDK-8344942.

Hits assert in debug. Not sure if product is affected, it seems to run correctly in my examples, but needs more investigation when fixing the bug.

But from looking at the lowering code really quick:

  1618     // Scalar variable shift, handle replicates generated by auto vectorizer.
  1619     cnt = cnt->in(1);
  1620     if (bt == T_LONG) {
  1621       // Shift count vector for Rotate vector has long elements too.
  1622       if (cnt->Opcode() == Op_ConvI2L) {
  1623          cnt = cnt->in(1);
  1624       } else {
  1625          assert(cnt->bottom_type()->isa_long() &&
  1626                 cnt->bottom_type()->is_long()->is_con(), "Long constant expected");
  1627          cnt = phase->transform(new ConvL2INode(cnt));
  1628       }
  1629     }

It seems to me that it only expects a replicate to have a constant, but a replicate could also have some non-constant value. We then cast it anyway, which seems correct to me right now. So maybe we can just weaken the assert.

It reproduces on aarch64 and AVX2, and affects ROR and ROL. Does not reproduce with AVX3, because there it seems that we support RotateLeftV / RotateRightV, and so we do not need to do VectorNode::degenerate_vector_rotate.

java --add-modules=jdk.incubator.vector -Xbatch -XX:UseAVX=2 Test.java

or on aarch64 just:
java --add-modules=jdk.incubator.vector -Xbatch Test.java

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (.../src/hotspot/share/opto/vectornode.cpp:1625), pid=1268285, tid=1268299
#  assert(cnt->bottom_type()->isa_long() && cnt->bottom_type()->is_long()->is_con()) failed: Long constant expected
#
# JRE version: Java(TM) SE Runtime Environment (25.0) (fastdebug build 25-internal-LTS-2025-01-30-1037584.emanuel...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 25-internal-LTS-2025-01-30-1037584.emanuel..., mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x191331c]  VectorNode::degenerate_vector_rotate(Node*, Node*, bool, int, BasicType, PhaseGVN*)+0x3ec
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to .../core.1268285)
#
# An error report file with more information is saved as:
# .../hs_err_pid1268285.log
#
# Compiler replay data is saved as:
# .../replay_pid1268285.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#
Aborted (core dumped)

Current CompileTask:
C2:5199 2094    b  4       Test::test (27 bytes)

Stack: [0x0000719158d00000,0x0000719158e00000],  sp=0x0000719158dfa9c0,  free space=1002k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x191331c]  VectorNode::degenerate_vector_rotate(Node*, Node*, bool, int, BasicType, PhaseGVN*)+0x3ec  (vectornode.cpp:1625)
V  [libjvm.so+0x15dad7b]  PhaseGVN::transform(Node*)+0x6b  (phaseX.cpp:668)
V  [libjvm.so+0x18f7f7b]  LibraryCallKit::inline_vector_broadcast_int()+0x9cb  (vectorIntrinsics.cpp:2213)
V  [libjvm.so+0x12b4426]  LibraryIntrinsic::generate(JVMState*)+0x1e6  (library_call.cpp:118)
V  [libjvm.so+0x8ab74b]  CallGenerator::do_late_inline_helper()+0x9db  (callGenerator.cpp:675)
V  [libjvm.so+0xa51865]  Compile::inline_incrementally_one()+0xd5  (compile.cpp:2036)
V  [libjvm.so+0xa5274b]  Compile::inline_incrementally(PhaseIterGVN&)+0x2db  (compile.cpp:2119)
V  [libjvm.so+0xa53126]  Compile::Optimize()+0x336  (compile.cpp:2252)
V  [libjvm.so+0xa5782f]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1b9f  (compile.cpp:848)
V  [libjvm.so+0x8a3045]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1d5  (c2compiler.cpp:141)
V  [libjvm.so+0xa63ff8]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x928  (compileBroker.cpp:2317)
V  [libjvm.so+0xa64d38]  CompileBroker::compiler_thread_loop()+0x528  (compileBroker.cpp:1975)
V  [libjvm.so+0xf291ae]  JavaThread::thread_main_inner()+0xee  (javaThread.cpp:776)
V  [libjvm.so+0x187c636]  Thread::call_run()+0xb6  (thread.cpp:231)
V  [libjvm.so+0x1555088]  thread_native_entry(Thread*)+0x128  (os_linux.cpp:877)
C  [libc.so.6+0x9caa4]
Comments
Sounds good, thanks Jatin!
19-05-2025

[~thartmann], fix is in place, validation in progress, will open a PR for this in couple of days.
19-05-2025

[~jbhateja] Since we are getting closer to RDP 1 for JDK 25 (June 05, 2025), any update on this? Thanks!
13-05-2025

Paging [~jbhateja] since this is VectorAPI related.
12-03-2025

ILW = Assesrtion failure during late inlining, single test with VectorAPI, disable compilation of affected method = HLM = P3
11-03-2025

Starts to fail after JDK-8332268 which most likely only revealed an existing issue.
11-03-2025