This is an archive of the discontinued LLVM Phabricator instance.

[SLP]Introduce gather cost estimation function.
ClosedPublic

Authored by ABataev on Apr 12 2023, 2:36 PM.

Details

Summary

Introduced BoUpSLP::ShuffleCostEstimator::gather function as an initial
implementation of the gather/buildvector cost estimation for buildvector
nodes. It will allow to use general codegen infrastructure for better
cost estimation + it improves the cost estimation for the
gathers/buildvectors.

Improved part of D110978.

Diff Detail

Event Timeline

ABataev created this revision.Apr 12 2023, 2:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 2:36 PM
ABataev requested review of this revision.Apr 12 2023, 2:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 2:36 PM
RKSimon added inline comments.Apr 13 2023, 5:17 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
6897

Don't we guarantee !allConstant(VL) in the TCC_Free check at the top?

ABataev updated this revision to Diff 513221.Apr 13 2023, 7:03 AM

Remove extra call for allConstant, changed if to assert.

RKSimon accepted this revision.Apr 13 2023, 7:31 AM

LGTM

This revision is now accepted and ready to land.Apr 13 2023, 7:31 AM
This revision was automatically updated to reflect the committed changes.
dmgreen added inline comments.
llvm/test/Transforms/SLPVectorizer/AArch64/extractelements-to-shuffle.ll
6
ABataev added inline comments.Apr 14 2023, 6:56 AM
llvm/test/Transforms/SLPVectorizer/AArch64/extractelements-to-shuffle.ll
6

Looks like the issue with buildvector cost estimation, will fix it.

6

I mean getGatherCost function.

ABataev added inline comments.Apr 14 2023, 10:36 AM
llvm/test/Transforms/SLPVectorizer/AArch64/extractelements-to-shuffle.ll
6

There is another one problem. When estimating the cost of the insertelement instruction, the TTI for AArch64 return 0, because it tries to insert to 0 position and HasRealUse is false

Just a heads up, we are seeing some performance regressions related to this. A reproducer can be found here: https://reviews.llvm.org/D148732