[SLP]Find reused scalars in buildvector sequences, if any.
authorAlexey Bataev <a.bataev@outlook.com>
Mon, 20 Mar 2023 14:26:33 +0000 (07:26 -0700)
committerAlexey Bataev <a.bataev@outlook.com>
Wed, 5 Apr 2023 16:37:05 +0000 (09:37 -0700)
commit40105a993399699fe351789c7eb2a0e6d36f440a
tree47ef4c22a6ae9c7104e23a5ff76ae98fe092d104
parentc416f6700f513d86226482f47ad956ceb4e7c927
[SLP]Find reused scalars in buildvector sequences, if any.

Patch generalizes analysis of scalars. The main part is outlined into
lambda, which can be used to find reused inserted scalars and emit
shuffle for them instead of multiple insertelement instructions, if the
permutation is found alreadyi. I.e. some scalars are transformed by the
permutation of previously vectorized nodes, and some are inserted
directly.

Reworked part of D110978

Differential Revision: https://reviews.llvm.org/D146564
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/jumbled-load-multiuse.ll
llvm/test/Transforms/SLPVectorizer/X86/matched-shuffled-entries.ll