[cfe-commits] [PATCH] Add llvm.fmuladd intrinsic.

Lang Hames lhames at gmail.com
Tue May 29 17:11:03 PDT 2012

Hi All,

I guess it's better to CC both lists, rather than have parallel feedback on
these patches - so for the Clang people who haven't seen this yet:

I want to improve Clang/LLVM's support for the fp_contract pragma.
(Background: when the fp_contract pragma is ON, multiplications and
additions within expressions can be fused to FMAs. This is a performance
win on targets that have a fast fma instruction.)

As a step towards implementing this functionality, these patches add a new
family of intrinsics, llvm.fmuladd.*, that represent mul+add expressions
that can be fused. Clang will emit calls to these intrinsics when it sees a
mul+add in a single source expression and fp_contract is ON. During LLVM
isel, the legalizer will check the Subtarget::isFMACheap() method to decide
whether to lower these intrinsics to llvm.fma.* intrinsic calls, or a
regular unfused mul and add expression.

The attached clang patch adds a per-function flag to FunctionDecl that
records the state of the fp_contract pragma when each function is defined,
and passes this information down to codegen. Clang codegen can then emit
calls to the new llvm.fmuladd intrinsic, instead of plain mul + add

Does anybody have any objections to the proposed scheme? If not I'll go
ahead and commit these.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120529/f6854d81/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm_fmuladd_intrinsic.patch
Type: application/octet-stream
Size: 6807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120529/f6854d81/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-fp-contract-fmuladd-codgen.patch
Type: application/octet-stream
Size: 6724 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120529/f6854d81/attachment-0001.obj>

More information about the cfe-commits mailing list