NFC: Migrate LoopFlatten to work on InstructionCost.

This patch migrates cost values and arithmetic to work on InstructionCost.
When the interfaces to TargetTransformInfo are changed, any InstructionCost
state will propagate naturally.

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

Reviewed By: david-arm

Differential Revision: https://reviews.llvm.org/D96029
This commit is contained in:
Sander de Smalen 2021-02-05 12:01:21 +00:00
parent 05c6c648ec
commit ae27274b2f
1 changed files with 3 additions and 2 deletions

View File

@ -280,7 +280,7 @@ checkOuterLoopInsts(struct FlattenInfo &FI,
// a significant amount of code here which can't be optimised out that it's
// not profitable (as these instructions would get executed for each
// iteration of the inner loop).
unsigned RepeatedInstrCost = 0;
InstructionCost RepeatedInstrCost = 0;
for (auto *B : FI.OuterLoop->getBlocks()) {
if (FI.InnerLoop->contains(B))
continue;
@ -310,7 +310,8 @@ checkOuterLoopInsts(struct FlattenInfo &FI,
if (match(&I, m_c_Mul(m_Specific(FI.OuterInductionPHI),
m_Specific(FI.InnerLimit))))
continue;
int Cost = TTI->getUserCost(&I, TargetTransformInfo::TCK_SizeAndLatency);
InstructionCost Cost =
TTI->getUserCost(&I, TargetTransformInfo::TCK_SizeAndLatency);
LLVM_DEBUG(dbgs() << "Cost " << Cost << ": "; I.dump());
RepeatedInstrCost += Cost;
}