This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add cost model for scalable scatter and gather
ClosedPublic

Authored by reames on Jun 10 2022, 2:35 PM.

Details

Summary

The costing we use for fixed length vector gather and scatter is to simply count up the memory ops, and multiply by a fixed memory op cost. For scalable vectors, we don't actually know how many lanes are active. Instead, we have to end up making a worst case assumption on how many lanes could be active. In the generic +V case, this results in very high costs, but we can do better when we know an upper bound on the VLEN.

There's some obvious ways to improve this - e.g. using information about VL and mask bits from the instruction to reduce the upper bound - but this seems like a reasonable starting point.

The resulting costs do bias us pretty strongly away from generating scatter/gather for generic +V, but might be useful when targeting particular CPUs.

Diff Detail

Event Timeline

reames created this revision.Jun 10 2022, 2:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2022, 2:35 PM
reames requested review of this revision.Jun 10 2022, 2:35 PM
This revision is now accepted and ready to land.Jun 15 2022, 4:15 PM
frasercrmck accepted this revision.Jun 16 2022, 2:26 AM

LGTM too, with a nit

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
251

Unintentional blank line after return?

This revision was landed with ongoing or failed builds.Jun 16 2022, 2:22 PM
This revision was automatically updated to reflect the committed changes.