1 //===- llvm/Transforms/Utils/LoopUtils.h - Loop utilities -*- C++ -*-=========//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines some loop transformation utilities.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TRANSFORMS_UTILS_LOOPUTILS_H
15 #define LLVM_TRANSFORMS_UTILS_LOOPUTILS_H
25 class ScalarEvolution;
27 BasicBlock *InsertPreheaderForLoop(Loop *L, Pass *P);
29 /// \brief Simplify each loop in a loop nest recursively.
31 /// This takes a potentially un-simplified loop L (and its children) and turns
32 /// it into a simplified loop nest with preheaders and single backedges. It
33 /// will optionally update \c AliasAnalysis and \c ScalarEvolution analyses if
35 bool simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, Pass *PP,
36 AliasAnalysis *AA = nullptr, ScalarEvolution *SE = nullptr,
37 const DataLayout *DL = nullptr);
39 /// \brief Put loop into LCSSA form.
41 /// Looks at all instructions in the loop which have uses outside of the
42 /// current loop. For each, an LCSSA PHI node is inserted and the uses outside
43 /// the loop are rewritten to use this node.
45 /// LoopInfo and DominatorTree are required and preserved.
47 /// If ScalarEvolution is passed in, it will be preserved.
49 /// Returns true if any modifications are made to the loop.
50 bool formLCSSA(Loop &L, DominatorTree &DT, ScalarEvolution *SE = nullptr);
52 /// \brief Put a loop nest into LCSSA form.
54 /// This recursively forms LCSSA for a loop nest.
56 /// LoopInfo and DominatorTree are required and preserved.
58 /// If ScalarEvolution is passed in, it will be preserved.
60 /// Returns true if any modifications are made to the loop.
61 bool formLCSSARecursively(Loop &L, DominatorTree &DT,
62 ScalarEvolution *SE = nullptr);