[llvm] [VPlan] Implement interleaving as VPlan-to-VPlan transform. (PR #95842)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 13:03:58 PDT 2024


================
@@ -1582,3 +1583,449 @@ void VPlanTransforms::createInterleaveGroups(
       }
   }
 }
+
+namespace {
+
+/// Helper to hold state needed for unrolling. It holds the Plan to unroll by
+/// UF. It also holds copies of VPValues across UF-1 unroll parts to facilitate
+/// the unrolling transformation, where the original VPValues are retained for
+/// part zero.
+class UnrollState {
+  /// Plan to unroll.
+  VPlan &Plan;
+  /// Unroll factor to unroll by.
+  const unsigned UF;
+  /// Analysis for types.
+  VPTypeAnalysis TypeInfo;
+
+  /// Unrolling may create recipes that should not be unrolled themselves.
+  /// Those are tracked in ToSkip.
+  SmallPtrSet<VPRecipeBase *, 8> ToSkip;
+
+  // Associate with each VPValue of part 0 its unrolled instances of parts 1,
+  // ..., UF-1.
+  DenseMap<VPValue *, SmallVector<VPValue *>> VPV2Parts;
+
+  void unrollReplicateRegion(VPRegionBlock *VPR);
+  void unrollRecipe(VPRecipeBase &R);
----------------
ayalz wrote:

Worth documenting, and perhaps emphasizing in the name as `unrollRecipeByUF()` - this unrolls a recipe by UF, each instance of a ReplicateRecipe will be further unrolled by VF during code-gen (or another unrollByVF() pass).

https://github.com/llvm/llvm-project/pull/95842


More information about the llvm-commits mailing list