From b9fb7eb57b79ce0a31d385c68f12b37dddc716ab Mon Sep 17 00:00:00 2001 From: jinbo Date: Thu, 19 Dec 2024 17:48:09 +0800 Subject: [PATCH] x86 clmul: add loongarch implementation for simde_x_bitreverse_u64 --- simde/x86/clmul.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/simde/x86/clmul.h b/simde/x86/clmul.h index e2d8b4cf8..7d51b5b3f 100644 --- a/simde/x86/clmul.h +++ b/simde/x86/clmul.h @@ -101,6 +101,10 @@ simde_x_bitreverse_u64(uint64_t v) { return HEDLEY_STATIC_CAST(uint64_t, _mm_cvtsi128_si64(vec)); #elif HEDLEY_HAS_BUILTIN(__builtin_bitreverse64) return __builtin_bitreverse64(v); + #elif defined(__loongarch64) + uint64_t r; + __asm__ __volatile__ ("bitrev.d %0, %1" :"=&r"(r):"r"(v):); + return r; #else v = ((v >> 1) & UINT64_C(0x5555555555555555)) | ((v & UINT64_C(0x5555555555555555)) << 1); v = ((v >> 2) & UINT64_C(0x3333333333333333)) | ((v & UINT64_C(0x3333333333333333)) << 2);