fix vmulhu/vmulhsu/vwmulu.vx: truncate the .vx scalar operand to SEW - #90
Open
emiliengnr wants to merge 1 commit into
Open
fix vmulhu/vmulhsu/vwmulu.vx: truncate the .vx scalar operand to SEW#90emiliengnr wants to merge 1 commit into
emiliengnr wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello, here is a pull request for a bug I found.
vmulhu.vx, vmulhsu.vx and vwmulu.vx do not truncate the .vx scalar operand to SEW
before the multiply. In ElementwiseMultiplyPipe.scala the unsigned operands are
passed raw (rvs1_elem / rvs2_elem), whereas the signed path sign-extends them from
the element width. For a .vx op the "element" is the full XLEN scalar, so passing
it raw feeds the multiplier bits above SEW, and the op multiplies by
rs1[2*SEW-1:0] instead of rs1[SEW-1:0]. Plain vmul.vx hides it because the product
is truncated to SEW; vwmaccus.vx is affected too, since its scalar reaches the
second operand.
The fix uses zextElem (the helper added in #87) to zero-extend the unsigned
multiply operands, mirroring the existing sextElem on the signed path. For a .vv
element it is a no-op, so only the .vx scalar is truncated, and it covers both
operand lines (in_vs1 and in_vs2). This is the multiply-pipe counterpart of #87.
Found by differential testing against Spike; a reduced reproducer (vwmulu.vx at
SEW=8) diverges before the fix and matches Spike after it, and the unaffected ops
(vmulh.vx, vmul.vx, vwmaccsu.vx) are unchanged.