[libc-commits] [libc] [libc][stdfix] Implement mulifx functions (PR #235602)
Jaeyong Lee via libc-commits
libc-commits at lists.llvm.org
Tue Nov 3 21:20:52 PST 2026
================
@@ -404,6 +404,48 @@ divifx(IntType n, FXType d) {
return static_cast<IntType>(result);
}
+// Multiply an integer operand by a fixed-point operand and return the
+// mathematically exact result as an IntType rounded towards 0. Assumes
+// signedness of IntType matches the signedness of FXType.
+template <typename IntType, typename FXType>
+LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_fixed_point_v<FXType>, IntType>
+mulifx(IntType n, FXType m) {
----------------
npmania wrote:
I think your process is almost correct, but the only edge case is 32-bit `mulilr` and `muliulr` with `long` and `(unsigned) long fract`, where `2F = 62 or 64`, so I'll fall back to a 64-bit type for that specific case.
https://github.com/llvm/llvm-project/pull/235602
More information about the libc-commits
mailing list