From 866cc5733d71b28dc4775d025fa4f48dce4d7ae4 Mon Sep 17 00:00:00 2001 From: jinboson Date: Fri, 20 Dec 2024 02:42:20 +0800 Subject: [PATCH] x86 clmul simde_x_bitreverse_u64: add loongarch implementation (#1249) --- 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);