[llvm] [LoopCacheAnalysis] Replace delinearization for fixed size array (PR #164798)
Sjoerd Meijer via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 19 03:55:42 PST 2025
================
@@ -355,22 +355,18 @@ CacheCostTy IndexedReference::computeRefCost(const Loop &L,
}
bool IndexedReference::tryDelinearizeFixedSize(
- const SCEV *AccessFn, SmallVectorImpl<const SCEV *> &Subscripts) {
- SmallVector<int, 4> ArraySizes;
- if (!tryDelinearizeFixedSizeImpl(&SE, &StoreOrLoadInst, AccessFn, Subscripts,
- ArraySizes))
+ const SCEV *AccessFn, SmallVectorImpl<const SCEV *> &Subscripts,
+ const SCEV *ElementSize) {
+ const SCEV *Offset = SE.removePointerBase(AccessFn);
+ if (!delinearizeFixedSizeArray(SE, Offset, Subscripts, Sizes, ElementSize)) {
+ Sizes.clear();
return false;
+ }
- // Populate Sizes with scev expressions to be used in calculations later.
- for (auto Idx : seq<unsigned>(1, Subscripts.size()))
- Sizes.push_back(
- SE.getConstant(Subscripts[Idx]->getType(), ArraySizes[Idx - 1]));
-
- LLVM_DEBUG({
- dbgs() << "Delinearized subscripts of fixed-size array\n"
- << "GEP:" << *getLoadStorePointerOperand(&StoreOrLoadInst)
- << "\n";
- });
+ // Drop the last element of Sizes which is the same as ElementSize.
+ assert(!Sizes.empty() && Sizes.back() == ElementSize &&
+ "Expecting the last one to be the element size");
----------------
sjoerdmeijer wrote:
I was going leave a nit if we can make the message a little bit more descriptive, but now looking at this, my first question is why we need to pass ElementSize if it is last element in the Sizes list?
https://github.com/llvm/llvm-project/pull/164798
More information about the llvm-commits
mailing list