This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][Cost] Add VectorToScalarBaseCost for extractelement
Needs ReviewPublic

Authored by arcbbb on Jun 7 2023, 9:00 AM.

Details

Summary

This patch proposes an alternative approach to D152001 to prevent
unprofitable decisions made by the vectorizer for small VF.
Some CPU implementations have high cost when performing vector-to-scalar communication,
For example, consider the given reduction operation with VF=4:

vle32.v v0, (a5)
vmv.s.x v8, a0
vfredusum.vs v8, v0, v8
vfmv.f.s fa0, v8

Despite that vle32.v and vfredsum.vs instructions have higher throughput than scalar does,
the profitability is hindered when the vector-to-scalar communication cost is excessively
high.
To address this, the patch introduces an interface within the subtarget,
enabling individual CPUs to differentiate the associated costs.
This approach mirrors VectorInsertExtractBaseCost used in AArch64 .

Diff Detail

Event Timeline

arcbbb created this revision.Jun 7 2023, 9:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2023, 9:00 AM
arcbbb requested review of this revision.Jun 7 2023, 9:00 AM
arcbbb updated this revision to Diff 529329.Jun 7 2023, 9:01 AM
  • clang-formatted