Page MenuHomePhabricator

[TTI] NFC: Change getIntImmCost[Inst|Intrin] to return InstructionCost

Authored by sdesmalen on Apr 15 2021, 7:22 AM.



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

See this patch for the introduction of the type:
See this thread for context:

Diff Detail

Event Timeline

sdesmalen created this revision.Apr 15 2021, 7:22 AM
sdesmalen requested review of this revision.Apr 15 2021, 7:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2021, 7:22 AM
c-rhodes added inline comments.Apr 15 2021, 8:21 AM

Does there need to be a check the cost is valid before calling getValue?

Assuming @c-rhodes is satisfied, this change looks good to me.


Code that handles the invalid case would be a functional change. This follows the philosophy of "the code previously assumed all costs are valid, so we will assume it's valid now and handle the crashes in future functional changes patches if we see them"

sdesmalen marked 2 inline comments as done.Wed, Apr 21, 7:13 AM
sdesmalen added inline comments.

@c-rhodes seems I wrote this comment but forgot to publish it. The assert in the dereference would fail if the cost is Invalid. We can assume the cost of an instruction in a basic-block is valid, because otherwise it would suggest the instruction cannot be code-generated. This would mean that either the cost-model is broken (it gives an invalid cost for something that _can_ be code-generated), or it means that the IR contains instructions that shouldn't have been created in the first place. As Chris says, changing the code to solve such an issue means making a functional change, and we can just work on the assumption that the cost was valid before this change.

c-rhodes accepted this revision.Wed, Apr 21, 7:22 AM
c-rhodes added inline comments.

@ctetreau @sdesmalen thanks for clarifying

This revision is now accepted and ready to land.Wed, Apr 21, 7:22 AM
This revision was automatically updated to reflect the committed changes.
sdesmalen marked an inline comment as done.