[PATCH] D82499: [DAGCombiner] tighten constraints for fma fold

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 24 13:34:45 PDT 2020


spatel created this revision.
spatel added reviewers: bryanpkc, efriedma, rscottmanley, lebedev.ri, RKSimon, PowerPC.
Herald added subscribers: ecnelises, hiraditya, mcrosier.
Herald added a reviewer: jdoerfert.
Herald added a project: LLVM.

fadd (fma A, B, (fmul C, D)), E --> fma A, B, (fma C, D, E)

This is only allowed when "reassoc" is present on the fadd.

As discussed in D80801 <https://reviews.llvm.org/D80801>, this transform goes beyond what is allowed by "contract" FMF (-ffp-contract=fast). That is because we are fusing the trailing add of 'E' with a multiply, but without "reassoc", the code mandates that the products A*B and C*D are added together before adding in 'E'.

I've added this example to the LangRef to try to clarify the meaning of "contract". If that seems reasonable, we should probably do something similar for the clang docs because there does not appear to be any formal spec for the behavior of -ffp-contract=fast.


https://reviews.llvm.org/D82499

Files:
  llvm/docs/LangRef.rst
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/AArch64/fadd-combines.ll
  llvm/test/CodeGen/X86/fma_patterns.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82499.273142.patch
Type: text/x-patch
Size: 5032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200624/0d44fc22/attachment.bin>


More information about the llvm-commits mailing list