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

Evan Cheng evan.cheng at apple.com
Tue May 29 18:34:19 PDT 2012


On May 29, 2012, at 5:10 PM, Stephen Canon wrote:

> 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( ).

Right, the comment should not talk about "legal". The code in SelectionDAGBuilder.cpp should check TLI.isOperationLegal(ISD::FMA, ty) in addition to isFMACheap(). We don't want to combine two checks in one.

Evan

> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list