diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2021-08-22 19:00:43 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2021-11-13 20:39:49 +0000 |
commit | fe6060f10f634930ff71b7c50291ddc610da2475 (patch) | |
tree | 1483580c790bd4d27b6500a7542b5ee00534d3cc /contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopFuse.cpp | |
parent | b61bce17f346d79cecfd8f195a64b10f77be43b1 (diff) | |
parent | 344a3780b2e33f6ca763666c380202b18aab72a3 (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopFuse.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopFuse.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopFuse.cpp index b5f8dfa9aafb..ca19913e37ee 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopFuse.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopFuse.cpp @@ -99,6 +99,8 @@ STATISTIC(NonEmptyExitBlock, "Candidate has a non-empty exit block with " STATISTIC(NonEmptyGuardBlock, "Candidate has a non-empty guard block with " "instructions that cannot be moved"); STATISTIC(NotRotated, "Candidate is not rotated"); +STATISTIC(OnlySecondCandidateIsGuarded, + "The second candidate is guarded while the first one is not"); enum FusionDependenceAnalysisChoice { FUSION_DEPENDENCE_ANALYSIS_SCEV, @@ -370,11 +372,13 @@ private: bool reportInvalidCandidate(llvm::Statistic &Stat) const { using namespace ore; assert(L && Preheader && "Fusion candidate not initialized properly!"); +#if LLVM_ENABLE_STATS ++Stat; ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, Stat.getName(), L->getStartLoc(), Preheader) << "[" << Preheader->getParent()->getName() << "]: " << "Loop is not a candidate for fusion: " << Stat.getDesc()); +#endif return false; } }; @@ -891,6 +895,14 @@ private: continue; } + if (!FC0->GuardBranch && FC1->GuardBranch) { + LLVM_DEBUG(dbgs() << "The second candidate is guarded while the " + "first one is not. Not fusing.\n"); + reportLoopFusion<OptimizationRemarkMissed>( + *FC0, *FC1, OnlySecondCandidateIsGuarded); + continue; + } + // Ensure that FC0 and FC1 have identical guards. // If one (or both) are not guarded, this check is not necessary. if (FC0->GuardBranch && FC1->GuardBranch && @@ -1523,6 +1535,7 @@ private: assert(FC0.Preheader && FC1.Preheader && "Expecting valid fusion candidates"); using namespace ore; +#if LLVM_ENABLE_STATS ++Stat; ORE.emit(RemarkKind(DEBUG_TYPE, Stat.getName(), FC0.L->getStartLoc(), FC0.Preheader) @@ -1530,6 +1543,7 @@ private: << "]: " << NV("Cand1", StringRef(FC0.Preheader->getName())) << " and " << NV("Cand2", StringRef(FC1.Preheader->getName())) << ": " << Stat.getDesc()); +#endif } /// Fuse two guarded fusion candidates, creating a new fused loop. |