aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2021-04-30 14:01:59 +0200
committerTor Egge <Tor.Egge@online.no>2021-04-30 14:01:59 +0200
commitb65c800a2aad33445ba456a7c594d9a998cd0fe8 (patch)
treeccd892ae6bccf026936ea84bb1d2183008ce2bf6 /searchlib
parentcf0d0a6d071f19d830633267796fca09f67ba89d (diff)
Avoid intel asm when not using x86_64 platform.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/bitcompression/compression.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/searchlib/src/vespa/searchlib/bitcompression/compression.h b/searchlib/src/vespa/searchlib/bitcompression/compression.h
index e6b171ec871..c25ed126fe0 100644
--- a/searchlib/src/vespa/searchlib/bitcompression/compression.h
+++ b/searchlib/src/vespa/searchlib/bitcompression/compression.h
@@ -933,8 +933,12 @@ template <>
inline uint64_t
EncodeContext64EBase<true>::bswap(uint64_t val)
{
+#ifdef __x86_64__
__asm__("bswap %0" : "=r" (val) : "0" (val));
return val;
+#else
+ return __builtin_bswap64(val);
+#endif
}
@@ -967,10 +971,11 @@ public:
#if (defined(__x86_64__)) && defined(DO_ASMLOG)
__asm("bsrq %1,%0" : "=r" (retVal) : "r" (x));
-
+#elif defined(__aarch64__) && defined(DO_ASMLOG)
+ return sizeof(uint64_t) * 8 - 1 - __builtin_clzl(x);
#else
- register uint64_t lower = x;
- uint32_t upper32 = lower >> 32;
+ uint64_t lower = x;
+ uint32_t upper32 = lower >> 32;
if (upper32 != 0) {
uint32_t upper16 = upper32 >> 16;
if (upper16 != 0) {
@@ -996,9 +1001,13 @@ public:
static inline uint64_t
ffsl(uint64_t x)
{
+#ifdef __x86_64__
uint64_t retVal;
__asm("bsfq %1,%0" : "=r" (retVal) : "r" (x));
return retVal;
+#else
+ return __builtin_ctzl(x);
+#endif
}
/**