Best way for JIT to query whether llvm.fma.* is fast?

For the Julia language JIT, we’d like be able to tell whether the llvm.fma.* intrinsic has hardware support. What’s the best way to query LLVM (JIT) for this information?

The information would be used in situations where the user wants to use different algorithms depending on whether FMA hardware is present or not.

  • Arch D. Robison

Does TargetLowering::isFMAFasterThanFMulAndFAdd ( help?


Thanks! That’s probably close enough for practical purposes. I looked at the overrides on various targets, and they all return true if the FMA hardware exists.

  • Arch

Hi Arch,

Also, consider just emitting the llvm.fmuladd intrinsic instead of llvm.fma. fmuladd is lowered to llvm.fma in codegen if the optimizer determines that it’s beneficial, otherwise it is expanded to a mul and an add.

At the moment I think SelectionDAG is just checking isFMAFasterThanFMulAndFAdd anyway, but that condition could be refined in the future.


Thanks for the tip. Indeed the current plan is to have Julia functions the correspond to both llvm.fmuladd and llvm.fma. Discussion is at .

  • Arch