From ba90cdeb5aba1ecc12b2f31d744969e6a9ca8030 Mon Sep 17 00:00:00 2001 From: Apostolos Tapsas Date: Fri, 5 Nov 2021 13:34:48 +0000 Subject: [PATCH] SuperVector constructors as well as andnot implementation fixed --- src/nfa/ppc64el/shufti.hpp | 4 ++-- src/util/arch/ppc64el/match.hpp | 16 ++++++++-------- src/util/supervector/arch/ppc64el/impl.cpp | 15 ++++++++------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/nfa/ppc64el/shufti.hpp b/src/nfa/ppc64el/shufti.hpp index 76461175..dedeb52d 100644 --- a/src/nfa/ppc64el/shufti.hpp +++ b/src/nfa/ppc64el/shufti.hpp @@ -43,7 +43,7 @@ const SuperVector blockSingleMask(SuperVector mask_lo, SuperVector mask c_lo = mask_lo.template pshufb(c_lo); c_hi = mask_hi.template pshufb(c_hi); - return (c_lo & c_hi) > (SuperVector::Zeroes()); + return (c_lo & c_hi).eq(SuperVector::Zeroes()); } template @@ -72,5 +72,5 @@ SuperVector blockDoubleMask(SuperVector mask1_lo, SuperVector mask1_hi, SuperVector t = t1 | (t2.template vshr_128_imm<1>()); t.print8("t"); - return !t.eq(SuperVector::Ones()); + return t.eq(SuperVector::Ones()); } diff --git a/src/util/arch/ppc64el/match.hpp b/src/util/arch/ppc64el/match.hpp index 3cb3d667..3f24ce7f 100644 --- a/src/util/arch/ppc64el/match.hpp +++ b/src/util/arch/ppc64el/match.hpp @@ -30,10 +30,10 @@ 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); diff --git a/src/util/supervector/arch/ppc64el/impl.cpp b/src/util/supervector/arch/ppc64el/impl.cpp index acdb89d4..20a735b8 100644 --- a/src/util/supervector/arch/ppc64el/impl.cpp +++ b/src/util/supervector/arch/ppc64el/impl.cpp @@ -74,7 +74,7 @@ template<> template<> really_inline SuperVector<16>::SuperVector(uint8_t const other) { - u.v128[0] = (m128) vec_splats(static_cast(other)); + u.v128[0] = (m128) vec_splats(static_cast(other)); } template<> @@ -88,7 +88,7 @@ template<> template<> really_inline SuperVector<16>::SuperVector(uint16_t const other) { - u.v128[0] = (m128) vec_splats(static_cast(other)); + u.v128[0] = (m128) vec_splats(static_cast(other)); } template<> @@ -102,7 +102,7 @@ template<> template<> really_inline SuperVector<16>::SuperVector(uint32_t const other) { - u.v128[0] = (m128) vec_splats(static_cast(other)); + u.v128[0] = (m128) vec_splats(static_cast(other)); } template<> @@ -116,7 +116,7 @@ template<> template<> really_inline SuperVector<16>::SuperVector(uint64_t const other) { - u.v128[0] = (m128) vec_splats(static_cast(other)); + u.v128[0] = (m128) vec_splats(static_cast(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 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 <>