[PATCH] D126273: [DAGCombiner][VP] Add DAGCombine for merging VP_FADD and VP_FMUL to VP_FMA.
Simon Moll via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 24 06:47:12 PDT 2022
simoll added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:23061
+ return false;
+ return AllowFusionGlobally || N->getFlags().hasAllowContract();
+ };
----------------
simoll wrote:
> RKSimon wrote:
> > It'd be very useful if we pulled stuff like this out and shared it between all the various FMA generating combines.
> Yes. It is possible to lift the existing DAGCombiner Patterns to work on VP SDNodes as well as on regular SDNodes.
> I've implemented this in the LLVM stack for SX-Aurora under the LLVM license, ie it could be upstreamed:
>
> https://github.com/sx-aurora-dev/llvm-project/blob/feature/generalized_pattern_rewriting/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L13859
>
> You could rephrase this patch using the generalized pattern-rewriting technique. I'd happy to help with that!
>
> The same applies to https://reviews.llvm.org/D121187
Some more info on the generalized pattern-matching thing:
The [visitFADDForFMACombine function](https://github.com/sx-aurora-dev/llvm-project/blob/feature/generalized_pattern_rewriting/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L13859) is templatized. The template parameter abstracts away the actual matching and SDNode creation. The flow of the code is the same (SDNode matching and creation is re-directed through the matcher class, that's all).
The templated function is instantiated twice, once with the [EmptyMatchContext for regular SDNodes](https://github.com/sx-aurora-dev/llvm-project/blob/feature/generalized_pattern_rewriting/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L824) and once with the [VPMatchContext for VP-SDNodes](https://github.com/sx-aurora-dev/llvm-project/blob/feature/generalized_pattern_rewriting/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L877).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126273/new/
https://reviews.llvm.org/D126273
More information about the llvm-commits
mailing list