]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
SuperVector constructors as well as andnot implementation fixed
authorApostolos Tapsas <apostolos@vm01.debian11>
Fri, 5 Nov 2021 13:34:48 +0000 (13:34 +0000)
committerApostolos Tapsas <apostolos@vm01.debian11>
Fri, 5 Nov 2021 13:34:48 +0000 (13:34 +0000)
src/nfa/ppc64el/shufti.hpp
src/util/arch/ppc64el/match.hpp
src/util/supervector/arch/ppc64el/impl.cpp

index 76461175689ad3ab52dcd262369c54cf0b0c8bf8..dedeb52de1b37971e54f998046679c22b9da224b 100644 (file)
@@ -43,7 +43,7 @@ const SuperVector<S> blockSingleMask(SuperVector<S> mask_lo, SuperVector<S> mask
     c_lo = mask_lo.template pshufb<false>(c_lo);
     c_hi = mask_hi.template pshufb<false>(c_hi);
 
-    return (c_lo & c_hi) > (SuperVector<S>::Zeroes());
+    return (c_lo & c_hi).eq(SuperVector<S>::Zeroes());
 }
 
 template <uint16_t S>
@@ -72,5 +72,5 @@ SuperVector<S> blockDoubleMask(SuperVector<S> mask1_lo, SuperVector<S> mask1_hi,
     SuperVector<S> t = t1 | (t2.template vshr_128_imm<1>());
     t.print8("t");
 
-    return !t.eq(SuperVector<S>::Ones());
+    return t.eq(SuperVector<S>::Ones());
 }
index 3cb3d667e0104f7a9337475053af8e780d735ba1..3f24ce7f5e00b8fb46b632022f120c257323fea4 100644 (file)
 template <>
 really_really_inline
 const u8 *firstMatch<16>(const u8 *buf, SuperVector<16> v) {
-    SuperVector<16>::movemask_type z = v.movemask();
-    DEBUG_PRINTF("buf %p z %08x \n", buf, z);
-    DEBUG_PRINTF("z %08x\n", z);
-    if (unlikely(z != 0xffff)) {
+    if (unlikely(vec_any_ne(v.u.v128[0], SuperVector<16>::Ones().u.v128[0]))) {
+        SuperVector<16>::movemask_type z = v.movemask();
+        DEBUG_PRINTF("buf %p z %08x \n", buf, z);
+        DEBUG_PRINTF("z %08x\n", z);
         u32 pos = ctz32(~z & 0xffff);
         DEBUG_PRINTF("~z %08x\n", ~z);
         DEBUG_PRINTF("match @ pos %u\n", pos);
@@ -47,10 +47,10 @@ const u8 *firstMatch<16>(const u8 *buf, SuperVector<16> v) {
 template <>
 really_really_inline
 const u8 *lastMatch<16>(const u8 *buf, SuperVector<16> v) {
-    SuperVector<16>::movemask_type z = v.movemask();
-    DEBUG_PRINTF("buf %p z %08x \n", buf, z);
-    DEBUG_PRINTF("z %08x\n", z);
-    if (unlikely(z != 0xffff)) {
+    if (unlikely(vec_any_ne(v.u.v128[0], SuperVector<16>::Ones().u.v128[0]))) {
+        SuperVector<16>::movemask_type z = v.movemask();
+        DEBUG_PRINTF("buf %p z %08x \n", buf, z);
+        DEBUG_PRINTF("z %08x\n", z);
         u32 pos = clz32(~z & 0xffff);
         DEBUG_PRINTF("~z %08x\n", ~z);
         DEBUG_PRINTF("match @ pos %u\n", pos);
index acdb89d44dc8011d7a1974bd3581c093dd16c27e..20a735b8e06900423b6ddaf667156060a66afdf7 100644 (file)
@@ -74,7 +74,7 @@ template<>
 template<>
 really_inline SuperVector<16>::SuperVector<uint8_t>(uint8_t const other)
 {
-    u.v128[0] = (m128) vec_splats(static_cast<int8_t>(other));
+    u.v128[0] = (m128) vec_splats(static_cast<uint8_t>(other));
 }
 
 template<>
@@ -88,7 +88,7 @@ template<>
 template<>
 really_inline SuperVector<16>::SuperVector<uint16_t>(uint16_t const other)
 {
-    u.v128[0] = (m128) vec_splats(static_cast<int8_t>(other));
+    u.v128[0] = (m128) vec_splats(static_cast<uint16_t>(other));
 }
 
 template<>
@@ -102,7 +102,7 @@ template<>
 template<>
 really_inline SuperVector<16>::SuperVector<uint32_t>(uint32_t const other)
 {
-    u.v128[0] = (m128) vec_splats(static_cast<int8_t>(other));
+    u.v128[0] = (m128) vec_splats(static_cast<uint32_t>(other));
 }
 
 template<>
@@ -116,7 +116,7 @@ template<>
 template<>
 really_inline SuperVector<16>::SuperVector<uint64_t>(uint64_t const other)
 {
-    u.v128[0] = (m128) vec_splats(static_cast<int8_t>(other));
+    u.v128[0] = (m128) vec_splats(static_cast<uint64_t>(other));
 }
 
 // Constants
@@ -167,7 +167,8 @@ really_inline SuperVector<16> SuperVector<16>::operator!() const
 template <>
 really_inline SuperVector<16> SuperVector<16>::opandnot(SuperVector<16> const &b) const
 {
-    return vec_xor(vec_and(u.v128[0], b.u.v128[0]), vec_and(u.v128[0], b.u.v128[0]));
+   m128 not_res = vec_xor(u.v128[0], (m128)vec_splat_s8(-1));
+   return {(m128) vec_and(not_res, (m128)b.u.v128[0]) };
 }
 
 
@@ -311,8 +312,8 @@ really_inline SuperVector<16> SuperVector<16>::vshr_32_imm() const
 template <>
 template<uint8_t N>
 really_inline SuperVector<16> SuperVector<16>::vshr_64_imm() const
-{              
-    return { (m128) vec_sr((int64x2_t)u.v128[0], vec_splats((uint64_t)N)) }; 
+{               
+   return { (m128) vec_sr((int64x2_t)u.v128[0], vec_splats((uint64_t)N)) }; 
 }
 
 template <>