[polly] [Polly] Restate array sizes and subscripts when the element type shrinks (PR #221496)
Timur Baidusenov via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 09:58:25 PDT 2026
================
@@ -476,6 +514,26 @@ void MemoryAccess::updateDimensionality() {
if (DimsAccess == 1) {
isl::val V = isl::val(Ctx, ArrayElemSize);
AccessRelation = AccessRelation.floordiv_val(V);
+ } else if (ElemBytes > ArrayElemSize) {
+ // A delinearized access has its subscripts in elements of the type it
+ // reads or writes, which is not the canonical element type of the array
+ // when some other access forced a smaller one. Restate the innermost
+ // subscript in canonical elements too; the outer ones count rows and are
+ // already stated in the sizes this access was delinearized against.
+ assert(ElemBytes % ArrayElemSize == 0 &&
+ "Loaded element size should be multiple of canonical element size");
+ isl::map Scale = isl::map::from_domain_and_range(
+ isl::set::universe(ArraySpace), isl::set::universe(ArraySpace));
+ for (auto i : seq<unsigned>(0, DimsArray - 1))
+ Scale = Scale.equate(isl::dim::in, i, isl::dim::out, i);
+
+ isl::local_space LS(Scale.get_space());
+ isl::constraint C = isl::constraint::alloc_equality(LS);
+ C = C.set_coefficient_si(isl::dim::in, DimsArray - 1,
+ ElemBytes / ArrayElemSize);
+ C = C.set_coefficient_si(isl::dim::out, DimsArray - 1, -1);
+ Scale = Scale.add_constraint(C);
----------------
bai-tim wrote:
Done
https://github.com/llvm/llvm-project/pull/221496
More information about the llvm-commits
mailing list