[llvm] ae27274 - NFC: Migrate LoopFlatten to work on InstructionCost.

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 6 04:46:12 PST 2021


Author: Sander de Smalen
Date: 2021-02-06T11:47:04Z
New Revision: ae27274b2ffe47174290c07e8d8cd021c966d081

URL: https://github.com/llvm/llvm-project/commit/ae27274b2ffe47174290c07e8d8cd021c966d081
DIFF: https://github.com/llvm/llvm-project/commit/ae27274b2ffe47174290c07e8d8cd021c966d081.diff

LOG: 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

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/LoopFlatten.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
index aaff68436c13..604eb64a94e0 100644
--- a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
@@ -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;
     }


        


More information about the llvm-commits mailing list