[llvm] [Analysis][RISCV] More accurately estimate the cost of strided vector loads (PR #175135)
Ryan Buchner via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 23:31:20 PST 2026
================
@@ -1274,6 +1274,25 @@ RISCVTTIImpl::getStridedMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
getMemoryOpCost(Opcode, VTy.getElementType(), Alignment, 0, CostKind,
{TTI::OK_AnyValue, TTI::OP_None}, I);
unsigned NumLoads = getEstimatedVLFor(&VTy);
+ // Performant implementations of the vector extension will attempt to re-use
+ // elements if they fall on the same cache line
+ uint64_t CacheLineBytes = ST->getCacheLineSize();
+ if (!CacheLineBytes) // If no value, use default value of 64
+ CacheLineBytes = 64;
+ unsigned EltsPerCL = (CacheLineBytes * 8) / DataTy->getScalarSizeInBits();
+ if (const ConstantInt *StrideCI =
+ dyn_cast_or_null<ConstantInt>(MICA.getStrideVal())) {
+ uint64_t AbsStride = (uint64_t)std::abs(StrideCI->getSExtValue());
+ if (AbsStride < EltsPerCL) {
----------------
bababuck wrote:
Thanks. I mistakenly thought that `stride` was in terms of number of elements, but per [LangRef](https://llvm.org/docs/LangRef.html#llvm-experimental-vp-strided-load-intrinsic).
```
The ‘llvm.experimental.vp.strided.load’ intrinsic loads, into a vector,
scalar values from memory locations evenly spaced apart by
‘stride’ number of bytes, starting from ‘ptr’.
```
https://github.com/llvm/llvm-project/pull/175135
More information about the llvm-commits
mailing list