Page MenuHomePhabricator

[SLP]Improve vectorization of gathered loads.
Needs ReviewPublic

Authored by ABataev on Jul 14 2021, 7:41 AM.

Details

Summary

When building the vectorization graph, the compiler may end up with the
consecutive loads in the different branches, which end up to be
gathered. We can scan these loads and try to load them as final
vectorized load and then reshuffle between the branches to avoid extra
scalar loads in the code.

Part of D57059

Diff Detail

Unit TestsFailed

TimeTest
90 msx64 debian > LLVM.Transforms/PhaseOrdering/X86::vector-reductions.ll
Script: -- : 'RUN: at line 2'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/opt -O2 -S -mattr=avx < /var/lib/buildkite-agent/builds/llvm-project/llvm/test/Transforms/PhaseOrdering/X86/vector-reductions.ll | /var/lib/buildkite-agent/builds/llvm-project/build/bin/FileCheck /var/lib/buildkite-agent/builds/llvm-project/llvm/test/Transforms/PhaseOrdering/X86/vector-reductions.ll
100 msx64 windows > LLVM.Transforms/PhaseOrdering/X86::vector-reductions.ll
Script: -- : 'RUN: at line 2'; c:\ws\w7\llvm-project\premerge-checks\build\bin\opt.exe -O2 -S -mattr=avx < C:\ws\w7\llvm-project\premerge-checks\llvm\test\Transforms\PhaseOrdering\X86\vector-reductions.ll | c:\ws\w7\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w7\llvm-project\premerge-checks\llvm\test\Transforms\PhaseOrdering\X86\vector-reductions.ll

Event Timeline

ABataev created this revision.Jul 14 2021, 7:41 AM
ABataev requested review of this revision.Jul 14 2021, 7:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2021, 7:41 AM
RKSimon edited the summary of this revision. (Show Details)Jul 14 2021, 7:47 AM

Any idea why so many of these test changes are just undef<->poison changes?

Any idea why so many of these test changes are just undef<->poison changes?

Changes in the vectorizations of gathers. I'm going to prepare a separate patch and fix it there.

A few minors

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
3308

Add comment explaining this logic

3326

Can you clean this up? The clang-formating has made it difficult to follow.

3893

Could we end up in a situation where we end up truncating here and causing overflow problems later on?

5894

By using .back() can't we safely use this for the Entries.size() == 1 case as well?

ABataev added inline comments.Jul 30 2021, 2:35 PM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
3893

This is what we already have when we're trying to build the vector for the GEPs. Here we end up with the IntPtr type.

5894

I had trouble with it for an unknown reason, will check it once again.

ABataev added inline comments.Jul 30 2021, 2:40 PM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
5894

Ahh, If I use .back() here, the compiler might emit something like this:

%vec = shuffle %v1, %v1, <0,1,2,undef>

I.e. the second argument is not replaced by the PoisonValue vector.

ABataev updated this revision to Diff 363210.Jul 30 2021, 2:57 PM

Rebase, fixes and improvements.