Skip to content

Avoid scalarization in _mm_madd_epi16 #13454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/source/docs/porting/simd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ The following table highlights the availability and expected performance of diff
* - _mm_loadu_si32
- ❌ emulated with wasm_i32x4_make
* - _mm_madd_epi16
- ❌ scalarized
- ✅ wasm_dot_s_i32x4_i16x8
* - _mm_maskmoveu_si128
- ❌ scalarized
* - _mm_max_epi16
Expand Down
15 changes: 1 addition & 14 deletions system/include/compat/emmintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,20 +669,7 @@ _mm_avg_epu16(__m128i __a, __m128i __b)
static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_madd_epi16(__m128i __a, __m128i __b)
{
// TODO: optimize
union {
signed short x[8];
__m128i m;
} src, src2;
union {
signed int x[4];
__m128i m;
} dst;
src.m = __a;
src2.m = __b;
for(int i = 0; i < 4; ++i)
dst.x[i] = src.x[i*2] * src2.x[i*2] + src.x[i*2+1] * src2.x[i*2+1];
return dst.m;
return (__m128i)__builtin_wasm_dot_s_i32x4_i16x8((__i16x8)__a, (__i16x8)__b);
}

static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
Expand Down