Skip to content

Commit

Permalink
Merge pull request #75 from howjmay/undefined
Browse files Browse the repository at this point in the history
feat: Add _mm_undefined_[pd|ps|si128]
  • Loading branch information
howjmay authored Jan 27, 2024
2 parents 3216dc6 + b73b9cf commit 036a6e6
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 21 deletions.
45 changes: 42 additions & 3 deletions sse2rvv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3476,11 +3476,50 @@ FORCE_INLINE int _mm_ucomineq_ss(__m128 a, __m128 b) {
return _mm_comineq_ss(a, b);
}

// FORCE_INLINE _mm_undefined_pd (void) {}
FORCE_INLINE __m128d _mm_undefined_pd(void) {
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
#endif
__m128d a;
#if defined(_MSC_VER)
a = _mm_setzero_pd();
#endif
return a;
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
}

// FORCE_INLINE __m128 _mm_undefined_ps (void) {}
FORCE_INLINE __m128 _mm_undefined_ps(void) {
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
#endif
__m128 a;
#if defined(_MSC_VER)
a = _mm_setzero_ps();
#endif
return a;
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
}

// FORCE_INLINE __m128i _mm_undefined_si128 (void) {}
FORCE_INLINE __m128i _mm_undefined_si128(void) {
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
#endif
__m128i a;
#if defined(_MSC_VER)
a = _mm_setzero_si128();
#endif
return a;
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
}

FORCE_INLINE __m128i _mm_unpackhi_epi16(__m128i a, __m128i b) {
vuint16m2_t _a = __riscv_vlmul_ext_v_u16m1_u16m2(vreinterpretq_m128i_u16(a));
Expand Down
36 changes: 18 additions & 18 deletions tests/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3649,13 +3649,13 @@ result_t test_mm_ucomineq_ss(const SSE2RVV_TEST_IMPL &impl, uint32_t iter) {
}

result_t test_mm_undefined_ps(const SSE2RVV_TEST_IMPL &impl, uint32_t iter) {
// #ifdef ENABLE_TEST_ALL
// __m128 a = _mm_undefined_ps();
// a = _mm_xor_ps(a, a);
// return validate_float(a, 0, 0, 0, 0);
// #else
#ifdef ENABLE_TEST_ALL
__m128 a = _mm_undefined_ps();
a = _mm_xor_ps(a, a);
return validate_float(a, 0, 0, 0, 0);
#else
return TEST_UNIMPL;
// #endif // ENABLE_TEST_ALL
#endif // ENABLE_TEST_ALL
}

result_t test_mm_unpackhi_ps(const SSE2RVV_TEST_IMPL &impl, uint32_t iter) {
Expand Down Expand Up @@ -8048,23 +8048,23 @@ result_t test_mm_ucomineq_sd(const SSE2RVV_TEST_IMPL &impl, uint32_t iter) {
}

result_t test_mm_undefined_pd(const SSE2RVV_TEST_IMPL &impl, uint32_t iter) {
// #ifdef ENABLE_TEST_ALL
// __m128d a = _mm_undefined_pd();
// a = _mm_xor_pd(a, a);
// return validate_double(a, 0, 0);
// #else
#ifdef ENABLE_TEST_ALL
__m128d a = _mm_undefined_pd();
a = _mm_xor_pd(a, a);
return validate_double(a, 0, 0);
#else
return TEST_UNIMPL;
// #endif // ENABLE_TEST_ALL
#endif // ENABLE_TEST_ALL
}

result_t test_mm_undefined_si128(const SSE2RVV_TEST_IMPL &impl, uint32_t iter) {
// #ifdef ENABLE_TEST_ALL
// __m128i a = _mm_undefined_si128();
// a = _mm_xor_si128(a, a);
// return validate_int64(a, 0, 0);
// #else
#ifdef ENABLE_TEST_ALL
__m128i a = _mm_undefined_si128();
a = _mm_xor_si128(a, a);
return validate_int64(a, 0, 0);
#else
return TEST_UNIMPL;
// #endif // ENABLE_TEST_ALL
#endif // ENABLE_TEST_ALL
}

result_t test_mm_unpackhi_epi16(const SSE2RVV_TEST_IMPL &impl, uint32_t iter) {
Expand Down

0 comments on commit 036a6e6

Please sign in to comment.