This is an archive of the discontinued LLVM Phabricator instance.

[SLP]Fix the cost for the extractelements, used in several nodes.
ClosedPublic

Authored by ABataev on Apr 20 2023, 7:49 AM.

Details

Summary

Currently the compiler calculates the compensation cost for the
extractelements, removed during vectorization. But if the extractelement
instruction is used in several nodes, we can calculate the compensation
for them several times.

Diff Detail

Event Timeline

ABataev created this revision.Apr 20 2023, 7:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2023, 7:49 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
ABataev requested review of this revision.Apr 20 2023, 7:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2023, 7:49 AM
RKSimon added inline comments.Apr 20 2023, 8:15 AM
llvm/test/Transforms/SLPVectorizer/X86/blending-shuffle-inseltpoison.ll
12 ↗(On Diff #515335)

This doesn't look faster imo

ABataev added inline comments.Apr 20 2023, 8:39 AM
llvm/test/Transforms/SLPVectorizer/X86/blending-shuffle-inseltpoison.ll
12 ↗(On Diff #515335)

It will be fixed after D148801, I hope. Let me commit it and see if it is so

ABataev added inline comments.Apr 20 2023, 10:18 AM
llvm/test/Transforms/SLPVectorizer/X86/blending-shuffle-inseltpoison.ll
12 ↗(On Diff #515335)

TTI reports that the cost of vector mul is 4, when the scalar cost is 2 (1x2).
llvm-mca reports different numbers - 8 for scalar muls and 1 for vector mul.
https://godbolt.org/z/azqaMKabr

RKSimon added inline comments.Apr 20 2023, 10:51 AM
llvm/test/Transforms/SLPVectorizer/X86/blending-shuffle-inseltpoison.ll
12 ↗(On Diff #515335)

Thanks for catching that - I'll get it updated

Thanks for looking into this @ABataev .

RKSimon accepted this revision.Apr 21 2023, 8:09 AM

LGTM

This revision is now accepted and ready to land.Apr 21 2023, 8:09 AM