Skip to content

[hardware] 🐛 Fix register checks for single-register operands - #512

Open
davidharrishmc wants to merge 2 commits into
pulp-platform:mainfrom
davidharrishmc:fix/single-register-checks
Open

davidharrishmc wants to merge 2 commits into
pulp-platform:mainfrom
davidharrishmc:fix/single-register-checks

Conversation

@davidharrishmc

Copy link
Copy Markdown

Caution

This pull request was generated by an AI assistant (Claude Code) and has not been reviewed by a human. Please review it with that in mind.

Fixes #511. The dispatcher no longer applies the LMUL alignment check to operands that are always one register: the mask destination of integer and floating-point compares, vmadc and vmsbc; the mask operands of vmand.mm..vmxnor.mm and vmsbf/vmsif/vmsof.m; the vs2 of viota.m; vlm.v/vsm.v (EMUL = 1); and the vd/vs1 of single-width integer and floating-point reductions. The vmadc/vmsbc-specific check, which rejected vd equal to a source register and (at LMUL >= 2) non-overlapping registers, is replaced by the RVV 1.0 rule for every mask-producing instruction: vd may overlap a source group only at its lowest-numbered register. That rule keeps reserved overlaps such as vmseq.vv v5, v4, v6 at LMUL=2 illegal, which today only trap as a side effect of the alignment check.

Widening integer reductions are left to #478, which restructures the same OPIVV check, so the two will need a small rebase against each other.

Verification (Verilator, NrLanes=4, VLEN=512): a directed M-mode probe of 25 instructions. On main all 19 legal cases trap; with this change none do, the reserved cases (vredsum.vs v22, v19, v1, vmadc.vv v5, v4, v6, vmseq.vv v5, v4, v6, vmseq.vx v3, v2, a0, vmfeq.vv v5, v4, v6 at LMUL=2) still trap, and vmadc.vi v12, v12, -14 gives the expected carry mask. vwredsum.vs with an odd vd still traps until #478.

Changelog

Fixed

Checklist

  • Automated tests pass (Ara's own test suite was not run; see Verification)
  • Changelog updated
  • Code style guideline is observed

The dispatcher applied the LMUL alignment check to operands that are always one register, so
legal instructions raised illegal instruction when that register was not a multiple of LMUL:
the mask destination of integer and floating-point compares, vmadc and vmsbc; the mask operands
of the mask-logical instructions and vmsbf/vmsif/vmsof; the vs2 of viota.m; vlm.v/vsm.v, whose
EMUL is 1; and the vd/vs1 of single-width integer and floating-point reductions (widening
integer reductions are pulp-platform#478). vmadc/vmsbc also had their own check that rejected vd equal to a
source register and, at LMUL >= 2, registers that do not overlap at all.

Exempt those operands, and replace the vmadc/vmsbc check with the RVV 1.0 rule for every
mask-producing instruction: vd may overlap a source group only at its lowest-numbered register.

Fixes pulp-platform#511

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: David Harris <David_Harris@hmc.edu>
Forcing EMUL = 1 for vlm.v/vsm.v made the EMUL > 8 / < 1/8 check compare that EMUL with a
fractional LMUL, so vlm.v at e16 mf4 or mf2 raised illegal instruction. vlm.v/vsm.v are legal
for any valid vtype: skip the check for them in the load and store decoders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: David Harris <David_Harris@hmc.edu>
@davidharrishmc
davidharrishmc force-pushed the fix/single-register-checks branch from 70b89de to 9277c04 Compare October 20, 2026 06:02
@davidharrishmc

Copy link
Copy Markdown
Author

Added 9277c04: forcing EMUL = 1 for vlm.v/vsm.v made the EMUL range check compare it with a fractional LMUL, so vlm.v at e16 mf4/mf2 raised illegal instruction (stock main runs it correctly). The check is now skipped for vlm.v/vsm.v. With it those loads match Spike, the #511 reproducer still passes all 25 checks, and the other probes that pass on main still pass.

This branch has not been deployed

No deployments
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.

Legal instructions with single-register operands (mask destinations, mask operands, vlm/vsm, reduction scalars) raise illegal instruction

1 participant