[LLVMdev] Clarifying FMA-related TargetOptions

Owen Anderson resistor at mac.com
Wed Feb 8 10:11:06 PST 2012


Hello everyone,

I'd like to propose the attached patch to form FMA intrinsics aggressively, but in order to do so I need some clarification on the intended semantics for the various FP precision-related TargetOptions.  I've summarized the three relevant ones below:

UnsafeFPMath - Defaults to off, enables "less precise" results than permitted by IEEE754.  Comments specifically reference using hardware FSIN/FCOS on X86.

NoExcessFPPrecision - Defaults to off (i.e. excess precision allowed), enables higher-precision implementations than specified by IEEE754.  Comments reference FMA-like operations, and X87 without rounding all over the place.

LessPreciseFPMADOption - Defaults to off, enables "less precise" FP multiply-add.

My general sense is that aggressive FMA formation is beyond the realm of what UnsafeFPMath allows, but I'm unclear on the relationship between NoExcessFPPrecision and LessPreciseFPMADOption.  My understanding is that fused multiply-add operations are "more precise" (i.e. closer to the numerically true value) than the baseline (which would round between the multiply and the add).  By that reasoning, it seems like it should be covered by !NoExcessFPPrecision.  However, that opens the question of what LessPreciseFPMADOption is intended to cover.  Are there targets on which FMA is actually "less precise" than the baseline sequence?  Or is the comment just poorly worded?

A related concern is that, while NoExcessFPPrecision seems applicable, it is the only one of the above that defaults to the more-relaxed option.  From testing my patch, I can say that it does change the behavior of a number of benchmarks in the LLVM test suite, and for that reason alone seems like it should not be enabled by default.

Anyone more knowledgable about FP than me have any ideas?

--Owen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120208/ee14b009/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fma.diff
Type: application/octet-stream
Size: 724 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120208/ee14b009/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120208/ee14b009/attachment-0001.html>


More information about the llvm-dev mailing list