diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopDistribute.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopDistribute.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp index 27d3004..1099aa3 100644 --- a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp +++ b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp @@ -113,6 +113,8 @@ static cl::opt<bool> EnableLoopDistribute( cl::desc("Enable the new, experimental LoopDistribution Pass"), cl::init(false)); +static const char *DistributedMetaData = "llvm.loop.isdistributed"; + STATISTIC(NumLoopsDistributed, "Number of loops distributed"); namespace { @@ -826,6 +828,8 @@ public: {LLVMLoopDistributeFollowupAll, LLVMLoopDistributeFollowupFallback}, "llvm.loop.distribute.", true); LVer.getNonVersionedLoop()->setLoopID(UnversionedLoopID); + addStringMetadataToLoop(LVer.getNonVersionedLoop(), DistributedMetaData, + true); } // Create identical copies of the original loop for each partition and hook @@ -986,6 +990,13 @@ static bool runImpl(Function &F, LoopInfo *LI, DominatorTree *DT, for (Loop *L : Worklist) { LoopDistributeForLoop LDL(L, &F, LI, DT, SE, LAIs, ORE); + // Do not reprocess loops we already distributed + if (getOptionalBoolLoopAttribute(L, DistributedMetaData).value_or(false)) { + LLVM_DEBUG( + dbgs() << "LDist: Distributed loop guarded for reprocessing\n"); + continue; + } + // If distribution was forced for the specific loop to be // enabled/disabled, follow that. Otherwise use the global flag. if (LDL.isForced().value_or(EnableLoopDistribute)) |