riscv: correct fractional LMUL legality check in vsetvl
PATCH 1/1 riscv: correct fractional LMUL legality check in vsetvl
--- target/riscv/vector_helper.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
target/riscv/vector_helper.c +3 -9
@@ -47,18 +47,12 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,target_ulong reserved = s2 &MAKE_64BIT_MASK (R_VTYPE_RESERVED_SHIFT , xlen -1 -R_VTYPE_RESERVED_SHIFT ); -uint16_t vlen = cpu->cfg.vlenb <<3 ;int8_t lmul;if (vlmul &4 ) { -/* -* Fractional LMUL, check: -* -* VLEN * LMUL >= SEW -* VLEN >> (8 - lmul) >= sew -* (vlenb << 3) >> (8 - lmul) >= sew -*/ -if (vlmul ==4 || (vlen >> (8 - vlmul)) < sew) { +/* fractional LMUL legality check: LMUL × ELEN ≥ SEW */ +int divisor =1 << (8 - vlmul);/* converts encoding into divisor for fractional LMUL */ +if (vlmul ==4 || cpu->cfg.elen < sew * divisor) { vill = true; } }
Signature · 1 line
2.49.0