[PATCH] Refactor and enhance FMA combine
hfinkel at anl.gov
hfinkel at anl.gov
Mon Mar 23 14:14:51 PDT 2015
================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:7060
@@ +7059,3 @@
+ // fold (fadd (fpext (fma x, y, (fmul u, v))), z)
+ // -> (fma (fpext x), (fpext y), (fma (fpext u), (fpext v), z))
+ if (N0.getOpcode() == ISD::FP_EXTEND) {
----------------
joker.eph wrote:
> hfinkel wrote:
> > ohsallen wrote:
> > > joker.eph wrote:
> > > > This turns two "low precision" and one "high precision" operations into two "high precision" operation.
> > > > I'm not saying it is necessarily bad, but I'm not convinced it is always beneficial.
> > > > The other FMA combines don't have the same behavior.
> > > In principle you're right, that might not be *always* beneficial. But in general, it should be, because even when "high precision" operations are twice more expensive than "low precision" one, the transformation does not worsen things. Right now this is only enabled for PPC, for which low and high precision operations have the same cost. Tell me if this is not acceptable.
> > I agree, I think this is okay as-is. However, please note this explicitly in a comment above the transform.
> >
> Well you can imagine having more than twice the throughput in f16 than f32 on some targets, and you can also imagine that 2 x f16 operations consume less power than one f32.
> I'd rather have Owen's opinion on this.
Sure, but I also don't want to have an unnecessary proliferation target hooks. It is reasonable to believe that this will be generally beneficial, and if we someday have a target that wishes to enable enableAggressiveFMAFusion but does not want this specific type of transformation, then we can add a new hook at that time.
FWIW, this is not just a throughput issue, but also a format-conversion issue (when we have vectors of float vs. vectors of double, the fpext implies register reorganization, and minimizing the number of such reorganizations is likely, I think, to be beneficial).
http://reviews.llvm.org/D8050
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list