[llvm] [LV]Initial support for safe distance in predicated DataWithEVL vectorization mode. (PR #102897)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 16:08:22 PDT 2024
================
@@ -1337,7 +1337,23 @@ void VPlanTransforms::addActiveLaneMask(
/// %NextEVLIV = add IVSize (cast i32 %VPEVVL to IVSize), %EVLPhi
/// ...
///
-bool VPlanTransforms::tryAddExplicitVectorLength(VPlan &Plan) {
+/// If MaxEVLSafeElements is provided, the function adds the following recipes:
+/// vector.ph:
+/// ...
+///
+/// vector.body:
+/// ...
+/// %EVLPhi = EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI [ %StartV, %vector.ph ],
+/// [ %NextEVLIV, %vector.body ]
+/// %cmp = cmp ult %EVLPhi, MaxEVLSafeElements
+/// %SAFE_AVL = select %cmp, %EVLPhi, MaxEVLSafeElements
+/// %VPEVL = EXPLICIT-VECTOR-LENGTH %SAFE_AVL, original TC
----------------
ayalz wrote:
Conceptually, and following the initial explanation at the patch's original summary, the number of remaining iterations that can be processed together as a vector is at most %bound = min(original TC - EVLPhi, MaxSafeElements), and this should be fed as %cnt to experimental_get_vector_length().
The code here reduces the first operand of EXPLICIT-VECTOR-LENGTH from EVLPhi (=sum of all previous VPEVL's) to %SAFE_AVL = minimum(EVLPhi, MaxEVLSafeElements), which in turn may **increase** the EVL computed from original TC - %SAFE_AVL, rather than decrease it?
It is possible to ensure that EXPLICIT-VECTOR-LENGTH will produce a result bounded by MaxSafeElements by **increasing** its first operand from EVLPhi to %SAFE_AVL = maximum(EVLPhi, original TC - MaxSafeElements), defining the latter invariant difference as MaxEVLSafeElements, keeping its second invariant operand intact (original TC). In any case, the terms SAFE_AVL and MaxEVLSafeElements are confusing.
https://github.com/llvm/llvm-project/pull/102897
More information about the llvm-commits
mailing list