| Issue |
233372
|
| Summary |
[flang] Loops over local POINTER arrays don't vectorize
|
| Labels |
flang
|
| Assignees |
Ritanya-B-Bharadwaj
|
| Reporter |
Ritanya-B-Bharadwaj
|
Loops over POINTER arrays that aren't dummy arguments (locals, derived type components, module variables) don't vectorize because the stride isn't known.
```fortran
subroutine s(a, b, n)
integer :: n, i
real(8), target :: a(:), b(:)
real(8), pointer :: p(:), q(:)
p => a
q => b
do i = 1, n
p(i) = p(i) + q(i)
end do
end subroutine
```
```
$ flang -O3 -Rpass-missed=loop-vectorize -Rpass-analysis=loop-vectorize -c s.f90
s.f90:8:5: remark: loop not vectorized: unsafe dependent memory operations in loop. ...
s.f90:7:3: remark: loop not vectorized [-Rpass-missed=loop-vectorize]
```
Seen on main at [627b8cf](https://github.com/llvm/llvm-project/commit/627b8cf3d4b1f7e572440fbdd45ae2bcf15516cb). The loop vectorizes if p and q are declared contiguous.
LoopVersioning could handle this, but it only looks at dummy arguments, and the descriptor loads of p and q are still inside the loop when it runs (flang-licm hoists them later in the pipeline). I have a patch that runs flang-licm before LoopVersioning and lets LoopVersioning version POINTER descriptors that aren't arguments.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs