LoopVectorizer: When -Os is used, vectorize only loops that dont require a tail loop...
[oota-llvm.git] / include / llvm / Transforms / Vectorize.h
1 //===-- Vectorize.h - Vectorization Transformations -------------*- 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 header file defines prototypes for accessor functions that expose passes
11 // in the Vectorize transformations library.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_TRANSFORMS_VECTORIZE_H
16 #define LLVM_TRANSFORMS_VECTORIZE_H
17
18 namespace llvm {
19 class BasicBlock;
20 class BasicBlockPass;
21 class Pass;
22
23 //===----------------------------------------------------------------------===//
24 /// @brief Vectorize configuration.
25 struct VectorizeConfig {
26   //===--------------------------------------------------------------------===//
27   // Target architecture related parameters
28
29   /// @brief The size of the native vector registers.
30   unsigned VectorBits;
31
32   /// @brief Vectorize boolean values.
33   bool VectorizeBools;
34
35   /// @brief Vectorize integer values.
36   bool VectorizeInts;
37
38   /// @brief Vectorize floating-point values.
39   bool VectorizeFloats;
40
41   /// @brief Vectorize pointer values.
42   bool VectorizePointers;
43
44   /// @brief Vectorize casting (conversion) operations.
45   bool VectorizeCasts;
46
47   /// @brief Vectorize floating-point math intrinsics.
48   bool VectorizeMath;
49
50   /// @brief Vectorize the fused-multiply-add intrinsic.
51   bool VectorizeFMA;
52
53   /// @brief Vectorize select instructions.
54   bool VectorizeSelect;
55
56   /// @brief Vectorize comparison instructions.
57   bool VectorizeCmp;
58
59   /// @brief Vectorize getelementptr instructions.
60   bool VectorizeGEP;
61
62   /// @brief Vectorize loads and stores.
63   bool VectorizeMemOps;
64
65   /// @brief Only generate aligned loads and stores.
66   bool AlignedOnly;
67
68   //===--------------------------------------------------------------------===//
69   // Misc parameters
70
71   /// @brief The required chain depth for vectorization.
72   unsigned ReqChainDepth;
73
74   /// @brief The maximum search distance for instruction pairs.
75   unsigned SearchLimit;
76
77   /// @brief The maximum number of candidate pairs with which to use a full
78   ///        cycle check.
79   unsigned MaxCandPairsForCycleCheck;
80
81   /// @brief Replicating one element to a pair breaks the chain.
82   bool SplatBreaksChain;
83
84   /// @brief The maximum number of pairable instructions per group.
85   unsigned MaxInsts;
86
87   /// @brief The maximum number of pairing iterations.
88   unsigned MaxIter;
89
90   /// @brief Don't try to form odd-length vectors.
91   bool Pow2LenOnly;
92
93   /// @brief Don't boost the chain-depth contribution of loads and stores.
94   bool NoMemOpBoost;
95
96   /// @brief Use a fast instruction dependency analysis.
97   bool FastDep;
98
99   /// @brief Initialize the VectorizeConfig from command line options.
100   VectorizeConfig();
101 };
102
103 //===----------------------------------------------------------------------===//
104 //
105 // BBVectorize - A basic-block vectorization pass.
106 //
107 BasicBlockPass *
108 createBBVectorizePass(const VectorizeConfig &C = VectorizeConfig());
109
110 //===----------------------------------------------------------------------===//
111 //
112 // LoopVectorize - Create a loop vectorization pass.
113 //
114 Pass *createLoopVectorizePass(bool OptForSize);
115
116 //===----------------------------------------------------------------------===//
117 /// @brief Vectorize the BasicBlock.
118 ///
119 /// @param BB The BasicBlock to be vectorized
120 /// @param P  The current running pass, should require AliasAnalysis and
121 ///           ScalarEvolution. After the vectorization, AliasAnalysis,
122 ///           ScalarEvolution and CFG are preserved.
123 ///
124 /// @return True if the BB is changed, false otherwise.
125 ///
126 bool vectorizeBasicBlock(Pass *P, BasicBlock &BB,
127                          const VectorizeConfig &C = VectorizeConfig());
128
129 } // End llvm namespace
130
131 #endif