xref: /llvm-project/polly/test/ScopInfo/mod_ref_read_pointee_arguments.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa -polly-stmt-granularity=bb '-passes=print<polly-function-scops>' -polly-allow-modref-calls \
2; RUN:     -disable-output < %s 2>&1 | FileCheck %s
3; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa -passes=polly-codegen -disable-output \
4; RUN:     -polly-allow-modref-calls < %s
5;
6; Verify that we model the read access of the gcread intrinsic
7; correctly, thus that A is read by it but B is not.
8;
9; CHECK:      Stmt_for_body
10; CHECK-NEXT:   Domain :=
11; CHECK-NEXT:       { Stmt_for_body[i0] : 0 <= i0 <= 1023 };
12; CHECK-NEXT:   Schedule :=
13; CHECK-NEXT:       { Stmt_for_body[i0] -> [i0] };
14; CHECK-NEXT:   ReadAccess := [Reduction Type: NONE]
15; CHECK-NEXT:       { Stmt_for_body[i0] -> MemRef_A[o0] };
16; CHECK-NEXT:   MustWriteAccess :=  [Reduction Type: NONE]
17; CHECK-NEXT:       { Stmt_for_body[i0] -> MemRef_dummyloc[0] };
18; CHECK-NEXT:   ReadAccess := [Reduction Type: NONE]
19; CHECK-NEXT:       { Stmt_for_body[i0] -> MemRef_B[i0] };
20; CHECK-NEXT:   MustWriteAccess :=  [Reduction Type: NONE]
21; CHECK-NEXT:       { Stmt_for_body[i0] -> MemRef_A[i0] };
22;
23;    void jd(int *restirct A, int *restrict B) {
24;      char **dummyloc;
25;      for (int i = 0; i < 1024; i++) {
26;        char *dummy = @llvm.gcread(A, nullptr);
27;        *dummyloc = dummy;
28;        A[i] = B[i];
29;      }
30;    }
31;
32target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
33
34define void @jd(ptr noalias %A, ptr noalias %B) gc "dummy" {
35entry:
36  %dummyloc = alloca ptr
37  br label %entry.split
38
39entry.split:					  ; preds = %entry
40  br label %for.body
41
42for.body:                                         ; preds = %entry.split, %for.inc
43  %i = phi i64 [ 0, %entry.split ], [ %i.next, %for.inc ]
44  %arrayidx = getelementptr inbounds i32, ptr %A, i64 %i
45  %arrayidx1 = getelementptr inbounds i32, ptr %B, i64 %i
46  %dummy = call ptr @f(ptr %arrayidx, ptr null)
47  store ptr %dummy, ptr %dummyloc, align 4
48  %tmp = load i32, ptr %arrayidx1
49  store i32 %tmp, ptr %arrayidx, align 4
50  br label %for.inc
51
52for.inc:                                          ; preds = %for.body
53  %i.next = add nuw nsw i64 %i, 1
54  %exitcond = icmp ne i64 %i.next, 1024
55  br i1 %exitcond, label %for.body, label %for.end
56
57for.end:                                          ; preds = %for.inc
58  ret void
59}
60
61declare ptr @f(ptr, ptr) #0
62
63attributes #0 = { argmemonly readonly nounwind }
64