llvm / llvm/llvm-project

[Support][SLP] Support for fractional InstructionCost

Open
#174,429 2 comments 0 reactions 1 assignee Claimed by @bababuck View on GitHub
enhancement llvm:analysis llvm:SLPVectorizer
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

When requesting cost information from `TargetTransformInfo` in the vectorizers, particular SLP, we request reciprocal throughput (`TCK_RecipThroughput`). However, `InstructionCost` only supports integer cost amounts, which doesn't align with reciprocal throughput on high performance machines which have a reciprocal throughput of less than 1 for many scalar instructions. As a result, we end up estimating the reciprocal throughput as 1, but this leads to large inaccuracies for large vector instructions. For instance, even if the reciprocal throughput for an add instruction should be `1/4`, we estimate the cost as `1`. So the scalar cost for a 16 element vector is estimated as `1 x 16 = 16`, even though it should be `1/4 x 16 = 4`.

To address this, a couple options could be to:
- Update `InstructionCost` to support fractional values (I threw together a quick implementation of this that I can push if interested.)
- Update `InstructionCost` to be backed by a floating point type
- Update `TargetTransformInfo` cost functions to accept a vector of scalars

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.