Skip to content

Commit

Permalink
Fix xvftint_w_d 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 1df495b commit 8f0ba57
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
19 changes: 19 additions & 0 deletions code/xvftint_w_d.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "common.h"

v256 xvftint_w_d(v256 a, v256 b) {
v256 dst;
#include "xvftint_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_xvftint_w_d(a, b));
PRINT(xvftint_w_d(a, b));
assert(xvftint_w_d(a, b) == __lasx_xvftint_w_d(a, b));
}
}
11 changes: 8 additions & 3 deletions code/xvftint_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 8f0ba57

Please sign in to comment.