This is an archive of the discontinued LLVM Phabricator instance.

[SLP]Adjust GEP indices types when trying to build entries.
ClosedPublic

Authored by ABataev on Nov 12 2021, 12:18 PM.

Details

Summary

Need to adjust the types of GEPs indices when building the tree
entries/operands. Otherwise some of the nodes might differ and
vectorizer is unable to correctly find them and count their cost.

Diff Detail

Event Timeline

ABataev created this revision.Nov 12 2021, 12:18 PM
ABataev requested review of this revision.Nov 12 2021, 12:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 12 2021, 12:18 PM
RKSimon added inline comments.Nov 14 2021, 8:53 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
3876
SmallVector<ValueList> Operands(1, ValueList());

Add test showing different costs?

Add test showing different costs?

There is no cost difference, just the tests are crashing.

There is no cost difference, just the tests are crashing.

Ok, I see, so add such test to this commit?

There is no cost difference, just the tests are crashing.

Ok, I see, so add such test to this commit?

We already have these tests. Just before we did this adjustment during vector code emission but instead we should do it when building the tree entry. I have some other patches that depend on this one.

ABataev updated this revision to Diff 387238.Nov 15 2021, 6:35 AM

Rebase + address comments

RKSimon added inline comments.Nov 15 2021, 9:16 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
6315–6316

auto *GEP0 = cast<GetElementPtrInst>(VL0);

6318

for (int J = 1, N = GEP0->getNumOperands(); J < N; ++J) {

6322

Value *V = Builder.CreateGEP(GEP0->getSourceElementType(), Op0, OpVecs);

ABataev updated this revision to Diff 387296.Nov 15 2021, 9:25 AM

Address comments.

vporpo added inline comments.Nov 15 2021, 11:43 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
3881

Update comment explaining why this is done here instead of VectorizeTree() ?

ABataev updated this revision to Diff 387373.Nov 15 2021, 1:03 PM

Address comments

vporpo accepted this revision.Nov 15 2021, 1:30 PM

LGTM

This revision is now accepted and ready to land.Nov 15 2021, 1:30 PM
This revision was landed with ongoing or failed builds.Nov 16 2021, 5:46 AM
This revision was automatically updated to reflect the committed changes.

Hi, I can't build with this commit (see inline comment).

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

This is failing to build for me because IndexIdx isn't captured here.

ABataev added inline comments.Nov 16 2021, 7:54 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
3891
Orlando added inline comments.Nov 16 2021, 8:00 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
3891

Aha thanks, sorry for the noise.