[llvm] [LV]: Teach LV to recursively (de)interleave. (PR #89018)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 10:21:17 PDT 2024


================
@@ -3558,15 +3558,17 @@ InstructionCost AArch64TTIImpl::getInterleavedMemoryOpCost(
   assert(Factor >= 2 && "Invalid interleave factor");
   auto *VecVTy = cast<VectorType>(VecTy);
 
-  if (VecTy->isScalableTy() && (!ST->hasSVE() || Factor != 2))
+  unsigned MaxFactor = TLI->getMaxSupportedInterleaveFactor();
+  if (VecTy->isScalableTy() &&
+      (!ST->hasSVE() || !isPowerOf2_32(Factor) || Factor > MaxFactor))
----------------
paulwalker-arm wrote:

Whilst this works I think it's much clearer to simply say `!ST->hasSVE() || (Factor != 2 && Factor != 4)`.

For what it's worth I don't see `getMaxSupportedInterleaveFactor()` being a good function because it doesn't provide enough context for the question it is asking (i.e. it assumes the vector types does not matter).  The only reason we don't run in to trouble is because other than this function all other uses are specific to fixed length vector types.

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


More information about the llvm-commits mailing list