[llvm-dev] valid BasicAA behavior?

Hiroshi Yamauchi via llvm-dev llvm-dev at lists.llvm.org
Tue Mar 17 08:37:34 PDT 2020


Perhaps BasicAA is telling that A and B don't alias during one particular
iteration of the loop even though they are swapped?

1:                                                ; preds = %0, %35
  %2 = phi double* [ getelementptr inbounds ([1000 x double], [1000 x
double]* @Ag, i64 0, i64 0), %0 ], [ %4, %35 ]
  %3 = phi i32 [ 0, %0 ], [ %36, %35 ]
  %4 = phi double* [ getelementptr inbounds ([1000 x double], [1000 x
double]* @Bg, i64 0, i64 0), %0 ], [ %2, %35 ]
  br label %5

https://godbolt.org/z/vHJmL5

On Mon, Mar 16, 2020 at 10:28 PM Chawla, Pankaj via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi all,
>
>
>
> I have this test case-
>
>
>
> #define N 1000
>
> extern double Ag[N];
>
> extern double Bg[N];
>
>
>
> void consume(double *A, double *B);
>
>
>
> void swap_deps() {
>
>   double *A = Ag;
>
>   double *B = Bg;
>
>
>
>   for (int i = 0; i < 97; ++i) {
>
>     for (int j = 0; j < N; ++j) {
>
>       B[j] = A[j] + 1;
>
>     }
>
>
>
>     double *tmp = A;
>
>     A = B;
>
>     B = tmp;
>
>   }
>
>
>
>   consume(A, B);
>
> }
>
>
>
> BasicAA is returning ‘NoAlias’ when queried for phis created in the i-loop
> for A and B.
>
> I was expecting it to return MayAlias since A and B are being swapped in
> the outer loop and so they access same locations in alternate iterations of
> the i-loop.
>
>
>
> Is BasicAA returning the correct result in this case?
>
>
>
> Thanks,
>
> Pankaj
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200317/1f854e55/attachment.html>


More information about the llvm-dev mailing list