Hi All,<div><br></div><div>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:<div><br><div class="gmail_quote"><div>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.)</div>



<div><br></div><div>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.</div>

<div><br></div><div><div>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 instructions.</div>
</div><div><br></div><div>Does anybody have any objections to the proposed scheme? If not I'll go ahead and commit these.</div><div><br></div><div>Cheers,</div><div>Lang.</div>
</div><br></div></div>