diff --git a/code/vftintrm_w_d.cpp b/code/vftintrm_w_d.cpp new file mode 100644 index 0000000..4b34472 --- /dev/null +++ b/code/vftintrm_w_d.cpp @@ -0,0 +1,19 @@ +#include "common.h" + +v128 vftintrm_w_d(v128 a, v128 b) { + v128 dst; +#include "vftintrm_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_vftintrm_w_d(a, b)); + PRINT(vftintrm_w_d(a, b)); + assert(vftintrm_w_d(a, b) == __lsx_vftintrm_w_d(a, b)); + } +} diff --git a/code/vftintrm_w_d.h b/code/vftintrm_w_d.h index 6874cf4..20bbde7 100644 --- a/code/vftintrm_w_d.h +++ b/code/vftintrm_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/vftintrne_w_d.cpp b/code/vftintrne_w_d.cpp new file mode 100644 index 0000000..f1ba000 --- /dev/null +++ b/code/vftintrne_w_d.cpp @@ -0,0 +1,19 @@ +#include "common.h" + +v128 vftintrne_w_d(v128 a, v128 b) { + v128 dst; +#include "vftintrne_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_vftintrne_w_d(a, b)); + PRINT(vftintrne_w_d(a, b)); + assert(vftintrne_w_d(a, b) == __lsx_vftintrne_w_d(a, b)); + } +} diff --git a/code/vftintrne_w_d.h b/code/vftintrne_w_d.h index 6874cf4..20bbde7 100644 --- a/code/vftintrne_w_d.h +++ b/code/vftintrne_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/vftintrp_w_d.cpp b/code/vftintrp_w_d.cpp new file mode 100644 index 0000000..688a36a --- /dev/null +++ b/code/vftintrp_w_d.cpp @@ -0,0 +1,19 @@ +#include "common.h" + +v128 vftintrp_w_d(v128 a, v128 b) { + v128 dst; +#include "vftintrp_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_vftintrp_w_d(a, b)); + PRINT(vftintrp_w_d(a, b)); + assert(vftintrp_w_d(a, b) == __lsx_vftintrp_w_d(a, b)); + } +} diff --git a/code/vftintrp_w_d.h b/code/vftintrp_w_d.h index 6874cf4..20bbde7 100644 --- a/code/vftintrp_w_d.h +++ b/code/vftintrp_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/vftintrz_w_d.cpp b/code/vftintrz_w_d.cpp new file mode 100644 index 0000000..a8a64f1 --- /dev/null +++ b/code/vftintrz_w_d.cpp @@ -0,0 +1,19 @@ +#include "common.h" + +v128 vftintrz_w_d(v128 a, v128 b) { + v128 dst; +#include "vftintrz_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_vftintrz_w_d(a, b)); + PRINT(vftintrz_w_d(a, b)); + assert(vftintrz_w_d(a, b) == __lsx_vftintrz_w_d(a, b)); + } +} diff --git a/code/vftintrz_w_d.h b/code/vftintrz_w_d.h index 6874cf4..20bbde7 100644 --- a/code/vftintrz_w_d.h +++ b/code/vftintrz_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/xvftintrm_w_d.cpp b/code/xvftintrm_w_d.cpp new file mode 100644 index 0000000..29a0ea1 --- /dev/null +++ b/code/xvftintrm_w_d.cpp @@ -0,0 +1,19 @@ +#include "common.h" + +v256 xvftintrm_w_d(v256 a, v256 b) { + v256 dst; +#include "xvftintrm_w_d.h" + return dst; +} + +void test() { + { + __m256d a = {1.0, 2.0, 3.0, 4.0}; + __m256d b = {5.0, 6.0, 7.0, 8.0}; + PRINT(a); + PRINT(b); + PRINT(__lasx_xvftintrm_w_d(a, b)); + PRINT(xvftintrm_w_d(a, b)); + assert(xvftintrm_w_d(a, b) == __lasx_xvftintrm_w_d(a, b)); + } +} diff --git a/code/xvftintrm_w_d.h b/code/xvftintrm_w_d.h index 033e549..1e2eab1 100644 --- a/code/xvftintrm_w_d.h +++ b/code/xvftintrm_w_d.h @@ -1,5 +1,10 @@ for (int i = 0; i < 4; i++) { - dst.dword[i] = (i < 2) - ? (s64)a.fp64[i] - : (s64)b.fp64[i]; // rounding mode is not expressed in C + dst.word[i] = (i < 2) + ? (s64)b.fp64[i] + : (s64)a.fp64[i - 2]; // rounding mode is not expressed in C +} +for (int i = 4; i < 8; i++) { + dst.word[i] = (i < 6) + ? (s64)b.fp64[i - 2] + : (s64)a.fp64[i - 4]; // rounding mode is not expressed in C } diff --git a/code/xvftintrne_w_d.cpp b/code/xvftintrne_w_d.cpp new file mode 100644 index 0000000..2a4400e --- /dev/null +++ b/code/xvftintrne_w_d.cpp @@ -0,0 +1,19 @@ +#include "common.h" + +v256 xvftintrne_w_d(v256 a, v256 b) { + v256 dst; +#include "xvftintrne_w_d.h" + return dst; +} + +void test() { + { + __m256d a = {1.0, 2.0, 3.0, 4.0}; + __m256d b = {5.0, 6.0, 7.0, 8.0}; + PRINT(a); + PRINT(b); + PRINT(__lasx_xvftintrne_w_d(a, b)); + PRINT(xvftintrne_w_d(a, b)); + assert(xvftintrne_w_d(a, b) == __lasx_xvftintrne_w_d(a, b)); + } +} diff --git a/code/xvftintrne_w_d.h b/code/xvftintrne_w_d.h index 033e549..1e2eab1 100644 --- a/code/xvftintrne_w_d.h +++ b/code/xvftintrne_w_d.h @@ -1,5 +1,10 @@ for (int i = 0; i < 4; i++) { - dst.dword[i] = (i < 2) - ? (s64)a.fp64[i] - : (s64)b.fp64[i]; // rounding mode is not expressed in C + dst.word[i] = (i < 2) + ? (s64)b.fp64[i] + : (s64)a.fp64[i - 2]; // rounding mode is not expressed in C +} +for (int i = 4; i < 8; i++) { + dst.word[i] = (i < 6) + ? (s64)b.fp64[i - 2] + : (s64)a.fp64[i - 4]; // rounding mode is not expressed in C } diff --git a/code/xvftintrp_w_d.cpp b/code/xvftintrp_w_d.cpp new file mode 100644 index 0000000..3a05f2d --- /dev/null +++ b/code/xvftintrp_w_d.cpp @@ -0,0 +1,19 @@ +#include "common.h" + +v256 xvftintrp_w_d(v256 a, v256 b) { + v256 dst; +#include "xvftintrp_w_d.h" + return dst; +} + +void test() { + { + __m256d a = {1.0, 2.0, 3.0, 4.0}; + __m256d b = {5.0, 6.0, 7.0, 8.0}; + PRINT(a); + PRINT(b); + PRINT(__lasx_xvftintrp_w_d(a, b)); + PRINT(xvftintrp_w_d(a, b)); + assert(xvftintrp_w_d(a, b) == __lasx_xvftintrp_w_d(a, b)); + } +} diff --git a/code/xvftintrp_w_d.h b/code/xvftintrp_w_d.h index 033e549..1e2eab1 100644 --- a/code/xvftintrp_w_d.h +++ b/code/xvftintrp_w_d.h @@ -1,5 +1,10 @@ for (int i = 0; i < 4; i++) { - dst.dword[i] = (i < 2) - ? (s64)a.fp64[i] - : (s64)b.fp64[i]; // rounding mode is not expressed in C + dst.word[i] = (i < 2) + ? (s64)b.fp64[i] + : (s64)a.fp64[i - 2]; // rounding mode is not expressed in C +} +for (int i = 4; i < 8; i++) { + dst.word[i] = (i < 6) + ? (s64)b.fp64[i - 2] + : (s64)a.fp64[i - 4]; // rounding mode is not expressed in C } diff --git a/code/xvftintrz_w_d.cpp b/code/xvftintrz_w_d.cpp new file mode 100644 index 0000000..14ea771 --- /dev/null +++ b/code/xvftintrz_w_d.cpp @@ -0,0 +1,19 @@ +#include "common.h" + +v256 xvftintrz_w_d(v256 a, v256 b) { + v256 dst; +#include "xvftintrz_w_d.h" + return dst; +} + +void test() { + { + __m256d a = {1.0, 2.0, 3.0, 4.0}; + __m256d b = {5.0, 6.0, 7.0, 8.0}; + PRINT(a); + PRINT(b); + PRINT(__lasx_xvftintrz_w_d(a, b)); + PRINT(xvftintrz_w_d(a, b)); + assert(xvftintrz_w_d(a, b) == __lasx_xvftintrz_w_d(a, b)); + } +} diff --git a/code/xvftintrz_w_d.h b/code/xvftintrz_w_d.h index 033e549..1e2eab1 100644 --- a/code/xvftintrz_w_d.h +++ b/code/xvftintrz_w_d.h @@ -1,5 +1,10 @@ for (int i = 0; i < 4; i++) { - dst.dword[i] = (i < 2) - ? (s64)a.fp64[i] - : (s64)b.fp64[i]; // rounding mode is not expressed in C + dst.word[i] = (i < 2) + ? (s64)b.fp64[i] + : (s64)a.fp64[i - 2]; // rounding mode is not expressed in C +} +for (int i = 4; i < 8; i++) { + dst.word[i] = (i < 6) + ? (s64)b.fp64[i - 2] + : (s64)a.fp64[i - 4]; // rounding mode is not expressed in C }