qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 8/8] target/sparc: Fix VIS subtraction instructions.


From: Nick Bowler
Subject: [PATCH 8/8] target/sparc: Fix VIS subtraction instructions.
Date: Mon, 25 Sep 2023 01:03:57 -0400

All of the VIS subtraction instructions are documented to subtract the
second input operand from the first.  This is also consistent with how
the instructions actually work on a real UltraSparc II.

But the emulator is implementing the subtraction in the wrong order,
subtracting the first input from the second, so the results are wrong
in all nontrivial cases.

Signed-off-by: Nick Bowler <nbowler@draconx.ca>
---
 target/sparc/vis_helper.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/target/sparc/vis_helper.c b/target/sparc/vis_helper.c
index 3903beaf5d..fa97e09ffa 100644
--- a/target/sparc/vis_helper.c
+++ b/target/sparc/vis_helper.c
@@ -282,10 +282,10 @@ uint64_t helper_fexpand(uint32_t src2)
         s.ll = src1;                                    \
         d.ll = src2;                                    \
                                                         \
-        d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0));   \
-        d.VIS_W64(1) = F(d.VIS_W64(1), s.VIS_W64(1));   \
-        d.VIS_W64(2) = F(d.VIS_W64(2), s.VIS_W64(2));   \
-        d.VIS_W64(3) = F(d.VIS_W64(3), s.VIS_W64(3));   \
+        d.VIS_W64(0) = F(s.VIS_W64(0), d.VIS_W64(0));   \
+        d.VIS_W64(1) = F(s.VIS_W64(1), d.VIS_W64(1));   \
+        d.VIS_W64(2) = F(s.VIS_W64(2), d.VIS_W64(2));   \
+        d.VIS_W64(3) = F(s.VIS_W64(3), d.VIS_W64(3));   \
                                                         \
         return d.ll;                                    \
     }                                                   \
@@ -297,8 +297,8 @@ uint64_t helper_fexpand(uint32_t src2)
         s.l = src1;                                     \
         d.l = src2;                                     \
                                                         \
-        d.VIS_W32(0) = F(d.VIS_W32(0), s.VIS_W32(0));   \
-        d.VIS_W32(1) = F(d.VIS_W32(1), s.VIS_W32(1));   \
+        d.VIS_W32(0) = F(s.VIS_W32(0), d.VIS_W32(0));   \
+        d.VIS_W32(1) = F(s.VIS_W32(1), d.VIS_W32(1));   \
                                                         \
         return d.l;                                     \
     }                                                   \
@@ -310,8 +310,8 @@ uint64_t helper_fexpand(uint32_t src2)
         s.ll = src1;                                    \
         d.ll = src2;                                    \
                                                         \
-        d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0));   \
-        d.VIS_L64(1) = F(d.VIS_L64(1), s.VIS_L64(1));   \
+        d.VIS_L64(0) = F(s.VIS_L64(0), d.VIS_L64(0));   \
+        d.VIS_L64(1) = F(s.VIS_L64(1), d.VIS_L64(1));   \
                                                         \
         return d.ll;                                    \
     }                                                   \
@@ -323,7 +323,7 @@ uint64_t helper_fexpand(uint32_t src2)
         s.l = src1;                                     \
         d.l = src2;                                     \
                                                         \
-        d.l = F(d.l, s.l);                              \
+        d.l = F(s.l, d.l);                              \
                                                         \
         return d.l;                                     \
     }
-- 
2.41.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]