]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
move andn helper function to bitutils.h
authorKonstantinos Margaritis <markos@freevec.org>
Tue, 22 Sep 2020 09:17:27 +0000 (12:17 +0300)
committerKonstantinos Margaritis <markos@freevec.org>
Tue, 22 Sep 2020 09:17:27 +0000 (12:17 +0300)
src/fdr/fdr.c
src/util/arch/common/bitutils.h
src/util/arch/x86/bitutils.h
src/util/bitutils.h

index d33756d3588bc69b0c27230aeee639fc8e5d4eea..b0f90b52112d7614a88e5adeaec6d71adc214cd8 100644 (file)
@@ -36,6 +36,7 @@
 #include "teddy.h"
 #include "teddy_internal.h"
 #include "util/arch.h"
+#include "util/bitutils.h"
 #include "util/simd_utils.h"
 #include "util/uniform_ops.h"
 
@@ -119,20 +120,6 @@ const ALIGN_CL_DIRECTIVE u8 zone_or_mask[ITER_BYTES+1][ITER_BYTES] = {
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
 };
 
-/* compilers don't reliably synthesize the 32-bit ANDN instruction here,
- * so we force its generation.
- */
-static really_inline
-u64a andn(const u32 a, const u8 *b) {
-    u64a r;
-#if defined(HAVE_BMI) && !defined(NO_ASM)
-    __asm__ ("andn\t%2,%1,%k0" : "=r"(r) : "r"(a), "m"(*(const u32 *)b));
-#else
-    r = unaligned_load_u32(b) & ~a;
-#endif
-    return r;
-}
-
 /* generates an initial state mask based on the last byte-ish of history rather
  * than being all accepting. If there is no history to consider, the state is
  * generated based on the minimum length of each bucket in order to prevent
index 85d5dc49bb7a5a5779a36198ab2d04c9112fd84f..f2706d70bfeec22775b48dda2266a05acbb63452 100644 (file)
@@ -34,6 +34,7 @@
 #define BITUTILS_ARCH_COMMON_H
 
 #include "util/popcount.h"
+#include "util/unaligned.h"
 
 static really_inline
 u32 clz32_impl_c(u32 x) {
@@ -350,4 +351,12 @@ u64a pext64_impl_c(u64a x, u64a mask) {
     return result;
 }
 
+/* compilers don't reliably synthesize the 32-bit ANDN instruction here,
+ * so we force its generation.
+ */
+static really_inline
+u64a andn_impl_c(const u32 a, const u8 *b) {
+    return unaligned_load_u32(b) & ~a;
+}
+
 #endif // BITUTILS_ARCH_COMMON_H
index da7c747efc15fee28ce9259c37921435b79b11b2..ec4c95ad93a07f1f7533f361df2be5ef824fe163 100644 (file)
@@ -301,4 +301,18 @@ u64a pdep64(u64a x, u64a mask) {
 }
 #endif
 
+/* compilers don't reliably synthesize the 32-bit ANDN instruction here,
+ * so we force its generation.
+ */
+static really_inline
+u64a andn_impl(const u32 a, const u8 *b) {
+#if defined(HAVE_BMI) && !defined(NO_ASM)
+    u64a r;
+    __asm__ ("andn\t%2,%1,%k0" : "=r"(r) : "r"(a), "m"(*(const u32 *)b));
+    return r;
+#else
+    return andn_impl_c(a, b);
+#endif
+}
+
 #endif // BITUTILS_ARCH_X86_H
index 651e5f93d40877e7faa7f32816924bb82046a1d9..b9f312cbb09e954f617d80934a307bdc3f662dd4 100644 (file)
@@ -167,4 +167,12 @@ u64a pext64(u64a x, u64a mask) {
     return pext64_impl(x, mask);
 }
 
+/* compilers don't reliably synthesize the 32-bit ANDN instruction here,
+ * so we force its generation.
+ */
+static really_inline
+u64a andn(const u32 a, const u8 *b) {
+    return andn_impl_c(a, b);
+}
+
 #endif // BITUTILS_H