Skip to content

Implement _mm_abs_epi* with wasm_*_abs #12372

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
Sep 30, 2020
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
6 changes: 3 additions & 3 deletions site/source/docs/porting/simd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -783,11 +783,11 @@ The following table highlights the availability and expected performance of diff
* - Intrinsic name
- WebAssembly SIMD support
* - _mm_abs_epi8
- ⚠️ emulated with a SIMD shift+xor+add
- ✅ wasm_i8x16_abs
* - _mm_abs_epi16
- ⚠️ emulated with a SIMD shift+xor+add
- ✅ wasm_i16x8_abs
* - _mm_abs_epi32
- ⚠️ emulated with a SIMD shift+xor+add
- ✅ wasm_i32x4_abs
* - _mm_alignr_epi8
- ⚠️ emulated with a SIMD or+two shifts
* - _mm_hadd_epi16
Expand Down
9 changes: 3 additions & 6 deletions system/include/SSE/tmmintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,19 @@
static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_abs_epi8(__m128i __a)
{
__m128i __mask = (__m128i)wasm_i8x16_shr((v128_t)__a, 7);
return _mm_xor_si128(_mm_add_epi8(__a, __mask), __mask);
return (__m128i)wasm_i8x16_abs((v128_t)__a);
}

static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_abs_epi16(__m128i __a)
{
__m128i __mask = _mm_srai_epi16(__a, 15);
return _mm_xor_si128(_mm_add_epi16(__a, __mask), __mask);
return (__m128i)wasm_i16x8_abs((v128_t)__a);
}

static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_abs_epi32(__m128i __a)
{
__m128i __mask = _mm_srai_epi32(__a, 31);
return _mm_xor_si128(_mm_add_epi32(__a, __mask), __mask);
return (__m128i)wasm_i32x4_abs((v128_t)__a);
}

#define _mm_alignr_epi8(__a, __b, __count) \
Expand Down