24#if !defined(__clang__)
25 static_assert(
false,
"This only works on clang.");
29 #include <immintrin.h>
32#if defined(__ARM_NEON)
40static void test_mm_mulhrs_epi16_simulation() {
41 for (
int i = -32768;
i < 32768;
i++) {
42 for (
int j = -32768; j < 32768; j++) {
46 Q15 intrinsicResult = _mm_mulhrs_epi16(
a,
b);
47 for (
int i = 0;
i < 8;
i++) {
48 if (simResult[
i] != intrinsicResult[
i]) {
49 printf(
"simulate_ssse3_mm_mulhrs_epi16 broken\n");
50 printf(
"i: %d, a: %hx b: %hx, intrinsic: %hx, sim: %hx\n",
51 i,
a[
i],
b[
i], intrinsicResult[
i], simResult[
i]);
61 constexpr Q15 limit(0x8000);
62 const Q15 product = _mm_mulhrs_epi16(
a,
b);
63 const Q15 eq = _mm_cmpeq_epi16(product, limit);
64 return _mm_xor_si128(
eq, product);
67static void test_ssse3_vqrdmulhq_s16() {
68 for (
int i = -32768;
i < 32768;
i++) {
69 for (
int j = -32768; j < 32768; j++) {
72 Q15 simResult = ssse3_vqrdmulhq_s16(
a,
b);
74 for (
int i = 0;
i < 8;
i++) {
75 if (simResult[
i] != realVqrdmulhqS16[
i]) {
76 printf(
"simulating vqrdmulhq_s16 with ssse3 broken\n");
77 printf(
"i: %d, a: %hx b: %hx, intrinsic: %hx, sim: %hx\n",
78 i,
a[
i],
b[
i], realVqrdmulhqS16[
i], simResult[
i]);
88#if defined(__ARM_NEON)
89static void test_neon_vqrdmulhq_s16_simulation() {
90 for (
int i = -32768;
i < 32768;
i++) {
91 for (
int j = -32768; j < 32768; j++) {
95 Q15 intrinsicResult = vqrdmulhq_s16(
a,
b);
96 for (
int i = 0;
i < 8;
i++) {
97 if (simResult[
i] != intrinsicResult[
i]) {
98 printf(
"simulate_neon_vqrdmulhq_s16 broken\n");
99 printf(
"i: %d, a: %hx b: %hx, intrinsic: %hx, sim: %hx\n",
100 i,
a[
i],
b[
i], intrinsicResult[
i], simResult[
i]);
110 #if defined(__SSSE3__)
112 test_ssse3_vqrdmulhq_s16();
114 #if defined(__ARM_NEON)
115 test_neon_vqrdmulhq_s16_simulation();
static bool eq(const SkM44 &a, const SkM44 &b, float tol)
static I16 simulate_ssse3_mm_mulhrs_epi16(I16 a, I16 b)
static Q15 simulate_neon_vqrdmulhq_s16(Q15 a, Q15 b)
__attribute__((visibility("default"))) int RunBenchmarks(int argc
T __attribute__((ext_vector_type(N))) V
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1