Make more code aarch64 friendly

This commit is contained in:
Justine Tunney 2023-05-02 13:38:16 -07:00
parent ca2860947f
commit 2b73e72d59
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
568 changed files with 2197 additions and 1061 deletions

View file

@ -38,6 +38,7 @@ static dontinline antiquity int bcmp_sse(const char *p, const char *q,
return !!(a[0] | a[1]);
}
#ifdef __x86_64__
microarchitecture("avx") static int bcmp_avx(const char *p, const char *q,
size_t n) {
xmm_t a, b, c, d;
@ -67,6 +68,7 @@ microarchitecture("avx") static int bcmp_avx(const char *p, const char *q,
*(const xmm_t *)(p + n - 16) ^ *(const xmm_t *)(q + n - 16);
return !!(a[0] | a[1]);
}
#endif
/**
* Tests inequality of first 𝑛 bytes of 𝑝 and 𝑞.
@ -122,8 +124,10 @@ int bcmp(const void *a, const void *b, size_t n) {
__builtin_memcpy(&j, q + n - 4, 4);
return !!(i ^ j);
}
#ifdef __x86_64__
} else if (LIKELY(X86_HAVE(AVX))) {
return bcmp_avx(p, q, n);
#endif
} else {
return bcmp_sse(p, q, n);
}