[llvm] 75b2555 - NFC: Migrate LoopUnrollPass to work on InstructionCost
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 4 06:06:09 PST 2021
Author: Sander de Smalen
Date: 2021-02-04T14:05:40Z
New Revision: 75b2555d6ef4b6f3dd53a49186793f03f9280c84
URL: https://github.com/llvm/llvm-project/commit/75b2555d6ef4b6f3dd53a49186793f03f9280c84
DIFF: https://github.com/llvm/llvm-project/commit/75b2555d6ef4b6f3dd53a49186793f03f9280c84.diff
LOG: NFC: Migrate LoopUnrollPass 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, fhahn
Differential Revision: https://reviews.llvm.org/D95817
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
index 1b974576a3cc..30e237a2f57f 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -361,14 +361,14 @@ static Optional<EstimatedUnrollCost> analyzeLoopUnrollCost(
// The estimated cost of the unrolled form of the loop. We try to estimate
// this by simplifying as much as we can while computing the estimate.
- unsigned UnrolledCost = 0;
+ InstructionCost UnrolledCost = 0;
// We also track the estimated dynamic (that is, actually executed) cost in
// the rolled form. This helps identify cases when the savings from unrolling
// aren't just exposing dead control flows, but actual reduced dynamic
// instructions due to the simplifications which we expect to occur after
// unrolling.
- unsigned RolledDynamicCost = 0;
+ InstructionCost RolledDynamicCost = 0;
// We track the simplification of each instruction in each iteration. We use
// this to recursively merge costs into the unrolled cost on-demand so that
@@ -639,10 +639,15 @@ static Optional<EstimatedUnrollCost> analyzeLoopUnrollCost(
}
}
+ assert(UnrolledCost.isValid() && RolledDynamicCost.isValid() &&
+ "All instructions must have a valid cost, whether the "
+ "loop is rolled or unrolled.");
+
LLVM_DEBUG(dbgs() << "Analysis finished:\n"
<< "UnrolledCost: " << UnrolledCost << ", "
<< "RolledDynamicCost: " << RolledDynamicCost << "\n");
- return {{UnrolledCost, RolledDynamicCost}};
+ return {{unsigned(*UnrolledCost.getValue()),
+ unsigned(*RolledDynamicCost.getValue())}};
}
/// ApproximateLoopSize - Approximate the size of the loop.
More information about the llvm-commits
mailing list