[llvm-commits] [PATCH] Add llvm.fmuladd intrinsic.
Stephen Canon
scanon at apple.com
Tue May 29 17:10:16 PDT 2012
On May 29, 2012, at 8:03 PM, Lang Hames <lhames at gmail.com> wrote:
> Hi All,
>
> 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, this patch adds a new family of intrinsics, llvm.fmuladd.*, that represent mul+add expressions that can be fused. The frontend will emit calls to these intrinsics when it sees a mul+add in a single source expression and fp_contract is ON (I'll mail a patch for this functionality to cfe-commits in a minute). During 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.
>
> I haven't taught the optimizers to reason about these expressions yet - that's coming next. For now I just wanted to see if anyone had any objections to the proposed scheme. If not I'll go ahead and commit.
No objections to the scheme, but this comment:
+ /// isFMACheapAndLegal - Return true if an FMA operation is legal and cheap,
+ /// false if an FMA is illegal or expensive. fmuladd intrinsics will be
+ /// expanded to FMAs when FMAs are cheap, otherwise they are expanded.
does not seem to be in sync with the code, which discusses isFMACheap( ).
More information about the llvm-commits
mailing list