]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
add AVX2 specializations
authorKonstantinos Margaritis <markos@freevec.org>
Mon, 12 Jul 2021 18:09:10 +0000 (21:09 +0300)
committerKonstantinos Margaritis <konstantinos@vectorcamp.gr>
Tue, 12 Oct 2021 08:51:34 +0000 (11:51 +0300)
src/util/match.hpp

index 74da50d879e431e331b31f7c3b791eca88444695..ba72e2e9de7f6a0619c803586df22b59a7329ff5 100644 (file)
@@ -56,6 +56,19 @@ const u8 *firstMatch<16>(const u8 *buf, typename SuperVector<16>::movemask_type
     }
 }
 
+template <>
+really_really_inline
+const u8 *firstMatch<32>(const u8 *buf, typename SuperVector<32>::movemask_type z) {
+    DEBUG_PRINTF("z 0x%08x\n", z);
+    if (unlikely(z != 0xffffffff)) {
+        u32 pos = ctz32(~z);
+        assert(pos < 32);
+        DEBUG_PRINTF("match @ pos %u\n", pos);
+        return buf + pos;
+    } else {
+        return NULL; // no match
+    }
+}
 template <>
 really_really_inline
 const u8 *firstMatch<64>(const u8 *buf, typename SuperVector<64>::movemask_type z) {
@@ -86,6 +99,19 @@ const u8 *lastMatch<16>(const u8 *buf, typename SuperVector<16>::movemask_type z
     }
 }
 
+template<>
+really_really_inline
+const u8 *lastMatch<32>(const u8 *buf, typename SuperVector<32>::movemask_type z) {
+    if (unlikely(z != 0xffffffff)) {
+        u32 pos = clz32(~z);
+        DEBUG_PRINTF("buf=%p, pos=%u\n", buf, pos);
+        assert(pos < 32);
+        return buf + (31 - pos);
+    } else {
+        return NULL; // no match
+    }
+}
+
 template <>
 really_really_inline
 const u8 *lastMatch<64>(const u8 *buf, typename SuperVector<64>::movemask_type z) {