[llvm] [Delinearization] Extract outer array dimensions using global object size (PR #175158)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 22 06:38:53 PST 2026
================
@@ -590,6 +596,45 @@ bool llvm::findFixedSizeArrayDimensions(ScalarEvolution &SE, const SCEV *Expr,
return true;
}
+static void extractOuterDimFromGlobal(ScalarEvolution &SE, Value *BasePtr,
+ SmallVectorImpl<const SCEV *> &Sizes,
+ const SCEV *ElementSize) {
+ LLVM_DEBUG(assert(Sizes.size() >= 2 && "Sizes should contain at least"
+ " the element size and one dimension");
+
+ for (const SCEV *S : Sizes)
+ assert(cast<SCEVConstant>(S) && "Only SCEVConstant expected");
+
+ dbgs() << "extractArrayInfoFromGlobal called with BasePtr: "
+ << *BasePtr << "\n";);
+
+ auto *GV = dyn_cast<GlobalVariable>(BasePtr);
+ if (!GV) {
+ LLVM_DEBUG(dbgs() << "Base pointer is not a global variable, "
+ << "can't extract outer dimension.\n");
+ return false;
+ }
+
+ LLVM_DEBUG(dbgs() << "Found global variable with type: "
+ << *GV->getValueType() << "\n");
+
+ const DataLayout &DL = GV->getParent()->getDataLayout();
+ uint64_t SizeInBytes = DL.getTypeAllocSize(GV->getValueType());
+ LLVM_DEBUG(dbgs() << "Object size in bytes: " << SizeInBytes << "\n");
----------------
kasuga-fj wrote:
> My understanding is that at this point, the size here can still be heuristic, and will be validated against loop bounds later, right?
Yes, you are right. (Currently the validation is responsibility of client side, thought.)
https://github.com/llvm/llvm-project/pull/175158
More information about the llvm-commits
mailing list