LLVM  4.0.0
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 //===----------------------------------------------------------------------===//
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"
59 #include "llvm/Analysis/LoopInfo.h"
63 #include "llvm/IR/Function.h"
64 #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 
87  std::function<const LoopAccessInfo &(Loop &)> *GetLAA;
89 
91 
93 
94  // Shim for old PM.
95  bool runImpl(Function &F, ScalarEvolution &SE_, LoopInfo &LI_,
99  std::function<const LoopAccessInfo &(Loop &)> &GetLAA_,
101 
102  bool processLoop(Loop *L);
103 };
104 }
105 
106 #endif // LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZE_H
MachineLoop * L
DominatorTree * DT
Definition: LoopVectorize.h:81
std::function< const LoopAccessInfo &(Loop &)> * GetLAA
Definition: LoopVectorize.h:87
This header provides classes for managing a pipeline of passes over loops in LLVM IR...
AssumptionCache * AC
Definition: LoopVectorize.h:86
BlockFrequencyInfo * BFI
Definition: LoopVectorize.h:82
The main scalar evolution driver.
A cache of .assume calls within a function.
bool AlwaysVectorize
If true, consider all loops for vectorization.
Definition: LoopVectorize.h:76
TargetLibraryInfo * TLI
Definition: LoopVectorize.h:83
ScalarEvolution * SE
Definition: LoopVectorize.h:78
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
#define F(x, y, z)
Definition: MD5.cpp:51
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:311
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:96
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)
BlockFrequency ColdEntryFreq
Definition: LoopVectorize.h:90
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:107
AliasAnalysis * AA
Definition: LoopVectorize.h:85
TargetTransformInfo * TTI
Definition: LoopVectorize.h:80
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:368
OptimizationRemarkEmitter * ORE
Definition: LoopVectorize.h:88
The LoopVectorize Pass.
Definition: LoopVectorize.h:71
print Print MemDeps of function
This is the interface for LLVM's primary stateless and local alias analysis.
A container for analyses that lazily runs them and caches their results.
This pass exposes codegen information to IR-level passes.
This header defines various interfaces for pass management in LLVM.
The optimization diagnostic interface.