This is an archive of the discontinued LLVM Phabricator instance.

[TTI] NFC: Change getRegUsageForType to return InstructionCost.
ClosedPublic

Authored by dfukalov on May 14 2021, 4:45 PM.

Details

Summary

This patch migrates the TTI cost interfaces to return an InstructionCost.

See this patch for the introduction of the type: https://reviews.llvm.org/D91174
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2020-November/146408.html

Diff Detail

Event Timeline

dfukalov created this revision.May 14 2021, 4:45 PM
dfukalov requested review of this revision.May 14 2021, 4:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 14 2021, 4:45 PM

@sdesmalen this is needed to return from getTypeLegalizationCost() invalid costs, so at some point invalid legalization should be processed to a reg usage value, instead of asserting in Optional<>::getValue().
What do you think, should it be processed explicitly in LV or yet in BasicTTIImplBase<>::getRegUsageForType?
In latter case, what reg usage value should it return for invalid (e.g. scalable vectors) legalization cost?

sdesmalen accepted this revision.May 20 2021, 3:44 AM

LGTM, thanks!

@sdesmalen this is needed to return from getTypeLegalizationCost() invalid costs, so at some point invalid legalization should be processed to a reg usage value, instead of asserting in Optional<>::getValue().
What do you think, should it be processed explicitly in LV or yet in BasicTTIImplBase<>::getRegUsageForType?

IMHO the further up we can propagate the InstructionCost value the better, so I'm happy how you've done it in this patch. I guess we could still consider propagating it further to the uses of GetRegUsage, but right now I think it's safe to assume that the VFs coming into this function must be legal VFs for the target, and so if all element types are legal for scalable vectors (D102253), then any VectorType with an element count of VF should be legal, or at least possible to legalize. And therefore the InstructionCost should never be Invalid.

This revision is now accepted and ready to land.May 20 2021, 3:44 AM