Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:43

0001 //===- LoopSimplify.h - Loop Canonicalization Pass --------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This pass performs several transformations to transform natural loops into a
0010 // simpler form, which makes subsequent analyses and transformations simpler and
0011 // more effective.
0012 //
0013 // Loop pre-header insertion guarantees that there is a single, non-critical
0014 // entry edge from outside of the loop to the loop header.  This simplifies a
0015 // number of analyses and transformations, such as LICM.
0016 //
0017 // Loop exit-block insertion guarantees that all exit blocks from the loop
0018 // (blocks which are outside of the loop that have predecessors inside of the
0019 // loop) only have predecessors from inside of the loop (and are thus dominated
0020 // by the loop header).  This simplifies transformations such as store-sinking
0021 // that are built into LICM.
0022 //
0023 // This pass also guarantees that loops will have exactly one backedge.
0024 //
0025 // Indirectbr instructions introduce several complications. If the loop
0026 // contains or is entered by an indirectbr instruction, it may not be possible
0027 // to transform the loop and make these guarantees. Client code should check
0028 // that these conditions are true before relying on them.
0029 //
0030 // Note that the simplifycfg pass will clean up blocks which are split out but
0031 // end up being unnecessary, so usage of this pass should not pessimize
0032 // generated code.
0033 //
0034 // This pass obviously modifies the CFG, but updates loop information and
0035 // dominator information.
0036 //
0037 //===----------------------------------------------------------------------===//
0038 #ifndef LLVM_TRANSFORMS_UTILS_LOOPSIMPLIFY_H
0039 #define LLVM_TRANSFORMS_UTILS_LOOPSIMPLIFY_H
0040 
0041 #include "llvm/IR/PassManager.h"
0042 
0043 namespace llvm {
0044 
0045 class AssumptionCache;
0046 class DominatorTree;
0047 class Loop;
0048 class LoopInfo;
0049 class MemorySSAUpdater;
0050 class ScalarEvolution;
0051 
0052 /// This pass is responsible for loop canonicalization.
0053 class LoopSimplifyPass : public PassInfoMixin<LoopSimplifyPass> {
0054 public:
0055   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
0056 };
0057 
0058 /// Simplify each loop in a loop nest recursively.
0059 ///
0060 /// This takes a potentially un-simplified loop L (and its children) and turns
0061 /// it into a simplified loop nest with preheaders and single backedges. It will
0062 /// update \c DominatorTree, \c LoopInfo, \c ScalarEvolution and \c MemorySSA
0063 /// analyses if they're non-null, and LCSSA if \c PreserveLCSSA is true.
0064 bool simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE,
0065                   AssumptionCache *AC, MemorySSAUpdater *MSSAU,
0066                   bool PreserveLCSSA);
0067 
0068 } // end namespace llvm
0069 
0070 #endif // LLVM_TRANSFORMS_UTILS_LOOPSIMPLIFY_H