1 //===- LoopVersioningLICM.cpp - LICM Loop Versioning ----------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // When alias analysis is uncertain about the aliasing between any two accesses,
10 // it will return MayAlias. This uncertainty from alias analysis restricts LICM
11 // from proceeding further. In cases where alias analysis is uncertain we might
12 // use loop versioning as an alternative.
13 //
14 // Loop Versioning will create a version of the loop with aggressive aliasing
15 // assumptions in addition to the original with conservative (default) aliasing
16 // assumptions. The version of the loop making aggressive aliasing assumptions
17 // will have all the memory accesses marked as no-alias. These two versions of
18 // loop will be preceded by a memory runtime check. This runtime check consists
19 // of bound checks for all unique memory accessed in loop, and it ensures the
20 // lack of memory aliasing. The result of the runtime check determines which of
21 // the loop versions is executed: If the runtime check detects any memory
22 // aliasing, then the original loop is executed. Otherwise, the version with
23 // aggressive aliasing assumptions is used.
24 //
25 // Following are the top level steps:
26 //
27 // a) Perform LoopVersioningLICM's feasibility check.
28 // b) If loop is a candidate for versioning then create a memory bound check,
29 //    by considering all the memory accesses in loop body.
30 // c) Clone original loop and set all memory accesses as no-alias in new loop.
31 // d) Set original loop & versioned loop as a branch target of the runtime check
32 //    result.
33 //
34 // It transforms loop as shown below:
35 //
36 //                         +----------------+
37 //                         |Runtime Memcheck|
38 //                         +----------------+
39 //                                 |
40 //              +----------+----------------+----------+
41 //              |                                      |
42 //    +---------+----------+               +-----------+----------+
43 //    |Orig Loop Preheader |               |Cloned Loop Preheader |
44 //    +--------------------+               +----------------------+
45 //              |                                      |
46 //    +--------------------+               +----------------------+
47 //    |Orig Loop Body      |               |Cloned Loop Body      |
48 //    +--------------------+               +----------------------+
49 //              |                                      |
50 //    +--------------------+               +----------------------+
51 //    |Orig Loop Exit Block|               |Cloned Loop Exit Block|
52 //    +--------------------+               +-----------+----------+
53 //              |                                      |
54 //              +----------+--------------+-----------+
55 //                                 |
56 //                           +-----+----+
57 //                           |Join Block|
58 //                           +----------+
59 //
60 //===----------------------------------------------------------------------===//
61 
62 #include "llvm/Transforms/Scalar/LoopVersioningLICM.h"
63 #include "llvm/ADT/SmallVector.h"
64 #include "llvm/ADT/StringRef.h"
65 #include "llvm/Analysis/AliasAnalysis.h"
66 #include "llvm/Analysis/AliasSetTracker.h"
67 #include "llvm/Analysis/GlobalsModRef.h"
68 #include "llvm/Analysis/LoopAccessAnalysis.h"
69 #include "llvm/Analysis/LoopInfo.h"
70 #include "llvm/Analysis/LoopPass.h"
71 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
72 #include "llvm/Analysis/ScalarEvolution.h"
73 #include "llvm/IR/Dominators.h"
74 #include "llvm/IR/Instruction.h"
75 #include "llvm/IR/Instructions.h"
76 #include "llvm/IR/LLVMContext.h"
77 #include "llvm/IR/MDBuilder.h"
78 #include "llvm/IR/Metadata.h"
79 #include "llvm/IR/Value.h"
80 #include "llvm/Support/Casting.h"
81 #include "llvm/Support/CommandLine.h"
82 #include "llvm/Support/Debug.h"
83 #include "llvm/Support/raw_ostream.h"
84 #include "llvm/Transforms/Utils.h"
85 #include "llvm/Transforms/Utils/LoopUtils.h"
86 #include "llvm/Transforms/Utils/LoopVersioning.h"
87 #include <cassert>
88 #include <memory>
89 
90 using namespace llvm;
91 
92 #define DEBUG_TYPE "loop-versioning-licm"
93 
94 static const char *LICMVersioningMetaData = "llvm.loop.licm_versioning.disable";
95 
96 /// Threshold minimum allowed percentage for possible
97 /// invariant instructions in a loop.
98 static cl::opt<float>
99     LVInvarThreshold("licm-versioning-invariant-threshold",
100                      cl::desc("LoopVersioningLICM's minimum allowed percentage"
101                               "of possible invariant instructions per loop"),
102                      cl::init(25), cl::Hidden);
103 
104 /// Threshold for maximum allowed loop nest/depth
105 static cl::opt<unsigned> LVLoopDepthThreshold(
106     "licm-versioning-max-depth-threshold",
107     cl::desc(
108         "LoopVersioningLICM's threshold for maximum allowed loop nest/depth"),
109     cl::init(2), cl::Hidden);
110 
111 namespace {
112 
113 struct LoopVersioningLICM {
114   // We don't explicitly pass in LoopAccessInfo to the constructor since the
115   // loop versioning might return early due to instructions that are not safe
116   // for versioning. By passing the proxy instead the construction of
117   // LoopAccessInfo will take place only when it's necessary.
118   LoopVersioningLICM(AliasAnalysis *AA, ScalarEvolution *SE,
119                      OptimizationRemarkEmitter *ORE,
120                      LoopAccessInfoManager &LAIs, LoopInfo &LI,
121                      Loop *CurLoop)
122       : AA(AA), SE(SE), LAIs(LAIs), LI(LI), CurLoop(CurLoop),
123         LoopDepthThreshold(LVLoopDepthThreshold),
124         InvariantThreshold(LVInvarThreshold), ORE(ORE) {}
125 
126   bool run(DominatorTree *DT);
127 
128 private:
129   // Current AliasAnalysis information
130   AliasAnalysis *AA;
131 
132   // Current ScalarEvolution
133   ScalarEvolution *SE;
134 
135   // Current Loop's LoopAccessInfo
136   const LoopAccessInfo *LAI = nullptr;
137 
138   // Proxy for retrieving LoopAccessInfo.
139   LoopAccessInfoManager &LAIs;
140 
141   LoopInfo &LI;
142 
143   // The current loop we are working on.
144   Loop *CurLoop;
145 
146   // Maximum loop nest threshold
147   unsigned LoopDepthThreshold;
148 
149   // Minimum invariant threshold
150   float InvariantThreshold;
151 
152   // Counter to track num of load & store
153   unsigned LoadAndStoreCounter = 0;
154 
155   // Counter to track num of invariant
156   unsigned InvariantCounter = 0;
157 
158   // Read only loop marker.
159   bool IsReadOnlyLoop = true;
160 
161   // OptimizationRemarkEmitter
162   OptimizationRemarkEmitter *ORE;
163 
164   bool isLegalForVersioning();
165   bool legalLoopStructure();
166   bool legalLoopInstructions();
167   bool legalLoopMemoryAccesses();
168   bool isLoopAlreadyVisited();
169   void setNoAliasToLoop(Loop *VerLoop);
170   bool instructionSafeForVersioning(Instruction *I);
171 };
172 
173 } // end anonymous namespace
174 
175 /// Check loop structure and confirms it's good for LoopVersioningLICM.
176 bool LoopVersioningLICM::legalLoopStructure() {
177   // Loop must be in loop simplify form.
178   if (!CurLoop->isLoopSimplifyForm()) {
179     LLVM_DEBUG(dbgs() << "    loop is not in loop-simplify form.\n");
180     return false;
181   }
182   // Loop should be innermost loop, if not return false.
183   if (!CurLoop->getSubLoops().empty()) {
184     LLVM_DEBUG(dbgs() << "    loop is not innermost\n");
185     return false;
186   }
187   // Loop should have a single backedge, if not return false.
188   if (CurLoop->getNumBackEdges() != 1) {
189     LLVM_DEBUG(dbgs() << "    loop has multiple backedges\n");
190     return false;
191   }
192   // Loop must have a single exiting block, if not return false.
193   if (!CurLoop->getExitingBlock()) {
194     LLVM_DEBUG(dbgs() << "    loop has multiple exiting block\n");
195     return false;
196   }
197   // We only handle bottom-tested loop, i.e. loop in which the condition is
198   // checked at the end of each iteration. With that we can assume that all
199   // instructions in the loop are executed the same number of times.
200   if (CurLoop->getExitingBlock() != CurLoop->getLoopLatch()) {
201     LLVM_DEBUG(dbgs() << "    loop is not bottom tested\n");
202     return false;
203   }
204   // Parallel loops must not have aliasing loop-invariant memory accesses.
205   // Hence we don't need to version anything in this case.
206   if (CurLoop->isAnnotatedParallel()) {
207     LLVM_DEBUG(dbgs() << "    Parallel loop is not worth versioning\n");
208     return false;
209   }
210   // Loop depth more then LoopDepthThreshold are not allowed
211   if (CurLoop->getLoopDepth() > LoopDepthThreshold) {
212     LLVM_DEBUG(dbgs() << "    loop depth is more then threshold\n");
213     return false;
214   }
215   // We need to be able to compute the loop trip count in order
216   // to generate the bound checks.
217   const SCEV *ExitCount = SE->getBackedgeTakenCount(CurLoop);
218   if (isa<SCEVCouldNotCompute>(ExitCount)) {
219     LLVM_DEBUG(dbgs() << "    loop does not has trip count\n");
220     return false;
221   }
222   return true;
223 }
224 
225 /// Check memory accesses in loop and confirms it's good for
226 /// LoopVersioningLICM.
227 bool LoopVersioningLICM::legalLoopMemoryAccesses() {
228   // Loop over the body of this loop, construct AST.
229   BatchAAResults BAA(*AA);
230   AliasSetTracker AST(BAA);
231   for (auto *Block : CurLoop->getBlocks()) {
232     // Ignore blocks in subloops.
233     if (LI.getLoopFor(Block) == CurLoop)
234       AST.add(*Block);
235   }
236 
237   // Memory check:
238   // Transform phase will generate a versioned loop and also a runtime check to
239   // ensure the pointers are independent and they don’t alias.
240   // In version variant of loop, alias meta data asserts that all access are
241   // mutually independent.
242   //
243   // Pointers aliasing in alias domain are avoided because with multiple
244   // aliasing domains we may not be able to hoist potential loop invariant
245   // access out of the loop.
246   //
247   // Iterate over alias tracker sets, and confirm AliasSets doesn't have any
248   // must alias set.
249   bool HasMayAlias = false;
250   bool TypeSafety = false;
251   bool HasMod = false;
252   for (const auto &I : AST) {
253     const AliasSet &AS = I;
254     // Skip Forward Alias Sets, as this should be ignored as part of
255     // the AliasSetTracker object.
256     if (AS.isForwardingAliasSet())
257       continue;
258     // With MustAlias its not worth adding runtime bound check.
259     if (AS.isMustAlias())
260       return false;
261     Value *SomePtr = AS.begin()->getValue();
262     bool TypeCheck = true;
263     // Check for Mod & MayAlias
264     HasMayAlias |= AS.isMayAlias();
265     HasMod |= AS.isMod();
266     for (const auto &A : AS) {
267       Value *Ptr = A.getValue();
268       // Alias tracker should have pointers of same data type.
269       TypeCheck = (TypeCheck && (SomePtr->getType() == Ptr->getType()));
270     }
271     // At least one alias tracker should have pointers of same data type.
272     TypeSafety |= TypeCheck;
273   }
274   // Ensure types should be of same type.
275   if (!TypeSafety) {
276     LLVM_DEBUG(dbgs() << "    Alias tracker type safety failed!\n");
277     return false;
278   }
279   // Ensure loop body shouldn't be read only.
280   if (!HasMod) {
281     LLVM_DEBUG(dbgs() << "    No memory modified in loop body\n");
282     return false;
283   }
284   // Make sure alias set has may alias case.
285   // If there no alias memory ambiguity, return false.
286   if (!HasMayAlias) {
287     LLVM_DEBUG(dbgs() << "    No ambiguity in memory access.\n");
288     return false;
289   }
290   return true;
291 }
292 
293 /// Check loop instructions safe for Loop versioning.
294 /// It returns true if it's safe else returns false.
295 /// Consider following:
296 /// 1) Check all load store in loop body are non atomic & non volatile.
297 /// 2) Check function call safety, by ensuring its not accessing memory.
298 /// 3) Loop body shouldn't have any may throw instruction.
299 /// 4) Loop body shouldn't have any convergent or noduplicate instructions.
300 bool LoopVersioningLICM::instructionSafeForVersioning(Instruction *I) {
301   assert(I != nullptr && "Null instruction found!");
302   // Check function call safety
303   if (auto *Call = dyn_cast<CallBase>(I)) {
304     if (Call->isConvergent() || Call->cannotDuplicate()) {
305       LLVM_DEBUG(dbgs() << "    Convergent call site found.\n");
306       return false;
307     }
308 
309     if (!AA->doesNotAccessMemory(Call)) {
310       LLVM_DEBUG(dbgs() << "    Unsafe call site found.\n");
311       return false;
312     }
313   }
314 
315   // Avoid loops with possiblity of throw
316   if (I->mayThrow()) {
317     LLVM_DEBUG(dbgs() << "    May throw instruction found in loop body\n");
318     return false;
319   }
320   // If current instruction is load instructions
321   // make sure it's a simple load (non atomic & non volatile)
322   if (I->mayReadFromMemory()) {
323     LoadInst *Ld = dyn_cast<LoadInst>(I);
324     if (!Ld || !Ld->isSimple()) {
325       LLVM_DEBUG(dbgs() << "    Found a non-simple load.\n");
326       return false;
327     }
328     LoadAndStoreCounter++;
329     Value *Ptr = Ld->getPointerOperand();
330     // Check loop invariant.
331     if (SE->isLoopInvariant(SE->getSCEV(Ptr), CurLoop))
332       InvariantCounter++;
333   }
334   // If current instruction is store instruction
335   // make sure it's a simple store (non atomic & non volatile)
336   else if (I->mayWriteToMemory()) {
337     StoreInst *St = dyn_cast<StoreInst>(I);
338     if (!St || !St->isSimple()) {
339       LLVM_DEBUG(dbgs() << "    Found a non-simple store.\n");
340       return false;
341     }
342     LoadAndStoreCounter++;
343     Value *Ptr = St->getPointerOperand();
344     // Check loop invariant.
345     if (SE->isLoopInvariant(SE->getSCEV(Ptr), CurLoop))
346       InvariantCounter++;
347 
348     IsReadOnlyLoop = false;
349   }
350   return true;
351 }
352 
353 /// Check loop instructions and confirms it's good for
354 /// LoopVersioningLICM.
355 bool LoopVersioningLICM::legalLoopInstructions() {
356   // Resetting counters.
357   LoadAndStoreCounter = 0;
358   InvariantCounter = 0;
359   IsReadOnlyLoop = true;
360   using namespace ore;
361   // Iterate over loop blocks and instructions of each block and check
362   // instruction safety.
363   for (auto *Block : CurLoop->getBlocks())
364     for (auto &Inst : *Block) {
365       // If instruction is unsafe just return false.
366       if (!instructionSafeForVersioning(&Inst)) {
367         ORE->emit([&]() {
368           return OptimizationRemarkMissed(DEBUG_TYPE, "IllegalLoopInst", &Inst)
369                  << " Unsafe Loop Instruction";
370         });
371         return false;
372       }
373     }
374   // Get LoopAccessInfo from current loop via the proxy.
375   LAI = &LAIs.getInfo(*CurLoop);
376   // Check LoopAccessInfo for need of runtime check.
377   if (LAI->getRuntimePointerChecking()->getChecks().empty()) {
378     LLVM_DEBUG(dbgs() << "    LAA: Runtime check not found !!\n");
379     return false;
380   }
381   // Number of runtime-checks should be less then RuntimeMemoryCheckThreshold
382   if (LAI->getNumRuntimePointerChecks() >
383       VectorizerParams::RuntimeMemoryCheckThreshold) {
384     LLVM_DEBUG(
385         dbgs() << "    LAA: Runtime checks are more than threshold !!\n");
386     ORE->emit([&]() {
387       return OptimizationRemarkMissed(DEBUG_TYPE, "RuntimeCheck",
388                                       CurLoop->getStartLoc(),
389                                       CurLoop->getHeader())
390              << "Number of runtime checks "
391              << NV("RuntimeChecks", LAI->getNumRuntimePointerChecks())
392              << " exceeds threshold "
393              << NV("Threshold", VectorizerParams::RuntimeMemoryCheckThreshold);
394     });
395     return false;
396   }
397   // Loop should have at least one invariant load or store instruction.
398   if (!InvariantCounter) {
399     LLVM_DEBUG(dbgs() << "    Invariant not found !!\n");
400     return false;
401   }
402   // Read only loop not allowed.
403   if (IsReadOnlyLoop) {
404     LLVM_DEBUG(dbgs() << "    Found a read-only loop!\n");
405     return false;
406   }
407   // Profitablity check:
408   // Check invariant threshold, should be in limit.
409   if (InvariantCounter * 100 < InvariantThreshold * LoadAndStoreCounter) {
410     LLVM_DEBUG(
411         dbgs()
412         << "    Invariant load & store are less then defined threshold\n");
413     LLVM_DEBUG(dbgs() << "    Invariant loads & stores: "
414                       << ((InvariantCounter * 100) / LoadAndStoreCounter)
415                       << "%\n");
416     LLVM_DEBUG(dbgs() << "    Invariant loads & store threshold: "
417                       << InvariantThreshold << "%\n");
418     ORE->emit([&]() {
419       return OptimizationRemarkMissed(DEBUG_TYPE, "InvariantThreshold",
420                                       CurLoop->getStartLoc(),
421                                       CurLoop->getHeader())
422              << "Invariant load & store "
423              << NV("LoadAndStoreCounter",
424                    ((InvariantCounter * 100) / LoadAndStoreCounter))
425              << " are less then defined threshold "
426              << NV("Threshold", InvariantThreshold);
427     });
428     return false;
429   }
430   return true;
431 }
432 
433 /// It checks loop is already visited or not.
434 /// check loop meta data, if loop revisited return true
435 /// else false.
436 bool LoopVersioningLICM::isLoopAlreadyVisited() {
437   // Check LoopVersioningLICM metadata into loop
438   if (findStringMetadataForLoop(CurLoop, LICMVersioningMetaData)) {
439     return true;
440   }
441   return false;
442 }
443 
444 /// Checks legality for LoopVersioningLICM by considering following:
445 /// a) loop structure legality   b) loop instruction legality
446 /// c) loop memory access legality.
447 /// Return true if legal else returns false.
448 bool LoopVersioningLICM::isLegalForVersioning() {
449   using namespace ore;
450   LLVM_DEBUG(dbgs() << "Loop: " << *CurLoop);
451   // Make sure not re-visiting same loop again.
452   if (isLoopAlreadyVisited()) {
453     LLVM_DEBUG(
454         dbgs() << "    Revisiting loop in LoopVersioningLICM not allowed.\n\n");
455     return false;
456   }
457   // Check loop structure leagality.
458   if (!legalLoopStructure()) {
459     LLVM_DEBUG(
460         dbgs() << "    Loop structure not suitable for LoopVersioningLICM\n\n");
461     ORE->emit([&]() {
462       return OptimizationRemarkMissed(DEBUG_TYPE, "IllegalLoopStruct",
463                                       CurLoop->getStartLoc(),
464                                       CurLoop->getHeader())
465              << " Unsafe Loop structure";
466     });
467     return false;
468   }
469   // Check loop instruction leagality.
470   if (!legalLoopInstructions()) {
471     LLVM_DEBUG(
472         dbgs()
473         << "    Loop instructions not suitable for LoopVersioningLICM\n\n");
474     return false;
475   }
476   // Check loop memory access leagality.
477   if (!legalLoopMemoryAccesses()) {
478     LLVM_DEBUG(
479         dbgs()
480         << "    Loop memory access not suitable for LoopVersioningLICM\n\n");
481     ORE->emit([&]() {
482       return OptimizationRemarkMissed(DEBUG_TYPE, "IllegalLoopMemoryAccess",
483                                       CurLoop->getStartLoc(),
484                                       CurLoop->getHeader())
485              << " Unsafe Loop memory access";
486     });
487     return false;
488   }
489   // Loop versioning is feasible, return true.
490   LLVM_DEBUG(dbgs() << "    Loop Versioning found to be beneficial\n\n");
491   ORE->emit([&]() {
492     return OptimizationRemark(DEBUG_TYPE, "IsLegalForVersioning",
493                               CurLoop->getStartLoc(), CurLoop->getHeader())
494            << " Versioned loop for LICM."
495            << " Number of runtime checks we had to insert "
496            << NV("RuntimeChecks", LAI->getNumRuntimePointerChecks());
497   });
498   return true;
499 }
500 
501 /// Update loop with aggressive aliasing assumptions.
502 /// It marks no-alias to any pairs of memory operations by assuming
503 /// loop should not have any must-alias memory accesses pairs.
504 /// During LoopVersioningLICM legality we ignore loops having must
505 /// aliasing memory accesses.
506 void LoopVersioningLICM::setNoAliasToLoop(Loop *VerLoop) {
507   // Get latch terminator instruction.
508   Instruction *I = VerLoop->getLoopLatch()->getTerminator();
509   // Create alias scope domain.
510   MDBuilder MDB(I->getContext());
511   MDNode *NewDomain = MDB.createAnonymousAliasScopeDomain("LVDomain");
512   StringRef Name = "LVAliasScope";
513   MDNode *NewScope = MDB.createAnonymousAliasScope(NewDomain, Name);
514   SmallVector<Metadata *, 4> Scopes{NewScope}, NoAliases{NewScope};
515   // Iterate over each instruction of loop.
516   // set no-alias for all load & store instructions.
517   for (auto *Block : CurLoop->getBlocks()) {
518     for (auto &Inst : *Block) {
519       // Only interested in instruction that may modify or read memory.
520       if (!Inst.mayReadFromMemory() && !Inst.mayWriteToMemory())
521         continue;
522       // Set no-alias for current instruction.
523       Inst.setMetadata(
524           LLVMContext::MD_noalias,
525           MDNode::concatenate(Inst.getMetadata(LLVMContext::MD_noalias),
526                               MDNode::get(Inst.getContext(), NoAliases)));
527       // set alias-scope for current instruction.
528       Inst.setMetadata(
529           LLVMContext::MD_alias_scope,
530           MDNode::concatenate(Inst.getMetadata(LLVMContext::MD_alias_scope),
531                               MDNode::get(Inst.getContext(), Scopes)));
532     }
533   }
534 }
535 
536 bool LoopVersioningLICM::run(DominatorTree *DT) {
537   // Do not do the transformation if disabled by metadata.
538   if (hasLICMVersioningTransformation(CurLoop) & TM_Disable)
539     return false;
540 
541   bool Changed = false;
542 
543   // Check feasiblity of LoopVersioningLICM.
544   // If versioning found to be feasible and beneficial then proceed
545   // else simply return, by cleaning up memory.
546   if (isLegalForVersioning()) {
547     // Do loop versioning.
548     // Create memcheck for memory accessed inside loop.
549     // Clone original loop, and set blocks properly.
550     LoopVersioning LVer(*LAI, LAI->getRuntimePointerChecking()->getChecks(),
551                         CurLoop, &LI, DT, SE);
552     LVer.versionLoop();
553     // Set Loop Versioning metaData for original loop.
554     addStringMetadataToLoop(LVer.getNonVersionedLoop(), LICMVersioningMetaData);
555     // Set Loop Versioning metaData for version loop.
556     addStringMetadataToLoop(LVer.getVersionedLoop(), LICMVersioningMetaData);
557     // Set "llvm.mem.parallel_loop_access" metaData to versioned loop.
558     // FIXME: "llvm.mem.parallel_loop_access" annotates memory access
559     // instructions, not loops.
560     addStringMetadataToLoop(LVer.getVersionedLoop(),
561                             "llvm.mem.parallel_loop_access");
562     // Update version loop with aggressive aliasing assumption.
563     setNoAliasToLoop(LVer.getVersionedLoop());
564     Changed = true;
565   }
566   return Changed;
567 }
568 
569 namespace llvm {
570 
571 PreservedAnalyses LoopVersioningLICMPass::run(Loop &L, LoopAnalysisManager &AM,
572                                               LoopStandardAnalysisResults &LAR,
573                                               LPMUpdater &U) {
574   AliasAnalysis *AA = &LAR.AA;
575   ScalarEvolution *SE = &LAR.SE;
576   DominatorTree *DT = &LAR.DT;
577   const Function *F = L.getHeader()->getParent();
578   OptimizationRemarkEmitter ORE(F);
579 
580   LoopAccessInfoManager LAIs(*SE, *AA, *DT, LAR.LI, nullptr);
581   if (!LoopVersioningLICM(AA, SE, &ORE, LAIs, LAR.LI, &L).run(DT))
582     return PreservedAnalyses::all();
583   return getLoopPassPreservedAnalyses();
584 }
585 } // namespace llvm
586