-
Bug
-
Resolution: Unresolved
-
P3
-
25
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]
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]
- relates to
-
JDK-8332268 C2: Add missing optimizations for UDivI/L and UModI/L and unify the shared logic with the signed nodes
-
- Resolved
-