Hi, Dear All: I'm going implement FMA formation. On some architectures, "FMA a, b, c" is more precise than "a * b + c". I'm wondering if FMA could be less precise. In the former case, can we enable FMA formation despite restrictive FP mode? Thanks Shuxin
On Wed, Dec 12, 2012 at 3:40 PM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:> Hi, Dear All: > > I'm going implement FMA formation. On some architectures, "FMA a, b, c" > is more precise than > "a * b + c".If it isn't more accurate, it isn't an FMA, at least not in the commonly used sense. (ARM has an instruction which does a multiply and add which isn't more precise, but it would just be confusing to refer to that as an FMA.)> In the former > case, can we enable FMA > formation despite restrictive FP mode?No. There have already been very long discussions about fma; try searching the llvmdev archives. -Eli
On Dec 12, 2012, at 3:40 PM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:> Hi, Dear All: > > I'm going implement FMA formation. On some architectures, "FMA a, b, c" is more precise than > "a * b + c". I'm wondering if FMA could be less precise. In the former case, can we enable FMA > formation despite restrictive FP mode? >I believe that a pass to form fmuladd[1] intrinsic calls would be very useful! The fmuladd intrinsic is defined such that its formation should be isolated from worries about strictness. It simply means "a * b + c" and leaves the decision of whether or not to fuse up to the code generator. Of course, one probably would only run your pass if they wanted the code generator to fuse it, but the pass itself should be valid. Someone please correct me if I misunderstand this intrinsic. [1] http://llvm.org/docs/LangRef.html#llvm-fmuladd-intrinsic> Thanks > Shuxin > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121212/c2f17cbe/attachment.html>
A little background: The fmuladd intrinsic was introduced to support the FP_CONTRACT pragma in C. llvm.fmuladd.* is generated by clang when it sees an expression of the form 'a * b + c' within a single source statement. If you want to opportunistically form FMA target instructions my inclination would be to skip llvm.fmuladd.* and just form them from a*b+c expressions at isel time. I don't see any fundamental problem with forming llvm.fmuladd.* to model FMA formation opportunities in an IR pass though. - Lang. On Wed, Dec 12, 2012 at 4:11 PM, Michael Ilseman <milseman at apple.com> wrote:> > On Dec 12, 2012, at 3:40 PM, Shuxin Yang <shuxin.llvm at gmail.com> wrote: > > Hi, Dear All: > > I'm going implement FMA formation. On some architectures, "FMA a, b, c" > is more precise than > "a * b + c". I'm wondering if FMA could be less precise. In the former > case, can we enable FMA > formation despite restrictive FP mode? > > > I believe that a pass to form fmuladd[1] intrinsic calls would be very > useful! The fmuladd intrinsic is defined such that its formation should be > isolated from worries about strictness. It simply means "a * b + c" and > leaves the decision of whether or not to fuse up to the code generator. Of > course, one probably would only run your pass if they wanted the code > generator to fuse it, but the pass itself should be valid. > > Someone please correct me if I misunderstand this intrinsic. > > [1] http://llvm.org/docs/LangRef.html#llvm-fmuladd-intrinsic > > Thanks > Shuxin > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121212/8857172a/attachment.html>