[flang-commits] [flang] [flang] AliasAnalysis: Handle fir.load on fir.alloca (PR #117785)

Joel E. Denny via flang-commits flang-commits at lists.llvm.org
Thu Feb 20 11:33:20 PST 2025


jdenny-ornl wrote:

> @jdenny-ornl After this commit, [a test which uses Cray pointer](https://github.com/fujitsu/compiler-test-suite/blob/main/Fortran/0734/0734_0018.f90) fails. Could you take a look?

I don't have experience working with cray pointers or forall loops in fortran.  However, what I've read suggests the above test is invalid, and so the result is undefined.

Specifically, the test has:

```
pointer (j,x)
j=loc(a(2))
forall (i=1:3)
 x(i)=a(i)+1
end forall
```

Because `x(i)` is an alias for `a(i+1)`, the forall body performs `a(i+1)=a(i)+1`.  From what I've read, in order to enable optimizations, forall doesn't permit this kind of data dependency among iterations.

Furthermore, on my test system, both gfortran 11.4.0 and 13.2.0 produce the same result for this test as flang does with this PR merged.

Let me know if you believe flang's previous behavior for this test is the only correct behavior.

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


More information about the flang-commits mailing list