Skip to contentSkip to conversation

target/riscv: trans_rvv: Avoid assert for RV32 and e64

PATCH Applied Alistair Francis 3 participants 3 messages Jun 8, 2022 – Jun 9, 2022 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/riscv: trans_rvv: Avoid assert for RV32 and e64

From: Alistair Francis <[email protected]>

When running a 32-bit guest, with a e64 vmv.v.x and vl_eq_vlmax set to true the tcg_debug_assert(vece <= MO_32) will be triggered inside tcg_gen_gvec_dup_i32().

This patch checks that condition and instead uses tcg_gen_gvec_dup_i64() is required.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1028

---
 target/riscv/insn_trans/trans_rvv.c.inc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
target/riscv/insn_trans/trans_rvv.c.inc +10 -2
index 391c61fe93..6b27d8e91e 100644
@@ -2097,8 +2097,16 @@ static bool trans_vmv_v_x(DisasContext *s, arg_vmv_v_x *a)
         s1 = get_gpr(s, a->rs1, EXT_SIGN);
 
         if (s->vl_eq_vlmax) {
-            tcg_gen_gvec_dup_tl(s->sew, vreg_ofs(s, a->rd),
-                                MAXSZ(s), MAXSZ(s), s1);
+            if (get_xl(s) == MXL_RV32 && s->sew == MO_64) {
+                TCGv_i64 s1_i64 = tcg_temp_new_i64();
+                tcg_gen_ext_tl_i64(s1_i64, s1);
+                tcg_gen_gvec_dup_i64(s->sew, vreg_ofs(s, a->rd),
+                                     MAXSZ(s), MAXSZ(s), s1_i64);
+                tcg_temp_free_i64(s1_i64);
+            } else {
+                tcg_gen_gvec_dup_tl(s->sew, vreg_ofs(s, a->rd),
+                                    MAXSZ(s), MAXSZ(s), s1);
+            }
         } else {
             TCGv_i32 desc;
             TCGv_i64 s1_i64 = tcg_temp_new_i64();
Signature · 1 line
2.36.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Alistair Francis

From: Alistair Francis <[email protected]>

When running a 32-bit guest, with a e64 vmv.v.x and vl_eq_vlmax set to true the tcg_debug_assert(vece <= MO_32) will be triggered inside tcg_gen_gvec_dup_i32().

Quoted 6 lines

This patch checks that condition and instead uses tcg_gen_gvec_dup_i64() is required.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1028

r~

Quoted 27 lines
---
  target/riscv/insn_trans/trans_rvv.c.inc | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
target/riscv/insn_trans/trans_rvv.c.inc +10 -2
index 391c61fe93..6b27d8e91e 100644
@@ -2097,8 +2097,16 @@ static bool trans_vmv_v_x(DisasContext *s, arg_vmv_v_x *a)
          s1 = get_gpr(s, a->rs1, EXT_SIGN);
 
          if (s->vl_eq_vlmax) {
-            tcg_gen_gvec_dup_tl(s->sew, vreg_ofs(s, a->rd),
-                                MAXSZ(s), MAXSZ(s), s1);
+            if (get_xl(s) == MXL_RV32 && s->sew == MO_64) {
+                TCGv_i64 s1_i64 = tcg_temp_new_i64();
+                tcg_gen_ext_tl_i64(s1_i64, s1);
+                tcg_gen_gvec_dup_i64(s->sew, vreg_ofs(s, a->rd),
+                                     MAXSZ(s), MAXSZ(s), s1_i64);
+                tcg_temp_free_i64(s1_i64);
+            } else {
+                tcg_gen_gvec_dup_tl(s->sew, vreg_ofs(s, a->rd),
+                                    MAXSZ(s), MAXSZ(s), s1);
+            }
          } else {
              TCGv_i32 desc;
              TCGv_i64 s1_i64 = tcg_temp_new_i64();
#2 lore raw
In reply to Alistair Francis
Quoted 7 lines · Alistair Francis

From: Alistair Francis <[email protected]>

When running a 32-bit guest, with a e64 vmv.v.x and vl_eq_vlmax set to true the tcg_debug_assert(vece <= MO_32) will be triggered inside tcg_gen_gvec_dup_i32().

Quoted 6 lines

This patch checks that condition and instead uses tcg_gen_gvec_dup_i64() is required.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1028

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 30 lines
---
 target/riscv/insn_trans/trans_rvv.c.inc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
target/riscv/insn_trans/trans_rvv.c.inc +10 -3
index 391c61fe93..6b27d8e91e 100644
@@ -2097,8 +2097,16 @@ static bool trans_vmv_v_x(DisasContext *s, arg_vmv_v_x *a)
         s1 = get_gpr(s, a->rs1, EXT_SIGN);
 
         if (s->vl_eq_vlmax) {
-            tcg_gen_gvec_dup_tl(s->sew, vreg_ofs(s, a->rd),
-                                MAXSZ(s), MAXSZ(s), s1);
+            if (get_xl(s) == MXL_RV32 && s->sew == MO_64) {
+                TCGv_i64 s1_i64 = tcg_temp_new_i64();
+                tcg_gen_ext_tl_i64(s1_i64, s1);
+                tcg_gen_gvec_dup_i64(s->sew, vreg_ofs(s, a->rd),
+                                     MAXSZ(s), MAXSZ(s), s1_i64);
+                tcg_temp_free_i64(s1_i64);
+            } else {
+                tcg_gen_gvec_dup_tl(s->sew, vreg_ofs(s, a->rd),
+                                    MAXSZ(s), MAXSZ(s), s1);
+            }
         } else {
             TCGv_i32 desc;
             TCGv_i64 s1_i64 = tcg_temp_new_i64();
--

2.36.1