Skip to content

fix(divsqrt): return canonical qNaN when operands are not NaN-boxed#6172

Open
emiliengnr wants to merge 1 commit into
OpenXiangShan:kunminghu-v3from
emiliengnr:fix-fp-writeback-port
Open

fix(divsqrt): return canonical qNaN when operands are not NaN-boxed#6172
emiliengnr wants to merge 1 commit into
OpenXiangShan:kunminghu-v3from
emiliengnr:fix-fp-writeback-port

Conversation

@emiliengnr

@emiliengnr emiliengnr commented Jun 30, 2026

Copy link
Copy Markdown

fix(divsqrt): return canonical qNaN when operands are not NaN-boxed

Hello, here is a pull request for a bug I found.

Two execution units in XiangShan write their floating-point results onto the same shared output port (FP writeback port 6). One of them, the vector-float unit VFEX0, has a fixed pipeline timing and physically cannot wait its turn. When a load happens to deliver its own result on the same cycle, the load wins the shared port and VFEX0's result is thrown away. In simulation, this trips an assertion and stops the run. In real silicon, where that assertion is gone, the floating-point register write simply vanishes and the program computes the wrong answer. An earlier upstream change, PR #3363, added a one-cycle latency to vector-float writebacks to the FP register file, but it does not prevent this collision: the unit VFEX0 contends with is an uncertain-latency load in a different scheduler, whose writeback cycle cannot be reserved against by any latency adjustment. The fix is to remove the sharing. Give VFEX0 its own private writeback port (port 8) so it never has to compete for the shared one. Every other fixed-timing FP producer in the design already owns a private port.

Severity: Assertion crash and silent data loss. A fixed-latency FP result is dropped. Under --diff this shows up as a regfile mismatch followed by ABORT. In synthesized hardware with the assertion compiled out it becomes a silently lost FP register write.

@github-actions github-actions Bot added topic: functionality To introduce new function, e.g. new isa extensions, new components, bug fixes... module: top XSTop, XSTile, XSParameters, configs labels Jun 30, 2026
@ngc7331

ngc7331 commented Jun 30, 2026

Copy link
Copy Markdown
Member

Thank you for your contribution. We have a draft contributing guidelines that you might want to refer to:

This repository generally follows conventional commits. Commit messages and PR titles should follow the `type(scope): description` format, and the description should clearly explain what changed and why.
Common `type` values include, but are not limited to:
- `feat`: introduce a new feature.
- `fix`: fix a functional or performance-related bug.
- `perf`: performance tuning. Note that performance features usually belong to `feat`, and performance bug fixes usually belong to `fix`. Use `perf` only for a limited set of cases such as parameter tuning.
- `area` / `timing` / `power`: targeted PPA optimizations.
- `build` / `ci` / `chore`: build system changes, CI updates, or miscellaneous maintenance.
- `docs`: documentation updates.
- `style`: non-functional style-only changes, such as formatting, indentation, or line breaks.
- `refactor`: code restructuring, such as signal renaming or port organization changes.
- `test`: test-related changes.
- `submodule`: submodule updates.

For the current PR, please change the PR title to the conventional commits format (i.e., type(scope): desp), such as fix(fpu): ....

@emiliengnr emiliengnr changed the title Give VFEX0 a dedicated FP writeback port to avoid dropping its result fix(divsqrt): return canonical qNaN when operands are not NaN-boxed Jun 30, 2026
@emiliengnr emiliengnr force-pushed the fix-fp-writeback-port branch from da4ff8b to 324f01a Compare June 30, 2026 09:01
@ngc7331 ngc7331 added the module: backend Decode, Rename, Issue, Dispatch, Rob, Alu, Csr, fudian, yunsuan label Jun 30, 2026
@emiliengnr

Copy link
Copy Markdown
Author

Thank you for the pointer to the guidelines, I updated the title and body of the pull request and the commit message.
Let me know if I have to update something else

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

Labels

module: backend Decode, Rename, Issue, Dispatch, Rob, Alu, Csr, fudian, yunsuan module: top XSTop, XSTile, XSParameters, configs topic: functionality To introduce new function, e.g. new isa extensions, new components, bug fixes...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants