This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Convert shuffle with single constant vector element to insertelement.
AbandonedPublic

Authored by ABataev on Sep 9 2016, 3:03 AM.

Details

Summary

If it is known that LHS or RHS of shufflevector instruction is a ConstantVector and only single element from this constant is used in the result, this shufflevector is transformed into an insertelement instruction:
shufflevector V, C, <v1, v2, .., ci, .., vm> -> insertelement V, C[ci],ci-n

Diff Detail

Event Timeline

ABataev updated this revision to Diff 70795.Sep 9 2016, 3:03 AM
ABataev retitled this revision from to [InstCombine] Convert shuffle with single constant vector element to insertelement..
ABataev updated this object.
ABataev added reviewers: spatel, RKSimon.
ABataev added subscribers: simon.f.whittaker, avt77.
ABataev added a subscriber: llvm-commits.
ABataev updated this revision to Diff 71368.Sep 14 2016, 8:40 AM

Fixes an issue with shuffling the elements from the other input. In this case we should retain the shuffle.

RKSimon edited edge metadata.Sep 16 2016, 9:07 AM

This looks OK to me (especially in context to D24182). Anybody else have any comments?

spatel added inline comments.Sep 16 2016, 9:37 AM
test/Transforms/InstCombine/insert-const-shuf.ll
16–29

As-is, this patch will cause a regression here (ie, the chain of inserts does not collapse). But D24182 will fix this? If it's not possible to separate these two patches without causing a regression, then they should be merged together. I'm not able to apply D24182 cleanly after applying this patch, so it may be that something is just not updated?

ABataev added inline comments.Sep 19 2016, 8:21 AM
test/Transforms/InstCombine/insert-const-shuf.ll
16–29

Yes, D24182 is not updated yet. Yes, it is not possible to separate these 2 patches without this kind of regression. Do you really want to join these 2 patches into one?

ABataev abandoned this revision.Sep 20 2016, 12:31 AM