On 11/5/26 15:41, Chao Liu wrote:
I would like to discuss this a bit further. In fact, we can divide this into
five cases:
Case Condition Current implementation
------------------------------------------------------------------------------
1. vsetvl rd, rs1, rs2 vtype from rs2 register keep lookup_and_goto_ptr()
2. vsetvli x0, x0, imm rd == 0 && rs1 == 0 keep lookup_and_goto_ptr()
3. vsetvli rd, rs1, imm rd != 0 && rs1 != 0 new path
4. vsetvli x0, rs1, imm rd == 0 && rs1 != 0 new path
5. vsetvli rd, x0, imm rd != 0 && rs1 == 0 new path
Currently there are two TB exit forms:
- Case1 and Case2 is the existing lookup_and_goto_ptr() exit.
- Case3 ~ Case5 is the new split exit, which compares the returned VL against
VLMAX and uses two goto_tb slots.
The new path can be improved. For rs1 == 0 a single gen_goto_tb() call is
enough, because the successor TB lookup key cannot change between executions.
So, We give three exit forms:
1. lookup: keep lookup_and_goto_ptr()
2. single: one gen_goto_tb() slot
3. split: compare VL against VLMAX and use two gen_goto_tb() slots
The cases map to the exit forms as follows:
Case Exit form
--------------------------------------
1 lookup
2 lookup
3 split, or single when maxsz < 8
4 split, or single when maxsz < 8
5 single
For cases 3 and 4, we care about the case where VL is not equal to
VLMAX. To explain this, let us look at VL_EQ_VLMAX first. It is computed
in riscv_get_tb_cpu_state() in target/riscv/tcg/tcg-cpu.c:
vl_eq_vlmax = (env->vstart == 0) && (vlmax == env->vl) && (maxsz >= 8)
In two cases, the AVL comes from a GPR rather than an immediate, so
VL may or may not equal VLMAX. Using the split exit is fine in that
situation. When maxsz < 8, however, VL_EQ_VLMAX is forced to zero. In
that case, both VL values map to the same successor key during the TB
lookup, so a single slot is enough.
Hi Chao:
Thanks for the detailed review! I hadn't noticed the maxsz >= 8
condition for VL_EQ_VLMAX.
Thanks for pointing that out!
I'll take this condition into account in v2.
Best regards,
WX Chen