Skip to content

Commit b8d6101

Browse files
authored
Merge pull request #4502 from zijianli1234/dev
- Modify the GCC version used for CI testing of the RISCV architecture
2 parents f42dee2 + 87cc127 commit b8d6101

File tree

5 files changed

+32
-29
lines changed

5 files changed

+32
-29
lines changed

.github/workflows/dev-short-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ jobs:
403403
{ name: PPC64LE, xcc_pkg: gcc-powerpc64le-linux-gnu, xcc: powerpc64le-linux-gnu-gcc, xemu_pkg: qemu-system-ppc, xemu: qemu-ppc64le-static },
404404
{ name: S390X, xcc_pkg: gcc-s390x-linux-gnu, xcc: s390x-linux-gnu-gcc, xemu_pkg: qemu-system-s390x, xemu: qemu-s390x-static },
405405
{ name: MIPS, xcc_pkg: gcc-mips-linux-gnu, xcc: mips-linux-gnu-gcc, xemu_pkg: qemu-system-mips, xemu: qemu-mips-static },
406-
{ name: RISC-V, xcc_pkg: gcc-riscv64-linux-gnu, xcc: riscv64-linux-gnu-gcc, xemu_pkg: qemu-system-riscv64,xemu: qemu-riscv64-static },
406+
{ name: RISC-V, xcc_pkg: gcc-14-riscv64-linux-gnu, xcc: riscv64-linux-gnu-gcc-14, xemu_pkg: qemu-system-riscv64,xemu: qemu-riscv64-static },
407407
{ name: M68K, xcc_pkg: gcc-m68k-linux-gnu, xcc: m68k-linux-gnu-gcc, xemu_pkg: qemu-system-m68k, xemu: qemu-m68k-static },
408408
{ name: SPARC, xcc_pkg: gcc-sparc64-linux-gnu, xcc: sparc64-linux-gnu-gcc, xemu_pkg: qemu-system-sparc, xemu: qemu-sparc64-static },
409409
]

lib/common/compiler.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,11 @@
224224
# if defined(__ARM_FEATURE_SVE2)
225225
# define ZSTD_ARCH_ARM_SVE2
226226
# endif
227-
#if defined(__riscv) && defined(__riscv_vector)
228-
#if defined(__GNUC__)
229-
#if (__GNUC__ > 14 || (__GNUC__ == 14 && __GNUC_MINOR__ >= 1))
230-
#define ZSTD_ARCH_RISCV_RVV
231-
#endif
232-
#elif defined(__clang__)
233-
#if __clang_major__ > 18 || (__clang_major__ == 18 && __clang_minor__ >= 1)
234-
#define ZSTD_ARCH_RISCV_RVV
235-
#endif
236-
#endif
227+
# if defined(__riscv) && defined(__riscv_vector)
228+
# if ((defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 14) || \
229+
(defined(__clang__) && __clang_major__ >= 19))
230+
#define ZSTD_ARCH_RISCV_RVV
231+
# endif
237232
#endif
238233
#
239234
# if defined(ZSTD_ARCH_X86_AVX2)

lib/common/zstd_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ static void ZSTD_copy16(void* dst, const void* src) {
185185
vst1q_u8((uint8_t*)dst, vld1q_u8((const uint8_t*)src));
186186
#elif defined(ZSTD_ARCH_X86_SSE2)
187187
_mm_storeu_si128((__m128i*)dst, _mm_loadu_si128((const __m128i*)src));
188+
#elif defined(ZSTD_ARCH_RISCV_RVV)
189+
__riscv_vse8_v_u8m1((uint8_t*)dst, __riscv_vle8_v_u8m1((const uint8_t*)src, 16), 16);
188190
#elif defined(__clang__)
189191
ZSTD_memmove(dst, src, 16);
190192
#else

lib/compress/zstd_compress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7292,7 +7292,7 @@ size_t convertSequences_noRepcodes(
72927292
return longLen;
72937293
}
72947294

7295-
#elif defined ZSTD_ARCH_RISCV_RVV
7295+
#elif defined (ZSTD_ARCH_RISCV_RVV)
72967296
#include <riscv_vector.h>
72977297
/*
72987298
* Convert `vl` sequences per iteration, using RVV intrinsics:
@@ -7824,7 +7824,7 @@ BlockSummary ZSTD_get1BlockSummary(const ZSTD_Sequence* seqs, size_t nbSeqs)
78247824
}
78257825
}
78267826

7827-
#elif defined ZSTD_ARCH_RISCV_RVV
7827+
#elif defined (ZSTD_ARCH_RISCV_RVV)
78287828

78297829
BlockSummary ZSTD_get1BlockSummary(const ZSTD_Sequence* seqs, size_t nbSeqs)
78307830
{

lib/compress/zstd_lazy.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,33 +1052,39 @@ ZSTD_row_getNEONMask(const U32 rowEntries, const BYTE* const src, const BYTE tag
10521052
#endif
10531053
#if defined(ZSTD_ARCH_RISCV_RVV) && (__riscv_xlen == 64)
10541054
FORCE_INLINE_TEMPLATE ZSTD_VecMask
1055-
ZSTD_row_getRVVMask(int nbChunks, const BYTE* const src, const BYTE tag, const U32 head)
1055+
ZSTD_row_getRVVMask(int rowEntries, const BYTE* const src, const BYTE tag, const U32 head)
10561056
{
10571057
ZSTD_VecMask matches;
10581058
size_t vl;
10591059

10601060
if (rowEntries == 16) {
10611061
vl = __riscv_vsetvl_e8m1(16);
1062-
vuint8m1_t chunk = __riscv_vle8_v_u8m1(src, vl);
1063-
vbool8_t mask = __riscv_vmseq_vx_u8m1_b8(chunk, tag, vl);
1064-
vuint16m1_t mask_u16 = __riscv_vreinterpret_v_b8_u16m1(mask);
1065-
matches = __riscv_vmv_x_s_u16m1_u16(mask_u16);
1066-
return ZSTD_rotateRight_U16((U16)matches, head);
1062+
{
1063+
vuint8m1_t chunk = __riscv_vle8_v_u8m1(src, vl);
1064+
vbool8_t mask = __riscv_vmseq_vx_u8m1_b8(chunk, tag, vl);
1065+
vuint16m1_t mask_u16 = __riscv_vreinterpret_v_b8_u16m1(mask);
1066+
matches = __riscv_vmv_x_s_u16m1_u16(mask_u16);
1067+
return ZSTD_rotateRight_U16((U16)matches, head);
1068+
}
10671069

10681070
} else if (rowEntries == 32) {
10691071
vl = __riscv_vsetvl_e8m2(32);
1070-
vuint8m2_t chunk = __riscv_vle8_v_u8m2(src, vl);
1071-
vbool4_t mask = __riscv_vmseq_vx_u8m2_b4(chunk, tag, vl);
1072-
vuint32m1_t mask_u32 = __riscv_vreinterpret_v_b4_u32m1(mask);
1073-
matches = __riscv_vmv_x_s_u32m1_u32(mask_u32);
1074-
return ZSTD_rotateRight_U32((U32)matches, head);
1072+
{
1073+
vuint8m2_t chunk = __riscv_vle8_v_u8m2(src, vl);
1074+
vbool4_t mask = __riscv_vmseq_vx_u8m2_b4(chunk, tag, vl);
1075+
vuint32m1_t mask_u32 = __riscv_vreinterpret_v_b4_u32m1(mask);
1076+
matches = __riscv_vmv_x_s_u32m1_u32(mask_u32);
1077+
return ZSTD_rotateRight_U32((U32)matches, head);
1078+
}
10751079
} else { // rowEntries = 64
10761080
vl = __riscv_vsetvl_e8m4(64);
1077-
vuint8m4_t chunk = __riscv_vle8_v_u8m4(src, vl);
1078-
vbool2_t mask = __riscv_vmseq_vx_u8m4_b2(chunk, tag, vl);
1079-
vuint64m1_t mask_u64 = __riscv_vreinterpret_v_b2_u64m1(mask);
1080-
matches = __riscv_vmv_x_s_u64m1_u64(mask_u64);
1081-
return ZSTD_rotateRight_U64(matches, head);
1081+
{
1082+
vuint8m4_t chunk = __riscv_vle8_v_u8m4(src, vl);
1083+
vbool2_t mask = __riscv_vmseq_vx_u8m4_b2(chunk, tag, vl);
1084+
vuint64m1_t mask_u64 = __riscv_vreinterpret_v_b2_u64m1(mask);
1085+
matches = __riscv_vmv_x_s_u64m1_u64(mask_u64);
1086+
return ZSTD_rotateRight_U64(matches, head);
1087+
}
10821088
}
10831089
}
10841090
#endif

0 commit comments

Comments
 (0)