[SLP] Make reordering aware of external vectorizable scalar stores.
authorVasileios Porpodas <vporpodas@google.com>
Thu, 5 May 2022 22:03:31 +0000 (15:03 -0700)
committerVasileios Porpodas <vporpodas@google.com>
Tue, 10 May 2022 22:25:35 +0000 (15:25 -0700)
commit71bcead98b2e655031208e5ad0ce89f8971a6343
tree5f6141d8d9986b6da11ff046191e3a0a9c5bd74d
parent7731935ffc96db2ceea9638d395439df814b5839
[SLP] Make reordering aware of external vectorizable scalar stores.

The current reordering scheme only checks the ordering of in-tree operands.
There are some cases, however, where we need to adjust the ordering based on
the ordering of a future SLP-tree who's instructions are not part of the
current tree, but are external users.

This patch is a simple implementation of this. We keep track of scalar stores
that are users of TreeEntries and if they look profitable to vectorize, then
we keep track of their ordering. During the reordering step we take this new
index order into account. This can remove some shuffles in cases like in the
lit test.

Differential Revision: https://reviews.llvm.org/D125111
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/reorder_with_external_users.ll