[flang-commits] [flang] [mlir] [mlir][flang][acc] Preserve source array extents in data bounds` (PR #209618)

via flang-commits flang-commits at lists.llvm.org
Tue Jul 14 15:49:49 PDT 2026


khaki3 wrote:

```fortran
real :: a(100,100)
integer :: i, j

!$acc parallel loop collapse(2) copy(a)
do j = 20, 29
  do i = 3, 5
    a(i,j) = 1.0
  end do
end do
```

Before specialization, `copy(a)` maps the whole array:

```text
dim 0: lb=0, ub=99, extent=100, sourceExtent=100, stride=1
dim 1: lb=0, ub=99, extent=100, sourceExtent=100, stride=100
```

Specialization narrows the mapped bounds:

```text
dim 0: lb=2,  ub=4,  extent=3,  sourceExtent=100, stride=1
dim 1: lb=19, ub=28, extent=10, sourceExtent=100, stride=100
```

`extent` changes because it describes the selected range. Leaving `extent=100` with `lb=2, ub=4` would produce inconsistent bounds. `sourceExtent` remains unchanged because specialization does not change the source shape.

A stride cannot generally recover the source extent. A stride of `100` may represent 100 contiguous elements or 50 elements with spacing two. The final dimension also has no following stride from which its extent could be inferred. Therefore extent and stride represent independent information.

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


More information about the flang-commits mailing list