Skip to content

Commit 99de3a6

Browse files
authored
[VPlan] Document current status. (#85689)
Update VectorizationPlan.rst to include a section about the current status of VPlan and its use in LoopVectorize, based on "VPlan: Status Update and Future Roadmap", LLVM Developers’ Meeting 2023, https://www.youtube.com/watch?v=SzGP4PgMuLE PR: #85689
1 parent 03d8e61 commit 99de3a6

File tree

4 files changed

+54
-10
lines changed

4 files changed

+54
-10
lines changed

llvm/docs/VectorizationPlan.rst

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,49 @@ candidates. It serves for both optimizing candidates including estimating their
1919
cost reliably, and for performing their final translation into IR. This
2020
facilitates dealing with multiple vectorization candidates.
2121

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+
2265
High-level Design
2366
=================
2467

@@ -160,13 +203,10 @@ The low-level design of VPlan comprises of the following classes.
160203
VPValues.
161204

162205
: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.
170210

171211
:VPTransformState:
172212
Stores information used for generating output IR, passed from
@@ -177,9 +217,9 @@ The Planning Process and VPlan Roadmap
177217
======================================
178218

179219
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
183223
for taking these decisions, effectively turning them into a series of
184224
VPlan-to-VPlan algorithms. Finally, VPlan will support the planning process
185225
itself including cost-based analyses for making these decisions, to fully
@@ -248,3 +288,6 @@ References
248288
249289
.. [9] "Extending LoopVectorizer: OpenMP4.5 SIMD and Outer Loop
250290
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

llvm/docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
# If false, no module index is generated.
223223
# latex_domain_indices = True
224224

225+
numfig = True
225226

226227
# -- Options for manual page output --------------------------------------------
227228

llvm/docs/vplan-scope.png

664 KB
Loading
542 KB
Loading

0 commit comments

Comments
 (0)