[PATCH] D123494: [VectorCombine] Find and remove shuffles from commutative reductions

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 11 03:53:42 PDT 2022


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

Given a shuffle feeding a reduction, the lane ordering of the shuffle will not alter the result. This is also true if there are a number of operations between the reduction and the shuffle, providing they only operate lane-wise. This patch searches for cases like that in Vector Combine, allowing us to check the cost of the shuffle vs an in-order identity shuffle and replace the order of possible. This only handles a single shuffle at the moment to keep things simple, and is able to ignore splats that produce results where every result is the same.

This is a more powerful version of a combine that already happens in instrcombine, capable of optimizing more cases by looking through more instructions and being able to cost the shuffle.


https://reviews.llvm.org/D123494

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123494.421859.patch
Type: text/x-patch
Size: 19503 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220411/c953b7be/attachment.bin>


More information about the llvm-commits mailing list