[PATCH] D123911: [VectorCombine] Fold shuffle select pattern

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 17 05:54:13 PDT 2022


dmgreen created this revision.
dmgreen added reviewers: spatel, RKSimon, labrinea, SjoerdMeijer, samtebbs.
Herald added a subscriber: hiraditya.
Herald added a project: All.
dmgreen requested review of this revision.
Herald added a project: LLVM.

This patch adds a combine to attempt to reduce the costs of certain
select-shuffle patterns. The form of code it attempts to detect is:

  %x = shuffle ...
  %y = shuffle ...
  %a = binop %x, %y
  %b = binop %x, %y
  shuffle %a, %b, selectmask

A classic select-mask will pick items from each lane of a or b.  These
do not always have a great lowering on many architectures. This patch
attempt to pack a and b into the lower elements, creating a different
shuffle for reconstructing the orignal which may be better than the
select mask. This can be better for performance, especially if less
elements of a and b need to be computed and the input shuffles are
cheaper.

Because select-masks are just one form of shuffle, we generalize to any
mask. So long as the backend has decent costmodel for the shuffles, this
can generally improve things when they come up. For more basic cost
models, the folds do not appear to be profitable, not getting past the
cost checks.


https://reviews.llvm.org/D123911

Files:
  llvm/lib/Transforms/Vectorize/VectorCombine.cpp
  llvm/test/Transforms/VectorCombine/AArch64/select-shuffle.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123911.423291.patch
Type: text/x-patch
Size: 40861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220417/25ff6b64/attachment-0001.bin>


More information about the llvm-commits mailing list