[PATCH] D31164: [IR] Add AllowContract to FastMathFlags

Steve Canon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 21 09:42:04 PDT 2017


scanon added inline comments.


================
Comment at: docs/LangRef.rst:2199
+   Allow floating-point contraction (e.g. fusing a multiply followed by an
+   addition into a fused multiply-and-add).
+
----------------
anemet wrote:
> mehdi_amini wrote:
> > anemet wrote:
> > > mehdi_amini wrote:
> > > > Is it the intent to allow this as well :  x + x + x ->  3 * x  ?
> > > I don't think so.  We do the general case (any number of terms) under unsafe-math, in FAddCombine::simplify in InstCombine.
> > I know we do this under unsafe-fp-math, I was wondering specifically about how fat the "contract" mode allows to go.
> Ah ok, sorry, I misunderstood.  The C standard frames FP_CONTRACT as a permission to omit rounding errors while contracting, so potentially this may be included too.
Fun fact, x + x + x -> 3*x is always legal (both expressions only have a single rounding). x + x + x + x -> 4*x requires the assumption of default rounding, however.


https://reviews.llvm.org/D31164





More information about the llvm-commits mailing list