@@ -19,6 +19,49 @@ candidates. It serves for both optimizing candidates including estimating their
19
19
cost reliably, and for performing their final translation into IR. This
20
20
facilitates dealing with multiple vectorization candidates.
21
21
22
+ Current Status
23
+ ==============
24
+ VPlan is currently used to drive code-generation in LoopVectorize. VPlans are
25
+ constructed after all cost-based and most legality-related decisions have been
26
+ taken. As def-use chains between recipes are now fully modeled in VPlan,
27
+ VPlan-based analyses and transformations are used to simplify and modularize
28
+ the vectorization process [10 ]_. Those include transformations to
29
+
30
+ 1. Legalize the initial VPlan, e.g. by introducing specialized recipes for
31
+ reductions and interleave groups.
32
+
33
+ 2. Optimize the legalized VPlan, e.g. by removing redundant recipes or
34
+ introducing active-lane-masks.
35
+
36
+ 3. Apply unroll- and vectorization-factor specific optimizations, e.g. removing
37
+ the backedge to reiterate the vector loop based on VF & UF.
38
+
39
+ Refer to :numref: `fig-vplan-transform-pipeline ` for an overview of the current
40
+ transformation pipeline.
41
+
42
+ Note that some legality checks are already done in VPlan, including checking if
43
+ all users of a fixed-order recurrence can be re-ordered. This is implemented as
44
+ a VPlan-to-VPlan transformation that either applies a valid re-ordering or
45
+ bails out marking the VPlan as invalid.
46
+
47
+ .. _fig-vplan-transform-pipeline :
48
+ .. figure :: ./vplan-transform-pipeline.png
49
+ :width: 800 px
50
+
51
+ VPlan Transformation Pipeline in 2024
52
+
53
+
54
+ VPlan currently models the complete vector loop, as well as additional parts of
55
+ the vectorization skeleton. Refer to :numref: `fig-vplan-scope ` for an overview
56
+ of the scope covered by VPlan.
57
+
58
+ .. _fig-vplan-scope :
59
+ .. figure :: ./vplan-scope.png
60
+ :width: 800 px
61
+
62
+ Scope modeled in VPlan in 2024
63
+
64
+
22
65
High-level Design
23
66
=================
24
67
@@ -160,13 +203,10 @@ The low-level design of VPlan comprises of the following classes.
160
203
VPValues.
161
204
162
205
:VPInstruction:
163
- A VPInstruction is both a VPRecipe and a VPUser. It models a single
164
- VPlan-level instruction to be generated if the VPlan is executed, including
165
- its opcode and possibly additional characteristics. It is the basis for
166
- writing instruction-level analyses and optimizations in VPlan as creating,
167
- replacing or moving VPInstructions record both def-use and scheduling
168
- decisions. VPInstructions also extend LLVM IR's opcodes with idiomatic
169
- operations that enrich the Vectorizer's semantics.
206
+ A VPInstruction is a recipe characterized by a single opcode and optional
207
+ flags, free of ingredients or other meta-data. VPInstructions also extend
208
+ LLVM IR's opcodes with idiomatic operations that enrich the Vectorizer's
209
+ semantics.
170
210
171
211
:VPTransformState:
172
212
Stores information used for generating output IR, passed from
@@ -177,9 +217,9 @@ The Planning Process and VPlan Roadmap
177
217
======================================
178
218
179
219
Transforming the Loop Vectorizer to use VPlan follows a staged approach. First,
180
- VPlan is used to record the final vectorization decisions, and to execute them:
181
- the Hierarchical CFG models the planned control-flow, and Recipes capture
182
- decisions taken inside basic-blocks. Next , VPlan will be used also as the basis
220
+ VPlan was only used to record the final vectorization decisions, and to execute
221
+ them: the Hierarchical CFG models the planned control-flow, and Recipes capture
222
+ decisions taken inside basic-blocks. Currently , VPlan is used also as the basis
183
223
for taking these decisions, effectively turning them into a series of
184
224
VPlan-to-VPlan algorithms. Finally, VPlan will support the planning process
185
225
itself including cost-based analyses for making these decisions, to fully
@@ -248,3 +288,6 @@ References
248
288
249
289
.. [9 ] "Extending LoopVectorizer: OpenMP4.5 SIMD and Outer Loop
250
290
Auto-Vectorization", Intel Vectorizer Team, LLVM Developers' Meeting 2016.
291
+
292
+ .. [10 ] "VPlan: Status Update and Future Roadmap", Florian Hahn, LLVM
293
+ Developers' Meeting 2023, https://www.youtube.com/watch?v=SzGP4PgMuLE
0 commit comments