[llvm] [LV] Support scalable interleave groups for factors 3, 5, 6 and 7 (PR #141865)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Fri May 30 08:13:44 PDT 2025


================
@@ -3377,34 +3441,43 @@ void VPInterleaveRecipe::execute(VPTransformState &State) {
     ArrayRef<VPValue *> VPDefs = definedValues();
     const DataLayout &DL = State.CFG.PrevBB->getDataLayout();
     if (VecTy->isScalableTy()) {
-      assert(isPowerOf2_32(InterleaveFactor) &&
-             "Unsupported deinterleave factor for scalable vectors");
-
       // Scalable vectors cannot use arbitrary shufflevectors (only splats),
       // so must use intrinsics to deinterleave.
       SmallVector<Value *> DeinterleavedValues(InterleaveFactor);
-      DeinterleavedValues[0] = NewLoad;
-      // For the case of InterleaveFactor > 2, we will have to do recursive
-      // deinterleaving, because the current available deinterleave intrinsic
-      // supports only Factor of 2, otherwise it will bailout after first
-      // iteration.
-      // When deinterleaving, the number of values will double until we
-      // have "InterleaveFactor".
-      for (unsigned NumVectors = 1; NumVectors < InterleaveFactor;
-           NumVectors *= 2) {
+
+      if (InterleaveFactor <= 8) {
----------------
lukel97 wrote:

Yeah, I think this would allow us to deduplicate some of the reversing logic too.

It's probably also worthwhile raising the question if we should just take out the recursive interleaving logic for now, and only support factors <= 8.

I think this is now dead code for in-tree targets, since the only targets that have scalable vectorization are AArch64 and RISC-V, which limit the factor to 4 and 8 respectively in TTI.

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


More information about the llvm-commits mailing list