target/riscv/vector_helper.c: Avoid shifting negative in fractional LMUL checking
PATCH 1/1 target/riscv/vector_helper.c: Avoid shifting negative in fractional LMUL checking
When vlmul is larger than 5, the original fractional LMUL checking may gets unexpected result.
--- target/riscv/vector_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target/riscv/vector_helper.c +1 -2
@@ -53,10 +53,9 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,* VLEN * LMUL >= SEW * VLEN >> (8 - lmul) >= sew * (vlenb << 3) >> (8 - lmul) >= sew -* vlenb >> (8 - 3 - lmul) >= sew */ if (vlmul ==4 || - cpu->cfg.vlenb >> (8 -3 - vlmul) < sew) { + ((cpu->cfg.vlenb <<3 ) >> (8 - vlmul)) < sew) { vill = true; } }
Signature · 1 line
2.34.1
Quoted 5 lines · Max Chou
When vlmul is larger than 5, the original fractional LMUL checking may gets unexpected result.
Signed-off-by Max Chou <[email protected]>---
There's already a fix for it in the ML:
"[PATCH v3] target/riscv: Fix shift count overflow"
https://lore.kernel.org/qemu-riscv/[email protected]/
Hopefully it'll be queued for the next PR. Thanks,
Daniel
Quoted 19 lines
target/riscv/vector_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/riscv/vector_helper.c +1
-2@@ -53,10 +53,9 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,* VLEN * LMUL >= SEW * VLEN >> (8 - lmul) >= sew * (vlenb << 3) >> (8 - lmul) >= sew -* vlenb >> (8 - 3 - lmul) >= sew */ if (vlmul ==4 || - cpu->cfg.vlenb >> (8 -3 - vlmul) < sew) { + ((cpu->cfg.vlenb <<3 ) >> (8 - vlmul)) < sew) { vill = true; } }
Looks liked that I missed this one.
Thank you Daniel
Max.
Quoted 43 lines · Daniel Henrique Barboza
Quoted 5 lines · Max Chou
When vlmul is larger than 5, the original fractional LMUL checking may gets unexpected result.
Signed-off-by Max Chou <[email protected]>---
There's already a fix for it in the ML:
"[PATCH v3] target/riscv: Fix shift count overflow"
https://lore.kernel.org/qemu-riscv/[email protected]/
Hopefully it'll be queued for the next PR. Thanks,
Daniel
Quoted 20 lines
target/riscv/vector_helper.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)target/riscv/vector_helper.c +0
-1@@ -53,10 +53,9 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env,target_ulong s1, * VLEN * LMUL >= SEW * VLEN >> (8 - lmul) >= sew * (vlenb << 3) >> (8 - lmul) >= sew -* vlenb >> (8 - 3 - lmul) >= sew */ if (vlmul == 4 ||
-cpu->cfg.vlenb>> (8 - 3 - vlmul) < sew) { + ((cpu->cfg.vlenb<< 3) >> (8 - vlmul)) < sew) { vill = true;
}
}