fix(riscv): reject partial vd/vs2 overlap in narrowing ops - #200
fix(riscv): reject partial vd/vs2 overlap in narrowing ops#200carlosqwqqwq wants to merge 2 commits into
Conversation
|
Blocking review finding: the new register-count calculation rejects legal fractional-LMUL narrowing encodings. The code first rounds every fractional LMUL to one occupied destination register and then computes The subsequent Please calculate EMUL as a rational value before converting it to occupied registers, and add regression cases covering fractional LMUL, odd/even register numbers, legal lowest-part overlap, disjoint groups, and illegal partial overlap. The PR currently adds no executable regression tests. Spec: https://docs.riscv.org/reference/isa/unpriv/v-st-ext Repository policy note: this PR adds to |
cpu.rs exceeded the AGENTS.md hard split triggers (2000 lines / 150 kB). Move the vector (RVV) element access and data-path execution group, including set_vtype, into cpu/vector.rs with no behavior change.
Narrowing instructions read a 2*LMUL vs2 group and write an LMUL vd; only the lowest-part overlap vd == vs2 is legal. Reject misaligned groups and partial overlap. With fractional LMUL the source EMUL is below one register, so the source group occupies a single register and odd vs2 registers remain legal.
b65f65c to
c0a88f9
Compare
|
Thanks for the review. Reworked as suggested:
Verified locally: |
|
Thanks @carlosqwqqwq. This fix is being consolidated into rollup PR #203, where it shares centralized direct-interpreter, SMIR/JIT, and QEMU differential coverage with the related RVV corrections. Closing this PR in favor of #203; the relevant rollup commits credit you as co-author. |
fix(riscv): reject partial vd/vs2 overlap in narrowing ops
Closes #195
Summary
RVV §5.2 permits a destination group to overlap a narrowing source group only in its lowest-numbered part (
vd == vs2); misaligned groups and partial overlap are reserved encodings. The validation computes the source group size from the rational EMUL (2*LMUL), so fractional LMUL configurations keep a one-register source group and oddvs2registers remain legal.Validation
e32,mf2fully-overlapped and odd disjointvs2),m1/m2alignment rules, legal lowest-part overlap, disjoint groups, and illegal partial/misaligned overlaps.cargo test --lib: cpu suite 72 passed, 0 failed.Notes
The vector semantics moved to
cpu/vector.rsin #202 so this change does not grow the oversizedcpu.rs.