riscv_fpu: don't size-optimize the FP op dispatch#234
Closed
SolAstrius wants to merge 1 commit into
Closed
Conversation
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
This was referenced Jun 19, 2026
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.
Summary
riscv_emulate_f_opc_op— the interpreter's OP-FP dispatch (fadd/fsub/fmul/fdiv/fsqrt + conversions) — is taggedfunc_opt_size, which compiles it for size (Oz/minsize) instead of the project default-O2. But the rvjit backend does not emit floating-point yet, so every guest FP instruction is handled here — this "slow path" is actually hot for any FP workload. Dropping the size attribute lets the compiler optimize it normally.Change
One line:
slow_path func_opt_size→slow_path. Theslow_path(cold/preserve_most) marking is kept.Benchmarks (aarch64 host, this dispatch only)
Pure FP-op throughput (tight loops, 40M iters, time-CSR ticks, lower = faster):
Realistic mixed FP (LINPACK 100×100 LU, double):
The realistic gain is modest (~3%): in mixed code the integer index/loop/memory ops are JIT-compiled and dominate, so only the FP-handler fraction shrinks. The 2× shows up only when FP-handler time dominates.
O3gives nothing beyondO2.Size
Function grows ~1.4 KB (
riscv_emulate_f_opc_op: 4648 → 6004 bytes); total__text+1.6 KB (+0.67%). On this arm64 build the on-disk binary rounds up by one 16 KB page; on 4 KB-page targets the on-disk delta is correspondingly smaller.Tradeoff is yours to weigh — modest real-world FP gain for ~1.6 KB of code. Benchmarks (
fp-bench,linpack) are bare-metal RVVM firmwares, available on request.