1 //===-- Scalar.h - Scalar Transformations ------------------------*- C++ -*-==//
3 // This header file defines prototypes for accessor functions that expose passes
4 // in the Scalar transformations library.
6 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_TRANSFORMS_SCALAR_H
9 #define LLVM_TRANSFORMS_SCALAR_H
13 //===----------------------------------------------------------------------===//
15 // Constant Propogation Pass - A worklist driven constant propogation pass
17 Pass *createConstantPropogationPass();
20 //===----------------------------------------------------------------------===//
22 // Sparse Conditional Constant Propogation Pass
24 Pass *createSCCPPass();
27 //===----------------------------------------------------------------------===//
29 // DeadInstElimination - This pass quickly removes trivially dead instructions
30 // without modifying the CFG of the function. It is a BasicBlockPass, so it
31 // runs efficiently when queued next to other BasicBlockPass's.
33 Pass *createDeadInstEliminationPass();
36 //===----------------------------------------------------------------------===//
38 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
39 // because it is worklist driven that can potentially revisit instructions when
40 // their other instructions become dead, to eliminate chains of dead
43 Pass *createDeadCodeEliminationPass();
46 //===----------------------------------------------------------------------===//
48 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm. This
49 // algorithm assumes instructions are dead until proven otherwise, which makes
50 // it more successful are removing non-obviously dead instructions.
52 Pass *createAggressiveDCEPass();
55 //===----------------------------------------------------------------------===//
57 // DecomposeMultiDimRefs - Convert multi-dimensional references consisting of
58 // any combination of 2 or more array and structure indices into a sequence of
59 // instructions (using getelementpr and cast) so that each instruction has at
60 // most one index (except structure references, which need an extra leading
63 Pass *createDecomposeMultiDimRefsPass();
66 //===----------------------------------------------------------------------===//
68 // GCSE - This pass is designed to be a very quick global transformation that
69 // eliminates global common subexpressions from a function. It does this by
70 // examining the SSA value graph of the function, instead of doing slow
71 // bit-vector computations.
73 Pass *createGCSEPass();
76 //===----------------------------------------------------------------------===//
78 // InductionVariableSimplify - Transform induction variables in a program to all
79 // use a single cannonical induction variable per loop.
81 Pass *createIndVarSimplifyPass();
84 //===----------------------------------------------------------------------===//
86 // InstructionCombining - Combine instructions to form fewer, simple
87 // instructions. This pass does not modify the CFG, and has a tendancy to
88 // make instructions dead, so a subsequent DCE pass is useful.
90 // This pass combines things like:
96 Pass *createInstructionCombiningPass();
99 //===----------------------------------------------------------------------===//
101 // LICM - This pass is a simple natural loop based loop invariant code motion
104 Pass *createLICMPass();
107 //===----------------------------------------------------------------------===//
109 // PiNodeInsertion - This pass inserts single entry Phi nodes into basic blocks
110 // that are preceeded by a conditional branch, where the branch gives
111 // information about the operands of the condition. For example, this C code:
112 // if (x == 0) { ... = x + 4;
115 // x2 = phi(x); // Node that can hold data flow information about X
118 // Since the direction of the condition branch gives information about X itself
119 // (whether or not it is zero), some passes (like value numbering or ABCD) can
120 // use the inserted Phi/Pi nodes as a place to attach information, in this case
121 // saying that X has a value of 0 in this scope. The power of this analysis
122 // information is that "in the scope" translates to "for all uses of x2".
124 // This special form of Phi node is refered to as a Pi node, following the
125 // terminology defined in the "Array Bounds Checks on Demand" paper.
127 Pass *createPiNodeInsertionPass();
130 //===----------------------------------------------------------------------===//
132 // This pass is used to promote memory references to be register references. A
133 // simple example of the transformation performed by this pass is:
136 // %X = alloca int, uint 1 ret int 42
137 // store int 42, int *%X
141 Pass *createPromoteMemoryToRegister();
144 //===----------------------------------------------------------------------===//
146 // This pass reassociates commutative expressions in an order that is designed
147 // to promote better constant propogation, GCSE, LICM, PRE...
149 // For example: 4 + (x + 5) -> x + (4 + 5)
151 Pass *createReassociatePass();
154 //===----------------------------------------------------------------------===//
156 // CFG Simplification - Merge basic blocks, eliminate unreachable blocks,
157 // simplify terminator instructions, etc...
159 Pass *createCFGSimplificationPass();
162 //===----------------------------------------------------------------------===//
164 // These functions removes symbols from functions and modules.
166 Pass *createSymbolStrippingPass();
167 Pass *createFullSymbolStrippingPass();