This is an archive of the discontinued LLVM Phabricator instance.

[SLP] Do not ignore ordering for root node when it has in-tree uses.
ClosedPublic

Authored by vdmitrie on Jan 9 2023, 11:06 AM.

Details

Summary

When rooted with PHIs, a vectorization tree may have another node with PHIs
which have roots as their operands. We cannot ignore ordering information
for root in such a case.

Diff Detail

Event Timeline

vdmitrie created this revision.Jan 9 2023, 11:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2023, 11:06 AM
vdmitrie requested review of this revision.Jan 9 2023, 11:06 AM
ABataev added inline comments.Jan 9 2023, 11:31 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
4395–4398
IgnoreReorder &= VectorizableTree.front()->UserTreeIndices.empty();

Can we do it before calling reorderBottomToTop?

llvm/test/Transforms/SLPVectorizer/X86/reorder-phi-operand.ll
87

Precommit the test, please.

vdmitrie added inline comments.Jan 9 2023, 11:43 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
4395–4398

This was the very first thing I was considering. But call to the method is from outside of BoUpSLP. It means we either need to allow access to VectorizaableTree data or add a public method that checks just that.

llvm/test/Transforms/SLPVectorizer/X86/reorder-phi-operand.ll
87

It fails with assertion without the fix. It represents a stability issue.

ABataev added inline comments.Jan 9 2023, 11:50 AM
llvm/test/Transforms/SLPVectorizer/X86/reorder-phi-operand.ll
87

Ah, I see

vdmitrie added inline comments.Jan 9 2023, 11:53 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
4395–4398

I can add this method and use it instead:

bool isRootHasInTreeUses() const {

return !VectorizableTree.empty() &&
       !VectorizableTree.front()->UserTreeIndices.empty();

}

Thoughts?

ABataev added inline comments.Jan 9 2023, 12:02 PM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
4395–4398

Go ahead with it.

vdmitrie updated this revision to Diff 487554.Jan 9 2023, 2:22 PM

address comment

ABataev added inline comments.Jan 9 2023, 5:03 PM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
1041

doesRootHave....

vdmitrie updated this revision to Diff 487608.Jan 9 2023, 5:10 PM

rename method as per suggestion

This revision is now accepted and ready to land.Jan 10 2023, 1:55 AM
This revision was landed with ongoing or failed builds.Jan 10 2023, 10:13 AM
This revision was automatically updated to reflect the committed changes.