Merge branch 'add_rvv_support' of https://github.com/anthony-zy/snappy into add_rvv_support

This commit is contained in:
anthony-zy
2025-08-28 20:42:49 +08:00

View File

@@ -1288,11 +1288,12 @@ void MemCopy64(char* dst, const void* src, size_t size) {
data = _mm256_lddqu_si256(static_cast<const __m256i *>(src) + 1);
_mm256_storeu_si256(reinterpret_cast<__m256i *>(dst) + 1, data);
}
#else
#ifdef SNAPPY_HAVE_RVV
// RVV acceleration available on RISC-V when compiled with -march=rv64gcv
#elif defined(__riscv) & SNAPPY_HAVE_RVV
uint8_t* dst_u8 = (uint8_t*)dst;
const uint8_t* src_u8 = (const uint8_t*)src;
if (src_u8 < dst_u8 && dst_u8 < src_u8 + size) { //overlap bwd copy
//overlap bwd copy
if (src_u8 < dst_u8 && dst_u8 < src_u8 + size) {
size_t offset = size;
while (offset > 0) {
size_t vl = VSETVL_E8M1(offset);
@@ -1302,7 +1303,8 @@ if (src_u8 < dst_u8 && dst_u8 < src_u8 + size) { //overlap bwd copy
}
} else {
size_t vl = VSETVL_E8M1(size);
if (vl < size) { // if size >vl,use the max_vlen copy
// if size >vl,use the max_vlen copy
if (vl < size) {
size_t offset = 0;
while (offset < size) {
vl = VSETVL_E8M1(size - offset);
@@ -1310,7 +1312,8 @@ if (src_u8 < dst_u8 && dst_u8 < src_u8 + size) { //overlap bwd copy
VSE8_V_U8M1(dst_u8 + offset, vec, vl);
offset += vl;
}
} else { // copy the leaft
} else {
// Copy the rest
vuint8m1_t vec = VLE8_V_U8M1(src_u8, vl);
VSE8_V_U8M1(dst_u8, vec, vl);
}
@@ -1322,8 +1325,6 @@ if (SNAPPY_PREDICT_FALSE(size > kShortMemCopy)) {
std::memmove(dst + kShortMemCopy,
static_cast<const uint8_t*>(src) + kShortMemCopy,
64 - kShortMemCopy);}
#endif
#endif
}