Skip to content

Commit

Permalink
Fix vftint_w_d variant's code, reported by Yang Liu
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 26, 2024
1 parent 8f0ba57 commit cf97720
Show file tree
Hide file tree
Showing 16 changed files with 200 additions and 28 deletions.
19 changes: 19 additions & 0 deletions code/vftintrm_w_d.cpp
Original file line number Diff line number Diff line change
@@ -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));
}
}
8 changes: 4 additions & 4 deletions code/vftintrm_w_d.h
Original file line number Diff line number Diff line change
@@ -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
}
19 changes: 19 additions & 0 deletions code/vftintrne_w_d.cpp
Original file line number Diff line number Diff line change
@@ -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));
}
}
8 changes: 4 additions & 4 deletions code/vftintrne_w_d.h
Original file line number Diff line number Diff line change
@@ -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
}
19 changes: 19 additions & 0 deletions code/vftintrp_w_d.cpp
Original file line number Diff line number Diff line change
@@ -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));
}
}
8 changes: 4 additions & 4 deletions code/vftintrp_w_d.h
Original file line number Diff line number Diff line change
@@ -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
}
19 changes: 19 additions & 0 deletions code/vftintrz_w_d.cpp
Original file line number Diff line number Diff line change
@@ -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));
}
}
8 changes: 4 additions & 4 deletions code/vftintrz_w_d.h
Original file line number Diff line number Diff line change
@@ -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
}
19 changes: 19 additions & 0 deletions code/xvftintrm_w_d.cpp
Original file line number Diff line number Diff line change
@@ -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));
}
}
11 changes: 8 additions & 3 deletions code/xvftintrm_w_d.h
Original file line number Diff line number Diff line change
@@ -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
}
19 changes: 19 additions & 0 deletions code/xvftintrne_w_d.cpp
Original file line number Diff line number Diff line change
@@ -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));
}
}
11 changes: 8 additions & 3 deletions code/xvftintrne_w_d.h
Original file line number Diff line number Diff line change
@@ -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
}
19 changes: 19 additions & 0 deletions code/xvftintrp_w_d.cpp
Original file line number Diff line number Diff line change
@@ -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));
}
}
11 changes: 8 additions & 3 deletions code/xvftintrp_w_d.h
Original file line number Diff line number Diff line change
@@ -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
}
19 changes: 19 additions & 0 deletions code/xvftintrz_w_d.cpp
Original file line number Diff line number Diff line change
@@ -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));
}
}
11 changes: 8 additions & 3 deletions code/xvftintrz_w_d.h
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit cf97720

Please sign in to comment.