On 9/24/23 01:03, Nick Bowler wrote:
On a real UltraSparc II, the fmul8x16au instruction takes two single-
precision input operands and returns a double-precision result.  For
the second operand, bits 31:16 are used, and bits 15:0 are ignored.

However, the emulation is taking two double-precision input operands,
and furthermore it is using bits 15:0 of the second operand (ignoring
bits 31:16).  These are unlikely to contain the correct values.

Even still, the emulator overwrites the second input before all outputs
are calculated, so even if by chance the data loaded in happens to be
correct, the results are just garbage except in trivial cases.

Signed-off-by: Nick Bowler <nbow...@draconx.ca>
---
  target/sparc/helper.h     |  2 +-
  target/sparc/translate.c  | 19 ++++++++++++++++++-
  target/sparc/vis_helper.c | 14 +++++++++-----
  3 files changed, 28 insertions(+), 7 deletions(-)

Reviewed-by: Richard Henderson <richard.hender...@linaro.org>

  #define PMUL(r)                                                 \
-    tmp = (int32_t)d.VIS_SW64(0) * (int32_t)s.VIS_B64(r);       \
+    tmp = (int32_t)s2.VIS_SW32(1) * (int32_t)s1.VIS_B64(r);     \
      if ((tmp & 0xff) > 0x7f) {                                  \
          tmp += 0x100;                                           \
      }                                                           \

Belated follow-up suggestion:

-   if ((tmp & 0xff) > 0x7f) {
-       tmp += 0x100;
-   }
+   tmp += 0x80;

7 occurrences throughout vis_helper.c.


r~

Reply via email to