Skip to content

Commit 058e02c

Browse files
committed
intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semantics
Add intrinsics `fmuladd{f16,f32,f64,f128}`. This computes `(a * b) + c`, to be fused if the code generator determines that (i) the target instruction set has support for a fused operation, and (ii) that the fused operation is more efficient than the equivalent, separate pair of `mul` and `add` instructions. https://llvm.org/docs/LangRef.html#llvm-fmuladd-intrinsic MIRI support is included for f32 and f64. The codegen_cranelift uses the `fma` function from libc, which is a correct implementation, but without the desired performance semantic. I think this requires an update to cranelift to expose a suitable instruction in its IR. I have not tested with codegen_gcc, but it should behave the same way (using `fma` from libc).
1 parent 2ca5753 commit 058e02c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/intrinsic/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ fn get_simple_intrinsic<'gcc, 'tcx>(
6666
sym::log2f64 => "log2",
6767
sym::fmaf32 => "fmaf",
6868
sym::fmaf64 => "fma",
69+
// FIXME: calling `fma` from libc without FMA target feature uses expensive sofware emulation
70+
sym::fmuladdf32 => "fmaf", // TODO: use gcc intrinsic analogous to llvm.fmuladd.f32
71+
sym::fmuladdf64 => "fma", // TODO: use gcc intrinsic analogous to llvm.fmuladd.f64
6972
sym::fabsf32 => "fabsf",
7073
sym::fabsf64 => "fabs",
7174
sym::minnumf32 => "fminf",

0 commit comments

Comments
 (0)