]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h
Merge llvm, clang, lld and lldb trunk r291476.
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / Transforms / Vectorize / LoopVectorize.h
1 //===---- LoopVectorize.h ---------------------------------------*- 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 is the LLVM loop vectorizer. This pass modifies 'vectorizable' loops
11 // and generates target-independent LLVM-IR.
12 // The vectorizer uses the TargetTransformInfo analysis to estimate the costs
13 // of instructions in order to estimate the profitability of vectorization.
14 //
15 // The loop vectorizer combines consecutive loop iterations into a single
16 // 'wide' iteration. After this transformation the index is incremented
17 // by the SIMD vector width, and not by one.
18 //
19 // This pass has three parts:
20 // 1. The main loop pass that drives the different parts.
21 // 2. LoopVectorizationLegality - A unit that checks for the legality
22 //    of the vectorization.
23 // 3. InnerLoopVectorizer - A unit that performs the actual
24 //    widening of instructions.
25 // 4. LoopVectorizationCostModel - A unit that checks for the profitability
26 //    of vectorization. It decides on the optimal vector width, which
27 //    can be one, if vectorization is not profitable.
28 //
29 //===----------------------------------------------------------------------===//
30 //
31 // The reduction-variable vectorization is based on the paper:
32 //  D. Nuzman and R. Henderson. Multi-platform Auto-vectorization.
33 //
34 // Variable uniformity checks are inspired by:
35 //  Karrenberg, R. and Hack, S. Whole Function Vectorization.
36 //
37 // The interleaved access vectorization is based on the paper:
38 //  Dorit Nuzman, Ira Rosen and Ayal Zaks.  Auto-Vectorization of Interleaved
39 //  Data for SIMD
40 //
41 // Other ideas/concepts are from:
42 //  A. Zaks and D. Nuzman. Autovectorization in GCC-two years later.
43 //
44 //  S. Maleki, Y. Gao, M. Garzaran, T. Wong and D. Padua.  An Evaluation of
45 //  Vectorizing Compilers.
46 //
47 //===----------------------------------------------------------------------===//
48
49 #ifndef LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZE_H
50 #define LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZE_H
51
52 #include "llvm/ADT/MapVector.h"
53 #include "llvm/Analysis/AliasAnalysis.h"
54 #include "llvm/Analysis/AssumptionCache.h"
55 #include "llvm/Analysis/BasicAliasAnalysis.h"
56 #include "llvm/Analysis/BlockFrequencyInfo.h"
57 #include "llvm/Analysis/DemandedBits.h"
58 #include "llvm/Analysis/LoopAccessAnalysis.h"
59 #include "llvm/Analysis/LoopInfo.h"
60 #include "llvm/Analysis/LoopPassManager.h"
61 #include "llvm/Analysis/OptimizationDiagnosticInfo.h"
62 #include "llvm/Analysis/ScalarEvolution.h"
63 #include "llvm/Analysis/TargetTransformInfo.h"
64 #include "llvm/IR/Function.h"
65 #include "llvm/IR/PassManager.h"
66 #include <functional>
67
68 namespace llvm {
69
70 /// The LoopVectorize Pass.
71 struct LoopVectorizePass : public PassInfoMixin<LoopVectorizePass> {
72   bool DisableUnrolling = false;
73   /// If true, consider all loops for vectorization.
74   /// If false, only loops that explicitly request vectorization are
75   /// considered.
76   bool AlwaysVectorize = true;
77
78   ScalarEvolution *SE;
79   LoopInfo *LI;
80   TargetTransformInfo *TTI;
81   DominatorTree *DT;
82   BlockFrequencyInfo *BFI;
83   TargetLibraryInfo *TLI;
84   DemandedBits *DB;
85   AliasAnalysis *AA;
86   AssumptionCache *AC;
87   std::function<const LoopAccessInfo &(Loop &)> *GetLAA;
88   OptimizationRemarkEmitter *ORE;
89
90   BlockFrequency ColdEntryFreq;
91
92   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
93
94   // Shim for old PM.
95   bool runImpl(Function &F, ScalarEvolution &SE_, LoopInfo &LI_,
96                TargetTransformInfo &TTI_, DominatorTree &DT_,
97                BlockFrequencyInfo &BFI_, TargetLibraryInfo *TLI_,
98                DemandedBits &DB_, AliasAnalysis &AA_, AssumptionCache &AC_,
99                std::function<const LoopAccessInfo &(Loop &)> &GetLAA_,
100                OptimizationRemarkEmitter &ORE);
101
102   bool processLoop(Loop *L);
103 };
104 }
105
106 #endif // LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZE_H