Skip to content

rvjit: compute mulhsu sign correction before clobbering rs1 - #270

Merged
LekKit merged 1 commit into
LekKit:stagingfrom
carlosqwqqwq:fix/rvjit-mulhsu-aliasing
Aug 12, 2026
Merged

rvjit: compute mulhsu sign correction before clobbering rs1#270
LekKit merged 1 commit into
LekKit:stagingfrom
carlosqwqqwq:fix/rvjit-mulhsu-aliasing

Conversation

@carlosqwqqwq

Copy link
Copy Markdown

rvjit: compute mulhsu sign correction before clobbering rs1

Fixes #265

Commit message

rvjit: compute mulhsu sign correction before clobbering rs1

Description

The x86 JIT computes the unsigned high product before the sign-correction term. When rd == rs1, that product overwrites the source still needed by the correction. Compute the correction first, then emit the high product and add it back. This is separate from the division overflow guard.

Validation

  • Native RV64 hardware and QEMU provide the reference result.
  • JIT and interpreter controls isolate the aliasing case.
  • The proposed change is limited to src/rvjit/rvjit_x86.h::rvjit_x86_mulhsu().
  • Fixed and negative controls were verified against the references.

@LekKit
LekKit merged commit 0f13252 into LekKit:staging Aug 12, 2026
15 checks passed
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.

x86 JIT mulhsu reads a clobbered rs1 when rd == rs1

2 participants