This is an archive of the discontinued LLVM Phabricator instance.

[SLP] Correct shuffle cost to reuse vectorized values in depending nodes
AbandonedPublic

Authored by dtemirbulatov on Oct 21 2022, 10:02 AM.

Details

Summary

While estimating a node cost of the tree which has dependency on another node we might too optimistic estimate code of shuffle operation by assuming that it is depending on a single tree node with TargetTransformInfo::SK_Select.

For example such node dependence ended up with this snippet:

%9 = fsub fast <2 x float> %8, %3
%10 = fadd fast <2 x float> %8, %3
%11 = shufflevector <2 x float> %9, <2 x float> %10, <2 x i32> <i32 0, i32 3>

Which ended up in suboptimal result in the end.

Diff Detail

Event Timeline

dtemirbulatov created this revision.Oct 21 2022, 10:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 10:02 AM
dtemirbulatov requested review of this revision.Oct 21 2022, 10:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 10:02 AM
ABataev added inline comments.Oct 21 2022, 10:08 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
6799–6811

Can you try to reuse buildShuffleEntryMask instead?

dtemirbulatov abandoned this revision.Oct 31 2022, 2:52 AM

The testcase that is associated with the change is not relevant, but I think the proposed change is improving cost calculation. I going to reopen this once I have appropriate testcase.