← Back to Pull requests

RVV: Fix ReorderWidenMulAccumulate for fractional LMUL #3382

Closed
unknown closed this pull request without merging on Sep 15, 2026 09:10 UTC
View on GitHub
unknown unknown commented on Sep 13, 2026 16:27 UTC
Author

Fixes #3305
Addresses #3281

Summary
Fix ReorderWidenMulAccumulate on RVV for fractional LMUL.

For real e32,mf2, the native vector type is also used to represent virtual e32,mf4. The previous implementation could leave state required by RearrangeToOddPlusEven in inactive tail lanes. After a Store/Load round trip, those tail lanes are no longer guaranteed to retain the required values, which can change the result.

This change keeps all persistent state required by RearrangeToOddPlusEven in active lanes.

For the real e32,mf2 case, the widening products are first computed in natural order:
[P0 | P1 | P2 | P3]
They are then stored using the block-transposed representation:
sum0 = [P0 | P2]
sum1 = [P1 | P3]
The implementation uses native vwmul.vv / vwmulu.vv followed by vcompress to construct the two accumulators.

This also avoids the slide-based rearrangement considered for this path and addresses the RVV performance concern in #3281.

Testing
Real RVV hardware

Tested on an X60 RISC-V system:
widen_mul_test: 12/12 tests passed

Both signed and unsigned paths were checked in the generated assembly:
int16_t -> int32_t: vwmul.vv + vcompress.vm
uint16_t -> uint32_t: vwmulu.vv + vcompress.vm

Multiple VLENs

TestAllReorderWidenMulAccumulate/RVV passes under QEMU with:
VLEN=128 PASS
VLEN=256 PASS
VLEN=512 PASS
VLEN=1024 PASS

A separate BF16 failure in TestAllRearrangeToOddPlusEven/RVV at VLEN=1024 is also reproducible on unmodified upstream/master and is unrelated to this change.

Performance

Microbenchmarks were run on the X60 with the benchmark pinned to a single CPU. The operands were changed on every iteration to prevent loop-invariant hoisting.

Average over 10 runs:

Type | upstream | this change
uint16_t -> uint32_t | 9.413 ns/iter | 9.413 ns/iter
int16_t -> int32_t | 9.415 ns/iter | 9.416 ns/iter

Diff: 241 lines (+180 / -61) across 3 files Reviewer: jan-wassenberg Review duration: 2442m
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 241 lines diff across 3 files
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.328
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3382"
general weight: 0.35
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 38.8% (MEDIUM) · Higher = larger blast radius
38.8%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15.3% · Safe to merge
15.3%
Repository