[llvm] [LV] Add support for widening loads/stores to a VF multiple (PR #217670)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 6 23:04:43 PDT 2026


================
@@ -3903,6 +3903,50 @@ void VPlanTransforms::sinkPredicatedStores(VPlan &Plan,
   }
 }
 
+void VPlanTransforms::scaleMemoryAccessesByUF(VPlan &Plan, ElementCount VF,
+                                              unsigned UF,
+                                              const TargetTransformInfo &TTI) {
+  if (UF == 1)
+    return;
+
+  for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
+           vp_depth_first_deep(Plan.getVectorLoopRegion()->getEntry()))) {
+    for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
+      VPValue *StoredValue = nullptr;
+      if (!match(&R, m_WidenLoad(m_VPValue())) &&
+          !match(&R, m_WidenStore(m_VPValue(), m_VPValue(StoredValue))))
+        continue;
+
+      auto *MemOp = cast<VPWidenMemoryRecipe>(&R);
+      if (!MemOp->isConsecutive())
----------------
fhahn wrote:

Consecutive access can have negative stride, and I think in that case we won't extra the correct parts below (address for the store of the first path access idx-VF..VF elements)? Would be good to add a test (+ test with stride > 1)

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


More information about the llvm-commits mailing list