Skip to content

Sanitize non-NaN-boxed operands in divsqrt to return canonical qNaN#27

Open
emiliengnr wants to merge 1 commit into
pulp-platform:developfrom
emiliengnr:fix-divsqrt-nanboxing
Open

Sanitize non-NaN-boxed operands in divsqrt to return canonical qNaN#27
emiliengnr wants to merge 1 commit into
pulp-platform:developfrom
emiliengnr:fix-divsqrt-nanboxing

Conversation

@emiliengnr

@emiliengnr emiliengnr commented Jun 30, 2026

Copy link
Copy Markdown

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

fpnew_divsqrt_multi declares the is_boxed_i input but never uses it, so a scalar fdiv.s or fsqrt.s whose source operand is not properly NaN-boxed is computed on the raw low 32 bits and returns an arithmetically wrong result with no trap, where the RISC-V D extension requires the canonical quiet NaN of the destination format. The fix substitutes the canonical qNaN for a badly boxed operand before the divsqrt pipeline, and skips the unused second operand on fsqrt.s so the square-root path stays correct. Found by differential testing of a cva6 + ara configuration against spike.

Severity: Architectural correctness. Every fdiv.s / fsqrt.s whose source FP register is not properly NaN-boxed returns a silently wrong result.

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.

1 participant