summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorGil Rapaport <gil.rapaport@intel.com>2017-11-20 12:01:47 +0000
committerGil Rapaport <gil.rapaport@intel.com>2017-11-20 12:01:47 +0000
commita36486e33b247dc3e7ce71211a434b4f35ec3751 (patch)
tree5ae968398e99f631733315509b6ace0f84e1fe1e /docs
parent3357ae93b383a5e25d9b421fa8bea8773c0ce3c7 (diff)
[LV] Model masking in VPlan, introducing VPInstructions
This patch adds a new abstraction layer to VPlan and leverages it to model the planned instructions that manipulate masks (AND, OR, NOT), introduced during predication. The new VPValue and VPUser classes model how data flows into, through and out of a VPlan, forming the vertices of a planned Def-Use graph. The new VPInstruction class is a generic single-instruction Recipe that models a planned instruction along with its opcode, operands and users. See VectorizationPlan.rst for more details. Differential Revision: https://reviews.llvm.org/D38676 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318645 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs')
-rw-r--r--docs/Proposals/VectorizationPlan.rst69
1 files changed, 67 insertions, 2 deletions
diff --git a/docs/Proposals/VectorizationPlan.rst b/docs/Proposals/VectorizationPlan.rst
index aed8e3d2b79..f9700d177d2 100644
--- a/docs/Proposals/VectorizationPlan.rst
+++ b/docs/Proposals/VectorizationPlan.rst
@@ -82,8 +82,14 @@ The design of VPlan follows several high-level guidelines:
replicated VF*UF times to handle scalarized and predicated instructions.
Innerloops are also modelled as SESE regions.
-Low-level Design
-================
+7. Support instruction-level analysis and transformation, as part of Planning
+ Step 2.b: During vectorization instructions may need to be traversed, moved,
+ replaced by other instructions or be created. For example, vector idiom
+ detection and formation involves searching for and optimizing instruction
+ patterns.
+
+Definitions
+===========
The low-level design of VPlan comprises of the following classes.
:LoopVectorizationPlanner:
@@ -139,11 +145,64 @@ The low-level design of VPlan comprises of the following classes.
instructions; e.g., cloned once, replicated multiple times or widened
according to selected VF.
+:VPValue:
+ The base of VPlan's def-use relations class hierarchy. When instantiated, it
+ models a constant or a live-in Value in VPlan. It has users, which are of type
+ VPUser, but no operands.
+
+:VPUser:
+ A VPValue representing a general vertex in the def-use graph of VPlan. It has
+ operands which are of type VPValue. When instantiated, it represents a
+ live-out Instruction that exists outside VPlan. VPUser is similar in some
+ aspects to LLVM's User class.
+
+:VPInstruction:
+ A VPInstruction is both a VPRecipe and a VPUser. It models a single
+ VPlan-level instruction to be generated if the VPlan is executed, including
+ its opcode and possibly additional characteristics. It is the basis for
+ writing instruction-level analyses and optimizations in VPlan as creating,
+ replacing or moving VPInstructions record both def-use and scheduling
+ decisions. VPInstructions also extend LLVM IR's opcodes with idiomatic
+ operations that enrich the Vectorizer's semantics.
+
:VPTransformState:
Stores information used for generating output IR, passed from
LoopVectorizationPlanner to its selected VPlan for execution, and used to pass
additional information down to VPBlocks and VPRecipes.
+The Planning Process and VPlan Roadmap
+======================================
+
+Transforming the Loop Vectorizer to use VPlan follows a staged approach. First,
+VPlan is used to record the final vectorization decisions, and to execute them:
+the Hierarchical CFG models the planned control-flow, and Recipes capture
+decisions taken inside basic-blocks. Next, VPlan will be used also as the basis
+for taking these decisions, effectively turning them into a series of
+VPlan-to-VPlan algorithms. Finally, VPlan will support the planning process
+itself including cost-based analyses for making these decisions, to fully
+support compositional and iterative decision making.
+
+Some decisions are local to an instruction in the loop, such as whether to widen
+it into a vector instruction or replicate it, keeping the generated instructions
+in place. Other decisions, however, involve moving instructions, replacing them
+with other instructions, and/or introducing new instructions. For example, a
+cast may sink past a later instruction and be widened to handle first-order
+recurrence; an interleave group of strided gathers or scatters may effectively
+move to one place where they are replaced with shuffles and a common wide vector
+load or store; new instructions may be introduced to compute masks, shuffle the
+elements of vectors, and pack scalar values into vectors or vice-versa.
+
+In order for VPlan to support making instruction-level decisions and analyses,
+it needs to model the relevant instructions along with their def/use relations.
+This too follows a staged approach: first, the new instructions that compute
+masks are modeled as VPInstructions, along with their induced def/use subgraph.
+This effectively models masks in VPlan, facilitating VPlan-based predication.
+Next, the logic embedded within each Recipe for generating its instructions at
+VPlan execution time, will instead take part in the planning process by modeling
+them as VPInstructions. Finally, only logic that applies to instructions as a
+group will remain in Recipes, such as interleave groups and potentially other
+idiom groups having synergistic cost.
+
Related LLVM components
-----------------------
1. SLP Vectorizer: one can compare the VPlan model with LLVM's existing SLP
@@ -152,6 +211,9 @@ Related LLVM components
2. RegionInfo: one can compare VPlan's H-CFG with the Region Analysis as used by
Polly [7]_.
+3. Loop Vectorizer: the Vectorization Plan aims to upgrade the infrastructure of
+ the Loop Vectorizer and extend it to handle outer loops [8,9]_.
+
References
----------
.. [1] "Outer-loop vectorization: revisited for short SIMD architectures", Dorit
@@ -180,3 +242,6 @@ References
.. [8] "Introducing VPlan to the Loop Vectorizer", Gil Rapaport and Ayal Zaks,
European LLVM Developers' Meeting 2017.
+
+.. [9] "Extending LoopVectorizer: OpenMP4.5 SIMD and Outer Loop
+ Auto-Vectorization", Intel Vectorizer Team, LLVM Developers' Meeting 2016.