LLVM  8.0.1
LoopVectorize.h
Go to the documentation of this file.
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 // There is a development effort going on to migrate loop vectorizer to the
30 // VPlan infrastructure and to introduce outer loop vectorization support (see
31 // docs/Proposal/VectorizationPlan.rst and
32 // http://lists.llvm.org/pipermail/llvm-dev/2017-December/119523.html). For this
33 // purpose, we temporarily introduced the VPlan-native vectorization path: an
34 // alternative vectorization path that is natively implemented on top of the
35 // VPlan infrastructure. See EnableVPlanNativePath for enabling.
36 //
37 //===----------------------------------------------------------------------===//
38 //
39 // The reduction-variable vectorization is based on the paper:
40 // D. Nuzman and R. Henderson. Multi-platform Auto-vectorization.
41 //
42 // Variable uniformity checks are inspired by:
43 // Karrenberg, R. and Hack, S. Whole Function Vectorization.
44 //
45 // The interleaved access vectorization is based on the paper:
46 // Dorit Nuzman, Ira Rosen and Ayal Zaks. Auto-Vectorization of Interleaved
47 // Data for SIMD
48 //
49 // Other ideas/concepts are from:
50 // A. Zaks and D. Nuzman. Autovectorization in GCC-two years later.
51 //
52 // S. Maleki, Y. Gao, M. Garzaran, T. Wong and D. Padua. An Evaluation of
53 // Vectorizing Compilers.
54 //
55 //===----------------------------------------------------------------------===//
56 
57 #ifndef LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZE_H
58 #define LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZE_H
59 
61 #include "llvm/IR/PassManager.h"
62 #include <functional>
63 
64 namespace llvm {
65 
66 class AssumptionCache;
67 class BlockFrequencyInfo;
68 class DemandedBits;
69 class DominatorTree;
70 class Function;
71 class Loop;
72 class LoopAccessInfo;
73 class LoopInfo;
74 class OptimizationRemarkEmitter;
75 class ScalarEvolution;
76 class TargetLibraryInfo;
77 class TargetTransformInfo;
78 
79 /// The LoopVectorize Pass.
80 struct LoopVectorizePass : public PassInfoMixin<LoopVectorizePass> {
81  /// If false, consider all loops for interleaving.
82  /// If true, only loops that explicitly request interleaving are considered.
84 
85  /// If false, consider all loops for vectorization.
86  /// If true, only loops that explicitly request vectorization are considered.
88 
98  std::function<const LoopAccessInfo &(Loop &)> *GetLAA;
100 
102 
103  // Shim for old PM.
104  bool runImpl(Function &F, ScalarEvolution &SE_, LoopInfo &LI_,
107  DemandedBits &DB_, AliasAnalysis &AA_, AssumptionCache &AC_,
108  std::function<const LoopAccessInfo &(Loop &)> &GetLAA_,
110 
111  bool processLoop(Loop *L);
112 };
113 
114 } // end namespace llvm
115 
116 #endif // LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZE_H
DominatorTree * DT
Definition: LoopVectorize.h:92
std::function< const LoopAccessInfo &(Loop &)> * GetLAA
Definition: LoopVectorize.h:98
This class represents lattice values for constants.
Definition: AllocatorList.h:24
AssumptionCache * AC
Definition: LoopVectorize.h:97
BlockFrequencyInfo * BFI
Definition: LoopVectorize.h:93
The main scalar evolution driver.
A cache of @llvm.assume calls within a function.
F(f)
TargetLibraryInfo * TLI
Definition: LoopVectorize.h:94
ScalarEvolution * SE
Definition: LoopVectorize.h:89
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:366
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:145
bool runImpl(Function &F, ScalarEvolution &SE_, LoopInfo &LI_, TargetTransformInfo &TTI_, DominatorTree &DT_, BlockFrequencyInfo &BFI_, TargetLibraryInfo *TLI_, DemandedBits &DB_, AliasAnalysis &AA_, AssumptionCache &AC_, std::function< const LoopAccessInfo &(Loop &)> &GetLAA_, OptimizationRemarkEmitter &ORE)
bool InterleaveOnlyWhenForced
If false, consider all loops for interleaving.
Definition: LoopVectorize.h:83
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:154
AliasAnalysis * AA
Definition: LoopVectorize.h:96
TargetTransformInfo * TTI
Definition: LoopVectorize.h:91
bool VectorizeOnlyWhenForced
If false, consider all loops for vectorization.
Definition: LoopVectorize.h:87
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Provides information about what library functions are available for the current target.
Drive the analysis of memory accesses in the loop.
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:465
OptimizationRemarkEmitter * ORE
Definition: LoopVectorize.h:99
The LoopVectorize Pass.
Definition: LoopVectorize.h:80
print Print MemDeps of function
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
The optimization diagnostic interface.