[PATCH] D80801: [DAGCombiner] allow more folding of fadd + fmul into fma

Scott Manley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 29 14:46:55 PDT 2020


rscottmanley added a comment.

> Given the constraints in SDAG, we should choose the (fma(fma)) variant by default (assuming as we do here that the target has fma instructions). For example on x86, our best perf heuristic at this stage of compilation on any recent Intel or AMD core is number of uops. The option with separate fmul and fadd always has more uops, so it would be backwards to choose that sequence here and then try to undo that later.

I agree SDAG is not ideal -- I explored doing this earlier in opt and also later using MIs, but both places have their own problems. It's a surprisingly cumbersome optimization if you are concerned about multiple targets which have different sets of FMA "flavours".

> If this is the wrong choice for some other target, they can can still opt out, so I think this is a safe option. Alternatively, we could make the enableAggressiveFMAFusion() hook more nuanced by changing the bool return to a enum'd level of aggression, and then deciding which of the current transforms under here require a higher level of fma perf.

Yes, that would be a nice feature to explore at some point.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80801/new/

https://reviews.llvm.org/D80801





More information about the llvm-commits mailing list