This is an archive of the discontinued LLVM Phabricator instance.

[SLP]Improve vectorization of stores.
ClosedPublic

Authored by ABataev on Jun 11 2021, 8:07 AM.

Details

Summary

Patch tries to improve the vectorization of stores. Originally, we just
check the type and the base pointer of the store.
Patch adds some extra checks to avoid non-profitable vectorization
cases. It includes analysis of the scalar values to be stored and
triggers the vectorization attempt only if the scalar values have
same/alt opcode and are from same basic block, i.e. we don't end up
immediately with the gather node, which is not profitable.
This also improves compile time by filtering out non-profitable cases.

Part of D57059.

Diff Detail

Event Timeline

ABataev created this revision.Jun 11 2021, 8:07 AM
ABataev requested review of this revision.Jun 11 2021, 8:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 11 2021, 8:07 AM
RKSimon added inline comments.Jun 16 2021, 12:44 AM
llvm/test/Transforms/SLPVectorizer/X86/stores-non-ordered.ll
23

We've managed to increase the number of gathers - which can''t be good....

ABataev added inline comments.Jun 16 2021, 4:07 AM
llvm/test/Transforms/SLPVectorizer/X86/stores-non-ordered.ll
23

Not exactly. Before we had 2 masked gathers and 2 gathers of loads. Now we have 4 masked gathers instead, which still can be lowered to gathers if masked gather is not profitable.
Actually, need to improve the cost model for masked gathers and their emission, they do not work correctly in SLP.

ABataev updated this revision to Diff 355181.Jun 29 2021, 5:13 AM

Rebase + fixed non-determinism.

RKSimon added inline comments.Jul 5 2021, 9:14 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
8547

Avoid use of auto for non trivially determinable types.

ABataev updated this revision to Diff 356693.Jul 6 2021, 5:47 AM

Address comments

RKSimon accepted this revision.Jul 8 2021, 12:32 PM

LGTM - cheers

This revision is now accepted and ready to land.Jul 8 2021, 12:32 PM
This revision was landed with ongoing or failed builds.Jul 8 2021, 12:49 PM
This revision was automatically updated to reflect the committed changes.