[PATCH] D53507: [InstCombine] try to turn shuffle into insertelement

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 22 09:15:03 PDT 2018


spatel created this revision.
spatel added reviewers: efriedma, lebedev.ri, craig.topper, RKSimon.
Herald added a subscriber: mcrosier.

shuffle (insert ?, Scalar, IndexC), V1, Mask --> insert V1, Scalar, IndexC'

The motivating case is at least a couple of steps away: I noticed that SLPVectorizer does not analyze shuffles as well as sequences of insert/extract in PR34724:
https://bugs.llvm.org/show_bug.cgi?id=34724
...so SLP may fail to vectorize when source code has shuffles to start with or instcombine has converted insert/extract to shuffles.

Independent of that, an insertelement is always a simpler op for IR analysis vs. a shuffle, so we should transform to insert when possible.

I don't think there's any codegen concern here - if a target can't insert a scalar directly to some fixed element in a vector (x86?), then this should get expanded to the insert+shuffle that we started with.


https://reviews.llvm.org/D53507

Files:
  lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  test/Transforms/InstCombine/insert-extract-shuffle.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53507.170437.patch
Type: text/x-patch
Size: 10801 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181022/8b65525f/attachment.bin>


More information about the llvm-commits mailing list