[PATCH] D124309: [SLP] Steer for the best chance in tryToVectorize() when rooting with binary ops.

Valeriy Dmitriev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 22 15:48:40 PDT 2022


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

tryToVectorize() method implements one of searching paths for vectorizable tree roots in SLP vectorizer,
specifically for binary and comparison operations. Order of making probes for various scalar pairs
was defined by its implementation: the instruction operands, then climb over one operand if
the instruction is its sole user and then perform same actions for another operand if previous
attempts failed. Problem with this approach is that among these options we can have more than a
single vectorizable tree candidate and it is not necessarily the one which encountered first.
Trying to build vectorizable tree for each possible combination for just evaluation is expensive.
But we already have lookahead heuristics mechanism which we use for finding best pick among
operands of commutative instructions. It calculates cumulative score for candidates in two
consecutive lanes. This patch introduces use of the heuristics for choosing the best pair among
several combinations. We only try one that looks as most promising for vectorization.
Additional benefit is that we reduce total number of vectorization trees built for probes
because we skip those looking non-profitable early.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124309

Files:
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/test/Transforms/SLPVectorizer/AArch64/invalid_type.ll
  llvm/test/Transforms/SLPVectorizer/X86/insert-element-build-vector-inseltpoison.ll
  llvm/test/Transforms/SLPVectorizer/X86/insert-element-build-vector.ll
  llvm/test/Transforms/SLPVectorizer/X86/vectorize-pair-path.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124309.424642.patch
Type: text/x-patch
Size: 34947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220422/d388e4b2/attachment.bin>


More information about the llvm-commits mailing list