This is an archive of the discontinued LLVM Phabricator instance.

[NFC][TTI] Add TargetCostKind argument to getUserCost
ClosedPublic

Authored by samparker on Apr 22 2020, 6:30 AM.

Details

Summary

There are several different types of cost that TTI tries to provide explicit information for: throughput, latency, code size along with a vague 'intersection of code-size cost and execution cost'.
The vectorizer is a keen user of RecipThroughput and there's at least 'getInstructionThroughput' and 'getArithmeticInstrCost' designed to help with this cost. The latency cost has a single use and a single implementation. The intersection cost appears to cover most of the rest of the API.
getUserCost is explicitly called from within TTI when the user has been explicit in wanting the code size (also only one use) as well as a few passes which are concerned with a mixture of size and/or a relative cost. In many cases these costs are closely related, such as when multiple instructions are required, but one evident diverging cost in this function is for div/rem.
This patch adds an argument so that the cost required is explicit, so that we can make the important distinction when necessary.
Next, I'd like to combine getUserCost and getInstructionCost.

Diff Detail

Event Timeline

samparker created this revision.Apr 22 2020, 6:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2020, 6:30 AM
mtrofin added inline comments.Apr 22 2020, 8:35 AM
llvm/include/llvm/Analysis/TargetTransformInfo.h
157

Would 'workingset' accurately describe what the 'hybrid' is used for, so a weighed sum of code and latency? I'm having trouble wrapping my mind around the old 'intersection' notion (what would intersecting 2 costs mean?), and 'hybrid', at a first glance, leads me to believe it's about combining all other 3.

samparker marked an inline comment as done.Apr 23 2020, 1:54 AM
samparker added inline comments.
llvm/include/llvm/Analysis/TargetTransformInfo.h
157

I also don't know what it means, I just quoted it from below :) and I agree that Hybrid is not descriptive. I would probably prefer to be as explicit as possible with something like SizeAndLatencyWeight.

mtrofin added inline comments.Apr 23 2020, 8:39 AM
llvm/include/llvm/Analysis/TargetTransformInfo.h
157

I think TCK_SizeAndLatency, with a descriptive comment, would probably communicate it clearly enough (and keep it reasonably concise)

samparker updated this revision to Diff 260234.Apr 27 2020, 1:04 AM
  • Updated the name of the enum
  • Used TTI shorthand in the backends.
mtrofin accepted this revision.Apr 27 2020, 8:11 AM

lgtm

This revision is now accepted and ready to land.Apr 27 2020, 8:11 AM
This revision was automatically updated to reflect the committed changes.