From 445f903be0852ae36ff4eee9d222723ab3bde052 Mon Sep 17 00:00:00 2001 From: jiangfeilong Date: Tue, 24 Jun 2025 22:30:55 +0800 Subject: [PATCH 1/3] riscv: fix c1 primitive array clone intrinsic regression --- src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp | 2 +- src/hotspot/share/c1/c1_Compiler.cpp | 2 +- src/hotspot/share/c1/c1_LIR.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp index b9ebd49779e98..03e4dc73000c5 100644 --- a/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp @@ -772,7 +772,7 @@ void LIRGenerator::do_ArrayCopy(Intrinsic* x) { ciArrayKlass* expected_type = nullptr; arraycopy_helper(x, &flags, &expected_type); if (x->check_flag(Instruction::OmitChecksFlag)) { - flags = 0; + flags = AvoidUnalignedAccesses ? (flags & LIR_OpArrayCopy::unaligned) : 0; } __ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(), length.result(), tmp, diff --git a/src/hotspot/share/c1/c1_Compiler.cpp b/src/hotspot/share/c1/c1_Compiler.cpp index 8151acd99e0a9..37f2acbfe938c 100644 --- a/src/hotspot/share/c1/c1_Compiler.cpp +++ b/src/hotspot/share/c1/c1_Compiler.cpp @@ -237,7 +237,7 @@ bool Compiler::is_intrinsic_supported(vmIntrinsics::ID id) { case vmIntrinsics::_counterTime: #endif case vmIntrinsics::_getObjectSize: -#if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV) || defined(PPC64) +#if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV64) || defined(PPC64) case vmIntrinsics::_clone: #endif break; diff --git a/src/hotspot/share/c1/c1_LIR.cpp b/src/hotspot/share/c1/c1_LIR.cpp index c1c94244fcc7b..3db916783f860 100644 --- a/src/hotspot/share/c1/c1_LIR.cpp +++ b/src/hotspot/share/c1/c1_LIR.cpp @@ -350,7 +350,7 @@ LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_ , _tmp(tmp) , _expected_type(expected_type) , _flags(flags) { -#if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV) || defined(PPC64) +#if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV64) || defined(PPC64) if (expected_type != nullptr && flags == 0) { _stub = nullptr; } else { From 7af2ea31a57ccc8081b023940dda4a0af33363c3 Mon Sep 17 00:00:00 2001 From: jiangfeilong Date: Thu, 26 Jun 2025 22:23:18 +0800 Subject: [PATCH 2/3] check unaligned flag at LIR_OpArrayCopy to avoid using AvoidUnalignedAccesses --- src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp | 2 +- src/hotspot/share/c1/c1_LIR.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp index 03e4dc73000c5..1b5c511360ff5 100644 --- a/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp @@ -772,7 +772,7 @@ void LIRGenerator::do_ArrayCopy(Intrinsic* x) { ciArrayKlass* expected_type = nullptr; arraycopy_helper(x, &flags, &expected_type); if (x->check_flag(Instruction::OmitChecksFlag)) { - flags = AvoidUnalignedAccesses ? (flags & LIR_OpArrayCopy::unaligned) : 0; + flags = (flags & LIR_OpArrayCopy::unaligned); } __ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(), length.result(), tmp, diff --git a/src/hotspot/share/c1/c1_LIR.cpp b/src/hotspot/share/c1/c1_LIR.cpp index 3db916783f860..fbcb95f35924b 100644 --- a/src/hotspot/share/c1/c1_LIR.cpp +++ b/src/hotspot/share/c1/c1_LIR.cpp @@ -351,7 +351,7 @@ LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_ , _expected_type(expected_type) , _flags(flags) { #if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV64) || defined(PPC64) - if (expected_type != nullptr && flags == 0) { + if (expected_type != nullptr && ((flags & ~LIR_OpArrayCopy::unaligned) == 0)) { _stub = nullptr; } else { _stub = new ArrayCopyStub(this); From a3c6a091f06e24a32ac8f5c8b79718c6969b4971 Mon Sep 17 00:00:00 2001 From: jiangfeilong Date: Sun, 6 Jul 2025 21:17:09 +0800 Subject: [PATCH 3/3] Revert RISCV Macro modification --- src/hotspot/share/c1/c1_Compiler.cpp | 2 +- src/hotspot/share/c1/c1_LIR.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/c1/c1_Compiler.cpp b/src/hotspot/share/c1/c1_Compiler.cpp index 82dea9b014184..64a2e6456d8c5 100644 --- a/src/hotspot/share/c1/c1_Compiler.cpp +++ b/src/hotspot/share/c1/c1_Compiler.cpp @@ -237,7 +237,7 @@ bool Compiler::is_intrinsic_supported(vmIntrinsics::ID id) { case vmIntrinsics::_counterTime: #endif case vmIntrinsics::_getObjectSize: -#if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV64) || defined(PPC64) +#if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV) || defined(PPC64) case vmIntrinsics::_clone: #endif break; diff --git a/src/hotspot/share/c1/c1_LIR.cpp b/src/hotspot/share/c1/c1_LIR.cpp index fbcb95f35924b..2a7b0adc3c339 100644 --- a/src/hotspot/share/c1/c1_LIR.cpp +++ b/src/hotspot/share/c1/c1_LIR.cpp @@ -350,7 +350,7 @@ LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_ , _tmp(tmp) , _expected_type(expected_type) , _flags(flags) { -#if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV64) || defined(PPC64) +#if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV) || defined(PPC64) if (expected_type != nullptr && ((flags & ~LIR_OpArrayCopy::unaligned) == 0)) { _stub = nullptr; } else {