[cfe-dev] Combining fast math flags with constrained intrinsics

Ulrich Weigand via cfe-dev cfe-dev at lists.llvm.org
Mon Jan 20 10:22:49 PST 2020


Serge Pavlov <sepavloff at gmail.com> wrote on 20.01.2020 09:12:55:

> One of the viewpoints on the constrained intrinsics is that it is a
> way to represent floating point environment. In this case they are
> just variants of corresponding IR nodes and in theory we could use
> the constrained intrinsics everywhere instead of the regular nodes.
> From this viewpoint it make sense to keep symmetry between
> constrained intrinsics and corresponding regular IR nodes.

Agreed with this.

> So for the first question the variant `a` (generate a constrained
> version of the llvm.fmuladd instrinsic) looks preferable.

But not with this.  Note that in Andrew's example we are operating
under -ffp-contract=fast, in which case clang never emits fmuladd,
so it shouldn't in the constrained case either.  Instead, it will
emit fmul/fadd nodes with the contract FMF set, so in constrained
mode it should emit constrained fmul/fadd with the contract FMF set.
(This was Andrew's variant (b).)

fmuladd is only emitted in the -ffp-contract=on case, which is
intended to allow contractions only within a single source statement.
Since the LLVM back-end no longer knows the boundaries of source
statemtents, this requires help from clang; this is why clang will
emit fmuladd in those cases where the mul and add originate from
within the same source statement.

To fully map all these cases onto constrained intrinsics, we need
both to allow contract (and other) FMFs on constrained intrinsics
*and* allow a constrained fmuladd.

Bye,
Ulrich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200120/6fc01c5f/attachment.html>


More information about the cfe-dev mailing list