WEDNESDAY, NOVEMBER 25, 2026
include Performance Win
RISC-V longlong.h uses mulhu for umul_ppmm.
RISC-V longlong.h now uses mulhu for umul_ppmm, improving performance.
The RISC-V implementation of umul_ppmm in longlong.h has been updated to leverage the mulhu instruction when the M extension is available. This change optimizes the double-word multiplication, reducing instruction count and improving performance for floating-point operations like __multf3.
In Details
In include/longlong.h, the RISC-V umul_ppmm macro, previously relying on four half-word multiplies, now utilizes the mulhu and mul instructions when the __riscv_mul (M extension) is enabled. This optimization is applied when UDWtype is not defined, falling back to the generic C implementation otherwise. The change optimizes __multf3 significantly on both RV64 and RV32.
For Context
- umul_ppmm
- A macro in
longlong.hthat computes the product of two double-word integers. The implementation can vary depending on target architecture features. - mulhu
- A RISC-V instruction that performs an unsigned multiply, returning the high double-word of the product.
- M extension
- A standard extension for the RISC-V instruction set architecture that adds integer multiplication and division instructions.
- RV64
- The 64-bit version of the RISC-V architecture.
- RV32
- The 32-bit version of the RISC-V architecture.