1 //===- LCSSA.h - Loop-closed SSA transform Pass -----------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This pass transforms loops by placing phi nodes at the end of the loops for
11 // all values that are live across the loop boundary.  For example, it turns
12 // the left into the right code:
13 //
14 // for (...)                for (...)
15 //   if (c)                   if (c)
16 //     X1 = ...                 X1 = ...
17 //   else                     else
18 //     X2 = ...                 X2 = ...
19 //   X3 = phi(X1, X2)         X3 = phi(X1, X2)
20 // ... = X3 + 4             X4 = phi(X3)
21 //                          ... = X4 + 4
22 //
23 // This is still valid LLVM; the extra phi nodes are purely redundant, and will
24 // be trivially eliminated by InstCombine.  The major benefit of this
25 // transformation is that it makes many other loop optimizations, such as
26 // LoopUnswitching, simpler.
27 //
28 //===----------------------------------------------------------------------===//
29 
30 #ifndef LLVM_TRANSFORMS_UTILS_LCSSA_H
31 #define LLVM_TRANSFORMS_UTILS_LCSSA_H
32 
33 #include "llvm/IR/PassManager.h"
34 
35 namespace llvm {
36 
37 /// Converts loops into loop-closed SSA form.
38 class LCSSAPass : public PassInfoMixin<LCSSAPass> {
39 public:
40   PreservedAnalyses run(Function &F, AnalysisManager<Function> &AM);
41 };
42 } // end namespace llvm
43 
44 #endif // LLVM_TRANSFORMS_UTILS_LCSSA_H
45