[llvm-dev] Combining fast math flags with constrained intrinsics
Ulrich Weigand via llvm-dev
llvm-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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev