[PATCH] target/i386: fix avx2 instructions vzeroall and vpermdq

lixinyu20s@ict.ac.cn posted 1 patch 1 year ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230510145222.586487-1-lixinyu20s@ict.ac.cn
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>
target/i386/ops_sse.h      | 8 ++++++++
target/i386/tcg/emit.c.inc | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
[PATCH] target/i386: fix avx2 instructions vzeroall and vpermdq
Posted by lixinyu20s@ict.ac.cn 1 year ago
From: Xinyu Li <lixinyu20s@ict.ac.cn>

vzeroall: xmm_regs should be used instead of xmm_t0
vpermdq: bit 3 and 7 of imm should be considered

Signed-off-by: Xinyu Li <lixinyu20s@ict.ac.cn>
---
 target/i386/ops_sse.h      | 8 ++++++++
 target/i386/tcg/emit.c.inc | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h
index 0bd6bfad8a..fb63af7afa 100644
--- a/target/i386/ops_sse.h
+++ b/target/i386/ops_sse.h
@@ -2497,6 +2497,14 @@ void helper_vpermdq_ymm(Reg *d, Reg *v, Reg *s, uint32_t order)
     d->Q(1) = r1;
     d->Q(2) = r2;
     d->Q(3) = r3;
+    if (order & 0x8) {
+        d->Q(0) = 0;
+        d->Q(1) = 0;
+    }
+    if (order & 0x80) {
+        d->Q(2) = 0;
+        d->Q(3) = 0;
+    }
 }
 
 void helper_vpermq_ymm(Reg *d, Reg *s, uint32_t order)
diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
index 95fb4f52fa..4fe8dec427 100644
--- a/target/i386/tcg/emit.c.inc
+++ b/target/i386/tcg/emit.c.inc
@@ -2285,7 +2285,7 @@ static void gen_VZEROALL(DisasContext *s, CPUX86State *env, X86DecodedInsn *deco
 {
     TCGv_ptr ptr = tcg_temp_new_ptr();
 
-    tcg_gen_addi_ptr(ptr, cpu_env, offsetof(CPUX86State, xmm_t0));
+    tcg_gen_addi_ptr(ptr, cpu_env, offsetof(CPUX86State, xmm_regs));
     gen_helper_memset(ptr, ptr, tcg_constant_i32(0),
                       tcg_constant_ptr(CPU_NB_REGS * sizeof(ZMMReg)));
 }
-- 
2.34.1
Re: [PATCH] target/i386: fix avx2 instructions vzeroall and vpermdq
Posted by Michael Tokarev 1 year ago
10.05.2023 17:52, lixinyu20s@ict.ac.cn wrote:
> From: Xinyu Li <lixinyu20s@ict.ac.cn>
> 
> vzeroall: xmm_regs should be used instead of xmm_t0
> vpermdq: bit 3 and 7 of imm should be considered

-stable material, it looks like?

Thanks,

/mjt
Re: [PATCH] target/i386: fix avx2 instructions vzeroall and vpermdq
Posted by Paolo Bonzini 1 year ago
Queued, thanks.

Paolo