scalar implementations of diffrich256 and diffrich384

This commit is contained in:
Konstantinos Margaritis 2020-10-16 13:02:40 +03:00
parent 4bce012570
commit c4db63665a
2 changed files with 12 additions and 3 deletions

View File

@ -26,13 +26,13 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "cpuid_flags.h" #include "util/arch/common/cpuid_flags.h"
#include "ue2common.h" #include "ue2common.h"
#include "hs_compile.h" // for HS_MODE_ flags #include "hs_compile.h" // for HS_MODE_ flags
#include "util/arch.h" #include "util/arch.h"
u64a cpuid_flags(void) { u64a cpuid_flags(void) {
return cap; return 0;
} }
u32 cpuid_tune(void) { u32 cpuid_tune(void) {

View File

@ -152,7 +152,7 @@ static really_inline int isnonzero256(m256 a) {
*/ */
static really_inline static really_inline
u32 diffrich256(m256 a, m256 b) { u32 diffrich256(m256 a, m256 b) {
return diffrich128(a.lo, b.lo) | (diffrich128(a.hi, b.hi) << 8); return diffrich128(a.lo, b.lo) | (diffrich128(a.hi, b.hi) << 4);
} }
/** /**
@ -384,6 +384,15 @@ static really_inline int isnonzero384(m384 a) {
return isnonzero128(or128(or128(a.lo, a.mid), a.hi)); return isnonzero128(or128(or128(a.lo, a.mid), a.hi));
} }
/**
* "Rich" version of diff384(). Takes two vectors a and b and returns a 12-bit
* mask indicating which 32-bit words contain differences.
*/
static really_inline
u32 diffrich384(m384 a, m384 b) {
return diffrich128(a.lo, b.lo) | (diffrich128(a.mid, b.mid) << 4) | (diffrich128(a.hi, b.hi) << 8);
}
/** /**
* "Rich" version of diff384(), 64-bit variant. Takes two vectors a and b and * "Rich" version of diff384(), 64-bit variant. Takes two vectors a and b and
* returns a 12-bit mask indicating which 64-bit words contain differences. * returns a 12-bit mask indicating which 64-bit words contain differences.