[PATCH] D125987: [SLP] Account for cost of removing FMA opportunities by horizontal reduction

Bill Schmidt via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 19 09:32:22 PDT 2022


wjschmidt created this revision.
wjschmidt added reviewers: vdmitrie, ABataev, fhahn, RKSimon, vporpo, spatel.
Herald added a subscriber: hiraditya.
Herald added a project: All.
wjschmidt requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When we generate a horizontal reduction of floating adds fed by a vectorized tree rooted at floating multiplies, account for the cost of no longer being able to generate scalar FMAs.

A subsequent patch will reuse getFMALossCost() from SLPVectorizerPass::tryToVectorizeList() to handle the remaining case.

This patch has one FIXME for something I don't know how to detect.  I'd like to be able to have an early exit if the target doesn't support FMA instructions at all.  If there isn't a good way to do that, the existing code is probably fine, relying on the cost model to say an FMA intrinsic is expensive on such a target.  (Real machines that have vector architectures almost certainly have FMAs, but best to be careful, I suppose.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125987

Files:
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/test/Transforms/SLPVectorizer/X86/slp-fma-loss.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125987.430714.patch
Type: text/x-patch
Size: 7033 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220519/5a3edeba/attachment.bin>


More information about the llvm-commits mailing list