1 //===- LoopVectorize.h ------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This is the LLVM loop vectorizer. This pass modifies 'vectorizable' loops
10 // and generates target-independent LLVM-IR.
11 // The vectorizer uses the TargetTransformInfo analysis to estimate the costs
12 // of instructions in order to estimate the profitability of vectorization.
14 // The loop vectorizer combines consecutive loop iterations into a single
15 // 'wide' iteration. After this transformation the index is incremented
16 // by the SIMD vector width, and not by one.
18 // This pass has three parts:
19 // 1. The main loop pass that drives the different parts.
20 // 2. LoopVectorizationLegality - A unit that checks for the legality
21 // of the vectorization.
22 // 3. InnerLoopVectorizer - A unit that performs the actual
23 // widening of instructions.
24 // 4. LoopVectorizationCostModel - A unit that checks for the profitability
25 // of vectorization. It decides on the optimal vector width, which
26 // can be one, if vectorization is not profitable.
28 // There is a development effort going on to migrate loop vectorizer to the
29 // VPlan infrastructure and to introduce outer loop vectorization support (see
30 // docs/Proposal/VectorizationPlan.rst and
31 // http://lists.llvm.org/pipermail/llvm-dev/2017-December/119523.html). For this
32 // purpose, we temporarily introduced the VPlan-native vectorization path: an
33 // alternative vectorization path that is natively implemented on top of the
34 // VPlan infrastructure. See EnableVPlanNativePath for enabling.
36 //===----------------------------------------------------------------------===//
38 // The reduction-variable vectorization is based on the paper:
39 // D. Nuzman and R. Henderson. Multi-platform Auto-vectorization.
41 // Variable uniformity checks are inspired by:
42 // Karrenberg, R. and Hack, S. Whole Function Vectorization.
44 // The interleaved access vectorization is based on the paper:
45 // Dorit Nuzman, Ira Rosen and Ayal Zaks. Auto-Vectorization of Interleaved
48 // Other ideas/concepts are from:
49 // A. Zaks and D. Nuzman. Autovectorization in GCC-two years later.
51 // S. Maleki, Y. Gao, M. Garzaran, T. Wong and D. Padua. An Evaluation of
52 // Vectorizing Compilers.
54 //===----------------------------------------------------------------------===//
56 #ifndef LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZE_H
57 #define LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZE_H
59 #include "llvm/Analysis/AliasAnalysis.h"
60 #include "llvm/IR/PassManager.h"
65 class AssumptionCache
;
66 class BlockFrequencyInfo
;
73 class OptimizationRemarkEmitter
;
74 class ScalarEvolution
;
75 class TargetLibraryInfo
;
76 class TargetTransformInfo
;
78 /// The LoopVectorize Pass.
79 struct LoopVectorizePass
: public PassInfoMixin
<LoopVectorizePass
> {
80 /// If false, consider all loops for interleaving.
81 /// If true, only loops that explicitly request interleaving are considered.
82 bool InterleaveOnlyWhenForced
= false;
84 /// If false, consider all loops for vectorization.
85 /// If true, only loops that explicitly request vectorization are considered.
86 bool VectorizeOnlyWhenForced
= false;
90 TargetTransformInfo
*TTI
;
92 BlockFrequencyInfo
*BFI
;
93 TargetLibraryInfo
*TLI
;
97 std::function
<const LoopAccessInfo
&(Loop
&)> *GetLAA
;
98 OptimizationRemarkEmitter
*ORE
;
100 PreservedAnalyses
run(Function
&F
, FunctionAnalysisManager
&AM
);
103 bool runImpl(Function
&F
, ScalarEvolution
&SE_
, LoopInfo
&LI_
,
104 TargetTransformInfo
&TTI_
, DominatorTree
&DT_
,
105 BlockFrequencyInfo
&BFI_
, TargetLibraryInfo
*TLI_
,
106 DemandedBits
&DB_
, AliasAnalysis
&AA_
, AssumptionCache
&AC_
,
107 std::function
<const LoopAccessInfo
&(Loop
&)> &GetLAA_
,
108 OptimizationRemarkEmitter
&ORE
);
110 bool processLoop(Loop
*L
);
113 } // end namespace llvm
115 #endif // LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZE_H