On Wed, 2026-11-04 at 01:34 +0800, WX Chen wrote: > This change adjusts the translation exit of `vsetivli`. While > preserving > the existing helper, state update flow, and TB boundaries, it uses > the > generic `gen_goto_tb()` path to reduce the overhead of repeated > successor-TB > lookups. > > `vsetivli` is used to set the vector length and type, and both its > AVL and > vtype encodings are provided by immediates. Given the CPU > configuration and > the source TB execution context, after this instruction completes > normally, > the vector state changes relevant to subsequent translation are > deterministic. Therefore, this exit is eligible for direct TB > linking. > > Measured on an AMD Ryzen AI 9 H 365 (x86-64) host, using qemu-riscv64 > with -cpu rv64,v=true,vlen=128,elen=64. A RISC-V GCC 14.2.0 cc1 built > for > rv64gcv compiles the packages with -O2 -g0 -march=rv64gcv - > mabi=lp64d. > Only cc1 runs under emulation; make, the compiler driver, assembler > and > linker run on the host. > > Each variant is warmed up once, followed by three paired clean builds > in > AB/BA/AB order, using -j1 and fixed host CPU affinity (CPU 7). Median > build > wall times are: > > Before (s) After (s) Wall time reduction > LZ4 1.10.0 125.017 123.060 1.57% > zlib 1.3.1 71.062 70.310 1.06% > > In a separate untimed test, a loop executes two vsetivli instructions > per > iteration for 37 iterations. Host-side GDB entry breakpoints show > that > helper_lookup_tb_ptr() entries at the two successor PCs fall from 74 > to 0. > The guest still executes 74 vsetivli instructions. Initial TB > dispatch and > link establishment still occur through the normal dispatcher. > > Signed-off-by: WX Chen <[email protected]>
Thanks! Applied to riscv-to-apply.next Alistair > --- > target/riscv/tcg/insn_trans/trans_rvv.c.inc | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/target/riscv/tcg/insn_trans/trans_rvv.c.inc > b/target/riscv/tcg/insn_trans/trans_rvv.c.inc > index > a22e2cae6ce8e5a055c106fb76c305c92ac53d3c..b299c82d7a29057433e280b49b5 > 220e6ad71498f 100644 > --- a/target/riscv/tcg/insn_trans/trans_rvv.c.inc > +++ b/target/riscv/tcg/insn_trans/trans_rvv.c.inc > @@ -234,8 +234,7 @@ static bool do_vsetivli(DisasContext *s, int rd, > TCGv s1, TCGv s2) > gen_helper_vsetvl(dst, tcg_env, s1, s2, tcg_constant_tl(0)); > gen_set_gpr(s, rd, dst); > finalize_rvv_inst(s); > - gen_update_pc(s, s->cur_insn_len); > - lookup_and_goto_ptr(s); > + gen_goto_tb(s, 0, s->cur_insn_len); > s->base.is_jmp = DISAS_NORETURN; > > return true; > > --- > base-commit: d73149283205645625bfa9fe029cfb68e4c4a9ae > change-id: 20261104-research-vsetivli-direct-chain-20261103- > 69536f07be37 > > Best regards,
