diff --git a/code/common.h b/code/common.h index a47e106f..33040190 100644 --- a/code/common.h +++ b/code/common.h @@ -185,7 +185,8 @@ union v256 { void test(); void print(const char *s, v128 num) { - printf("v128 as __m128i %s: 0x%016lx 0x%016lx\n", s, num.dword[0], num.dword[1]); + printf("v128 as __m128i %s: 0x%016lx 0x%016lx\n", s, num.dword[0], + num.dword[1]); printf("v128 as __m128 %s: %f %f %f %f\n", s, num.fp32[0], num.fp32[1], num.fp32[2], num.fp32[3]); printf("v128 as __m128d %s: %lf %lf\n", s, num.fp64[0], num.fp64[1]); @@ -204,8 +205,8 @@ void print(const char *s, __m128d num) { } void print(const char *s, v256 num) { - printf("v256 as __m256i %s: 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n", s, num.dword[0], - num.dword[1], num.dword[2], num.dword[3]); + printf("v256 as __m256i %s: 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n", s, + num.dword[0], num.dword[1], num.dword[2], num.dword[3]); printf("v256 as __m256 %s: %f %f %f %f %f %f %f %f\n", s, num.fp32[0], num.fp32[1], num.fp32[2], num.fp32[3], num.fp32[4], num.fp32[5], num.fp32[6], num.fp32[7]); @@ -214,8 +215,8 @@ void print(const char *s, v256 num) { } void print(const char *s, __m256i num) { - printf("__m256i %s: 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n", s, num[0], num[1], - num[2], num[3]); + printf("__m256i %s: 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n", s, num[0], + num[1], num[2], num[3]); } void print(const char *s, __m256 num) { diff --git a/code/vftint_w_d.cpp b/code/vftint_w_d.cpp new file mode 100644 index 00000000..ca54af0c --- /dev/null +++ b/code/vftint_w_d.cpp @@ -0,0 +1,19 @@ +#include "common.h" + +v128 vftint_w_d(v128 a, v128 b) { + v128 dst; +#include "vftint_w_d.h" + return dst; +} + +void test() { + { + __m128d a = {1.0, 2.0}; + __m128d b = {3.0, 4.0}; + PRINT(a); + PRINT(b); + PRINT(__lsx_vftint_w_d(a, b)); + PRINT(vftint_w_d(a, b)); + assert(vftint_w_d(a, b) == __lsx_vftint_w_d(a, b)); + } +} diff --git a/code/vftint_w_d.h b/code/vftint_w_d.h index 6874cf44..20bbde7a 100644 --- a/code/vftint_w_d.h +++ b/code/vftint_w_d.h @@ -1,5 +1,5 @@ -for (int i = 0; i < 2; i++) { - dst.dword[i] = (i < 1) - ? (s64)a.fp64[i] - : (s64)b.fp64[i]; // rounding mode is not expressed in C +for (int i = 0; i < 4; i++) { + dst.word[i] = (i < 2) + ? (s64)b.fp64[i] + : (s64)a.fp64[i - 2]; // rounding mode is not expressed in C } diff --git a/code/xvsetanyeqz_b.cpp b/code/xvsetanyeqz_b.cpp index d272ccec..3bdf3c2b 100644 --- a/code/xvsetanyeqz_b.cpp +++ b/code/xvsetanyeqz_b.cpp @@ -19,11 +19,13 @@ void test() { assert(__lasx_xbz_b(a)); assert(__lasx_xbz_b(a) == xbz_b(a)); - a = __m256i{0x1111111111111111, 0x1111111111111111, 0x1111111111111111, 0x1111111111111111}; + a = __m256i{0x1111111111111111, 0x1111111111111111, 0x1111111111111111, + 0x1111111111111111}; assert(!__lasx_xbz_b(a)); assert(__lasx_xbz_b(a) == xbz_b(a)); - a = __m256i{0x1111111111111100, 0x1111111111111111, 0x1111111111111111, 0x1111111111111111}; + a = __m256i{0x1111111111111100, 0x1111111111111111, 0x1111111111111111, + 0x1111111111111111}; assert(__lasx_xbz_b(a)); assert(__lasx_xbz_b(a) == xbz_b(a)); } \ No newline at end of file diff --git a/code/xvsetanyeqz_d.cpp b/code/xvsetanyeqz_d.cpp index 6f0ae824..c47ae5ac 100644 --- a/code/xvsetanyeqz_d.cpp +++ b/code/xvsetanyeqz_d.cpp @@ -19,11 +19,13 @@ void test() { assert(__lasx_xbz_d(a)); assert(__lasx_xbz_d(a) == xbz_d(a)); - a = __m256i{0x1111111111111111, 0x1111111111111111, 0x1111111111111111, 0x1111111111111111}; + a = __m256i{0x1111111111111111, 0x1111111111111111, 0x1111111111111111, + 0x1111111111111111}; assert(!__lasx_xbz_d(a)); assert(__lasx_xbz_d(a) == xbz_d(a)); - a = __m256i{0x0000000000000000, 0x1111111111111111, 0x1111111111111111, 0x1111111111111111}; + a = __m256i{0x0000000000000000, 0x1111111111111111, 0x1111111111111111, + 0x1111111111111111}; assert(__lasx_xbz_d(a)); assert(__lasx_xbz_d(a) == xbz_d(a)); } \ No newline at end of file diff --git a/code/xvsetanyeqz_h.cpp b/code/xvsetanyeqz_h.cpp index 179652e2..41e3b283 100644 --- a/code/xvsetanyeqz_h.cpp +++ b/code/xvsetanyeqz_h.cpp @@ -19,11 +19,13 @@ void test() { assert(__lasx_xbz_h(a)); assert(__lasx_xbz_h(a) == xbz_h(a)); - a = __m256i{0x1111111111111111, 0x1111111111111111, 0x1111111111111111, 0x1111111111111111}; + a = __m256i{0x1111111111111111, 0x1111111111111111, 0x1111111111111111, + 0x1111111111111111}; assert(!__lasx_xbz_h(a)); assert(__lasx_xbz_h(a) == xbz_h(a)); - a = __m256i{0x1111111111110000, 0x1111111111111111, 0x1111111111111111, 0x1111111111111111}; + a = __m256i{0x1111111111110000, 0x1111111111111111, 0x1111111111111111, + 0x1111111111111111}; assert(__lasx_xbz_h(a)); assert(__lasx_xbz_h(a) == xbz_h(a)); } \ No newline at end of file diff --git a/code/xvsetanyeqz_w.cpp b/code/xvsetanyeqz_w.cpp index eebd6a75..e02efdbc 100644 --- a/code/xvsetanyeqz_w.cpp +++ b/code/xvsetanyeqz_w.cpp @@ -19,11 +19,13 @@ void test() { assert(__lasx_xbz_w(a)); assert(__lasx_xbz_w(a) == xbz_w(a)); - a = __m256i{0x1111111111111111, 0x1111111111111111, 0x1111111111111111, 0x1111111111111111}; + a = __m256i{0x1111111111111111, 0x1111111111111111, 0x1111111111111111, + 0x1111111111111111}; assert(!__lasx_xbz_w(a)); assert(__lasx_xbz_w(a) == xbz_w(a)); - a = __m256i{0x1111111100000000, 0x1111111111111111, 0x1111111111111111, 0x1111111111111111}; + a = __m256i{0x1111111100000000, 0x1111111111111111, 0x1111111111111111, + 0x1111111111111111}; assert(__lasx_xbz_w(a)); assert(__lasx_xbz_w(a) == xbz_w(a)); } \ No newline at end of file