[PATCH] D62024: [InstCombine] fold shuffles of insert_subvectors

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 12:05:02 PDT 2019


spatel created this revision.
spatel added reviewers: lebedev.ri, RKSimon, efriedma.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: LLVM.

This should be a valid exception to the general rule of not creating new shuffle masks in IR...because we already do it. :)
Also AFAICT, DAG combining/legalization can undo this by widening the shuffle back out if needed.

Explanation for how we already do this: SLP or vector source can create chains of insert/extract as shown in 1 of the examples from PR16739:
https://godbolt.org/z/NlK7rA
https://bugs.llvm.org/show_bug.cgi?id=16739

And we expect instcombine or DAGCombine to clean that up by creating relatively simple shuffles. But instcombine has a strange way of dealing with this and which can fail with multiple uses - grep for:

  // TODO: Looking at the user(s) to determine if this insert is a
  // fold-to-shuffle opportunity does not match the usual instcombine
  // constraints.

So this patch is proposing to reduce that restriction by matching a sub-pattern of shuffles. We would have folded that anyway if they had appeared in an alternate form (as a sequence of insert/extract).


https://reviews.llvm.org/D62024

Files:
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/test/Transforms/InstCombine/vec_shuffle.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62024.199872.patch
Type: text/x-patch
Size: 5692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190516/be33101e/attachment.bin>


More information about the llvm-commits mailing list