about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2023-04-09 14:41:36 +0800
committerGitHub <noreply@github.com>2023-04-09 08:41:36 +0200
commit24f2720df43c4570ab9d344a688e0a36d0a8fa88 (patch)
tree04e3028d83969421887e29468106f46b416b9144
parentd9c30c8942888d609d89df5b8ea29071d2663b46 (diff)
downloadbox64-24f2720df43c4570ab9d344a688e0a36d0a8fa88.tar.gz
box64-24f2720df43c4570ab9d344a688e0a36d0a8fa88.zip
[TESTS] Disable compiler optimizations for test17 and some related fixes (#677)
* [TESTS] Disable compiler optimizations for test17

* [INTERP] Fixed MAXSD/MINSD when both sources are 0

* [RV64_DYNAREC] Fixed F2 0F 5D MINSD opcode
-rw-r--r--src/dynarec/rv64/dynarec_rv64_f20f.c8
-rw-r--r--src/emu/x64runf20f.c4
-rw-r--r--tests/ref17.txt8
-rwxr-xr-xtests/test17bin254544 -> 137224 bytes
-rw-r--r--tests/test17.c37
5 files changed, 34 insertions, 23 deletions
diff --git a/src/dynarec/rv64/dynarec_rv64_f20f.c b/src/dynarec/rv64/dynarec_rv64_f20f.c
index 6cb62e3c..2a8089a1 100644
--- a/src/dynarec/rv64/dynarec_rv64_f20f.c
+++ b/src/dynarec/rv64/dynarec_rv64_f20f.c
@@ -161,7 +161,13 @@ uintptr_t dynarec64_F20F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
             INST_NAME("MINSD Gx, Ex");
             nextop = F8;
             GETGXSD(v0);
-            GETEXSD(v1, 0);        
+            GETEXSD(v1, 0);
+            d0 = sse_get_reg_empty(dyn, ninst, x1, x4, 0);
+            FMVDX(d0, xZR);
+            FEQD(x2, v0, d0);
+            FEQD(x3, v1, d0);
+            AND(x2, x2, x3);
+            BNE_MARK(x2, xZR);
             FEQD(x2, v0, v0);
             FEQD(x3, v1, v1);
             AND(x2, x2, x3);
diff --git a/src/emu/x64runf20f.c b/src/emu/x64runf20f.c
index 10da2f09..33750318 100644
--- a/src/emu/x64runf20f.c
+++ b/src/emu/x64runf20f.c
@@ -205,6 +205,8 @@ uintptr_t RunF20F(x64emu_t *emu, rex_t rex, uintptr_t addr, int *step)
         nextop = F8;

         GETEX(0);

         GETGX;

+        if (GX->d[0] == 0.0 && EX->d[0]  == 0.0)

+            GX->d[0] = EX->d[0];

         if (isnan(GX->d[0]) || isnan(EX->d[0]) || isless(EX->d[0], GX->d[0]))

             GX->d[0] = EX->d[0];

         break;

@@ -225,6 +227,8 @@ uintptr_t RunF20F(x64emu_t *emu, rex_t rex, uintptr_t addr, int *step)
         nextop = F8;

         GETEX(0);

         GETGX;

+        if (GX->d[0] == 0.0 && EX->d[0]  == 0.0)

+            GX->d[0] = EX->d[0];

         if (isnan(GX->d[0]) || isnan(EX->d[0]) || isgreater(EX->d[0], GX->d[0]))

             GX->d[0] = EX->d[0];

         break;

diff --git a/tests/ref17.txt b/tests/ref17.txt
index 2f5688f2..865dabc2 100644
--- a/tests/ref17.txt
+++ b/tests/ref17.txt
@@ -489,8 +489,8 @@ mulsd(0 -2 , -0 0x7ff8000000000000 ) = -0 -2
 subsd(1 2 , 1 2 ) = 0 2 
 subsd(1 2 , 0 -2 ) = 1 2 
 subsd(1 2 , inf -inf ) = -inf 2 
-subsd(1 2 , 0x7ff8000000000000 -0 ) = 0xfff8000000000000 2 
-subsd(0 -2 , 0x7ff8000000000000 -0 ) = 0xfff8000000000000 -2 
+subsd(1 2 , 0x7ff8000000000000 -0 ) = 0x7ff8000000000000 2 
+subsd(0 -2 , 0x7ff8000000000000 -0 ) = 0x7ff8000000000000 -2 
 subsd(inf -inf , 0x7ff8000000000000 -0 ) = 0x7ff8000000000000 -inf 
 subsd(1 2 , 2 1 ) = -1 2 
 subsd(1 2 , -2 0 ) = 3 2 
@@ -532,8 +532,8 @@ maxsd(1 2 , 2 1 ) = 2 2
 maxsd(1 2 , -2 0 ) = 1 2 
 maxsd(1 2 , -inf inf ) = 1 2 
 maxsd(1 2 , -0 0x7ff8000000000000 ) = 1 2 
-maxsd(0 -2 , -0 0x7ff8000000000000 ) = 0 -2 
-maxsd(0 -2 , -0 0x7ff8000000000000 ) = 0 -2 
+maxsd(0 -2 , -0 0x7ff8000000000000 ) = -0 -2 
+maxsd(0 -2 , -0 0x7ff8000000000000 ) = -0 -2 
 cvtps2pd(1 2 3 -4 ) = 0x1 0x2 0x3 0xfffffffc 
 cvtps2pd(0 -2 -10 0.5 ) = 0x0 0xfffffffe 0xfffffff6 0x0 
 cvtps2pd(inf -inf -inf 1 ) = 0x80000000 0x80000000 0x80000000 0x1 
diff --git a/tests/test17 b/tests/test17
index 4a28a47f..ebb01718 100755
--- a/tests/test17
+++ b/tests/test17
Binary files differdiff --git a/tests/test17.c b/tests/test17.c
index 2c0e549d..632d13ce 100644
--- a/tests/test17.c
+++ b/tests/test17.c
@@ -1,5 +1,6 @@
-// build with  gcc -O2 -g -msse -msse2 -mssse3 -msse4.1 test17.c -o test17
+// build with  gcc -O0 -g -msse -msse2 -mssse3 -msse4.1 test17.c -o test17
 // and -m32 for 32bits version
+#include <inttypes.h>
 #include <string.h>
 #include <stdio.h>
 #include <stddef.h>
@@ -141,7 +142,7 @@ void print_32(v128 v) {
 }
 void print_64(v128 v) {
     for(int i=0; i<2; ++i)
-        printf("0x%llx ", v.u64[i]);
+        printf("0x%"PRIx64" ", v.u64[i]);
 }
 #define print_128 print_64
 void print_ps(v128 v) {
@@ -154,7 +155,7 @@ void print_ps(v128 v) {
 void print_pd(v128 v) {
     for(int i=0; i<2; ++i)
         if(isnan(v.d64[i]))
-            printf("0x%llx ", v.u64[i]);
+            printf("0x%"PRIx64" ", v.u64[i]);
         else
             printf("%g ", v.d64[i]);
 }
@@ -163,7 +164,7 @@ void print_pd(v128 v) {
 int main(int argc, const char** argv)
 {
  float a, b;
- uint64_t flags;
+ uint32_t flags;
  uint32_t maxf = 0x7f7fffff;
  uint32_t minf = 0xff7fffff;
  uint32_t r;
@@ -171,40 +172,40 @@ int main(int argc, const char** argv)
 #define GO1(A, N)                                   \
 a = 1.0f; b = 2.0f;                                 \
 flags = A(a, b);                                    \
-printf(N " %f, %f => 0x%lx\n", a, b, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", a, b, flags);  \
 flags = A(b, a);                                    \
-printf(N " %f, %f => 0x%lx\n", b, a, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", b, a, flags);  \
 b = INFINITY;                                       \
 flags = A(a, b);                                    \
-printf(N " %f, %f => 0x%lx\n", a, b, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", a, b, flags);  \
 flags = A(b, a);                                    \
-printf(N " %f, %f => 0x%lx\n", b, a, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", b, a, flags);  \
 b = -INFINITY;                                      \
 flags = A(a, b);                                    \
-printf(N " %f, %f => 0x%lx\n", a, b, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", a, b, flags);  \
 flags = A(b, a);                                    \
-printf(N " %f, %f => 0x%lx\n", b, a, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", b, a, flags);  \
 b = NAN;                                            \
 flags = A(a, b);                                    \
-printf(N " %f, %f => 0x%lx\n", a, b, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", a, b, flags);  \
 flags = A(b, a);                                    \
-printf(N " %f, %f => 0x%lx\n", b, a, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", b, a, flags);  \
 b = a;                                              \
 flags = A(a, b);                                    \
-printf(N " %f, %f => 0x%lx\n", a, b, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", a, b, flags);  \
 flags = A(b, a);                                    \
-printf(N " %f, %f => 0x%lx\n", b, a, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", b, a, flags);  \
 a = b = INFINITY;                                   \
 flags = A(a, b);                                    \
-printf(N " %f, %f => 0x%lx\n", a, b, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", a, b, flags);  \
 a = -INFINITY;                                      \
 flags = A(a, b);                                    \
-printf(N " %f, %f => 0x%lx\n", a, b, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", a, b, flags);  \
 flags = A(b, a);                                    \
-printf(N " %f, %f => 0x%lx\n", b, a, flags);        \
+printf(N " %f, %f => 0x%"PRIx32"\n", b, a, flags);  \
 a = b = NAN;                                        \
 flags = A(a, b);                                    \
-printf(N " %f, %f => 0x%lx\n", a, b, flags);
+printf(N " %f, %f => 0x%"PRIx32"\n", a, b, flags);
 
 #define GO2(A, N)                               \
 a = 1.0f; b = 2.0f;                             \