kasuga-fj wrote:

There is still a correctness issue with LoopInterchange, as I reported in 
#140238. This problem is not specific to C/C++. The following code demonstrates 
a case where illegal loop-interchange occurs.

```fortran
program main
    implicit none
    real, save :: A(5, 5)
    real, target :: V(16), W(16)
    real, pointer :: X(:, :) => null(), Y(:, :) => null()
    integer :: i, j

    do i = 0, 15
        A(i / 4 + 1, mod(i, 4) + 1) = real(i)
        V(i + 1) = real(i + i)
        W(i + 1) = real(i * i)
    end do

    X(1:4, 1:4) => V(:)
    if (A(2, 2) < A(3, 3)) then
            Y(1:4, 1:4) => V(:)
    else
            Y(1:4, 1:4) => W(:)
    endif

    ! Illegal interchange occurs
    do j = 1, 4
        do i = 1, 4
            X(i, j) = Y(j, i)
            A(i + 1, j) = A(i, j) + 1
        end do
    end do

    print *, X
end program main
```

godbolt: https://godbolt.org/z/db5qaab1T 

This issue should be resolved by #140709.

https://github.com/llvm/llvm-project/pull/140182
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to