[llvm] 5c77aa2 - [unroll] Use early return in shouldFullUnroll [nfc]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 23 09:01:44 PST 2021
Author: Philip Reames
Date: 2021-11-23T09:01:36-08:00
New Revision: 5c77aa2b917c5b21b3f9c6d355ca2f9a0a81b95d
URL: https://github.com/llvm/llvm-project/commit/5c77aa2b917c5b21b3f9c6d355ca2f9a0a81b95d
DIFF: https://github.com/llvm/llvm-project/commit/5c77aa2b917c5b21b3f9c6d355ca2f9a0a81b95d.diff
LOG: [unroll] Use early return in shouldFullUnroll [nfc]
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 67702520511b8..0b8b47fc932b4 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -807,27 +807,25 @@ static Optional<unsigned> shouldFullUnroll(
const unsigned FullUnrollTripCount, const UnrollCostEstimator UCE,
const TargetTransformInfo::UnrollingPreferences &UP) {
- if (FullUnrollTripCount && FullUnrollTripCount <= UP.FullUnrollMaxCount) {
- // When computing the unrolled size, note that BEInsns are not replicated
- // like the rest of the loop body.
- if (UCE.getUnrolledLoopSize(UP) < UP.Threshold) {
- return FullUnrollTripCount;
+ if (!FullUnrollTripCount || FullUnrollTripCount >= UP.FullUnrollMaxCount)
+ return None;
- } else {
- // The loop isn't that small, but we still can fully unroll it if that
- // helps to remove a significant number of instructions.
- // To check that, run additional analysis on the loop.
- if (Optional<EstimatedUnrollCost> Cost = analyzeLoopUnrollCost(
- L, FullUnrollTripCount, DT, SE, EphValues, TTI,
- UP.Threshold * UP.MaxPercentThresholdBoost / 100,
- UP.MaxIterationsCountToAnalyze)) {
- unsigned Boost =
- getFullUnrollBoostingFactor(*Cost, UP.MaxPercentThresholdBoost);
- if (Cost->UnrolledCost < UP.Threshold * Boost / 100) {
- return FullUnrollTripCount;
- }
- }
- }
+ // When computing the unrolled size, note that BEInsns are not replicated
+ // like the rest of the loop body.
+ if (UCE.getUnrolledLoopSize(UP) < UP.Threshold)
+ return FullUnrollTripCount;
+
+ // The loop isn't that small, but we still can fully unroll it if that
+ // helps to remove a significant number of instructions.
+ // To check that, run additional analysis on the loop.
+ if (Optional<EstimatedUnrollCost> Cost = analyzeLoopUnrollCost(
+ L, FullUnrollTripCount, DT, SE, EphValues, TTI,
+ UP.Threshold * UP.MaxPercentThresholdBoost / 100,
+ UP.MaxIterationsCountToAnalyze)) {
+ unsigned Boost =
+ getFullUnrollBoostingFactor(*Cost, UP.MaxPercentThresholdBoost);
+ if (Cost->UnrolledCost < UP.Threshold * Boost / 100)
+ return FullUnrollTripCount;
}
return None;
}
More information about the llvm-commits
mailing list