[llvm] [LV] Convert gather loads with constant stride into strided loads (PR #147297)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 5 03:05:17 PDT 2026


================
@@ -2071,6 +2079,30 @@ void VPWidenIntrinsicRecipe::printRecipe(raw_ostream &O, const Twine &Indent,
 }
 #endif
 
+void VPWidenMemIntrinsicRecipe::execute(VPTransformState &State) {
+  CallInst *MemI = createVectorCall(State);
+  MemI->addParamAttr(
+      0, Attribute::getWithAlignment(MemI->getContext(), Alignment));
+  State.set(this, MemI);
+}
+
+InstructionCost VPWidenMemIntrinsicRecipe::computeMemIntrinsicCost(
+    Intrinsic::ID IID, Type *Ty, bool IsMasked, Align Alignment,
+    VPCostContext &Ctx) {
+  return Ctx.TTI.getMemIntrinsicInstrCost(
+      MemIntrinsicCostAttributes(IID, Ty, /*Ptr=*/nullptr, IsMasked, Alignment),
+      Ctx.CostKind);
+}
+
+InstructionCost
+VPWidenMemIntrinsicRecipe::computeCost(ElementCount VF,
+                                       VPCostContext &Ctx) const {
+  Type *Ty = toVectorTy(getScalarType(), VF);
+  return computeMemIntrinsicCost(getVectorIntrinsicID(), Ty,
+                                 !match(getOperand(2), m_True()), Alignment,
+                                 Ctx);
+}
----------------
fhahn wrote:

@arcbbb @Mel-Chen Just checking back in, is there no way to construct a test for this code path?

```
if (!isLegalStridedLoadStore(DataTy, Alignment))
  return BaseT::getMemIntrinsicInstrCost(MICA, CostKind);
```

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


More information about the llvm-commits mailing list