Skip to content

fix(riscv): reject widening vd/vs2 overlap beyond the high part - #206

Closed
carlosqwqqwq wants to merge 2 commits into
HexRaysSA:masterfrom
carlosqwqqwq:fix-riscv-widening-overlap-vx-vwmul
Closed

fix(riscv): reject widening vd/vs2 overlap beyond the high part#206
carlosqwqqwq wants to merge 2 commits into
HexRaysSA:masterfrom
carlosqwqqwq:fix-riscv-widening-overlap-vx-vwmul

Conversation

@carlosqwqqwq

Copy link
Copy Markdown
Contributor

fix(riscv): reject widening vd/vs2 overlap beyond the high part

Closes #205

Summary

The widening integer ops (vwadd/vwsub/vwmul/vwmacc families) write a 2*LMUL destination; RVV §5.2 only permits an overlap in the highest-numbered part of the destination group (source group ends where the destination ends). The existing check only covered the OPMVV forms of vwadd/vwsub; the OPMVX forms and the whole widening multiply family bypassed it, so reserved encodings executed normally.

Validation

  • Validation extended to funct3=0b010/0b110 and to Vwmulu/Vwmul/Vwmulsu/Vwmaccu/Vwmacc/Vwmaccsu/Vwmaccus; the .w forms use the wide source group width; fractional LMUL keeps one-register source and destination groups.
  • CPU regression covers high-part legal overlap, disjoint groups, low-part reserved overlap, misaligned destination, the vx form, and fractional-LMUL cases.
  • cargo test --lib: cpu suite 70 passed, 0 failed.

Notes

The vector semantics live in cpu/vector.rs after the refactor in #202, so this change does not grow the oversized cpu.rs.

carlosqwqqwq and others added 2 commits August 11, 2026 22:52
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.
The widening integer ops (vwadd/vwsub/vwmul/vwmacc families) write a 2*LMUL destination; only an overlap in the highest-numbered part of the destination group is legal (RVV §5.2). The .vx/.wx forms and the vwmulu/vwmaccu families were not validated. Fractional LMUL keeps one-register source and destination groups.
@19h

19h commented Aug 11, 2026

Copy link
Copy Markdown
Member

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.

@19h 19h closed this Aug 11, 2026
@carlosqwqqwq

Copy link
Copy Markdown
Contributor Author

Thanks for consolidating these into #203 and for the co-author credit. The local evidence (QEMU 8.2.2 -cpu max + native RV64 X60, three runs per probe) and the regression tests remain available in this branch if the rollup needs them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

widening integer ops accept illegal vd/vs2 group overlaps

2 participants