xref: /llvm-project/polly/test/ScopDetect/mod_ref_read_pointer.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa -polly-allow-modref-calls '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s -check-prefix=MODREF
2; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa                           '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s
3;
4; CHECK-NOT: Valid Region for Scop: for.body => for.end
5; MODREF: Valid Region for Scop: for.body => for.end
6;
7;    #pragma readonly
8;    int func(int *A);
9;
10;    void jd(int *A) {
11;      for (int i = 0; i < 1024; i++)
12;        A[i + 2] = func(A);
13;    }
14;
15target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
16
17declare i32 @func(ptr %A) #1
18
19define void @jd(ptr %A) {
20entry:
21  br label %for.body
22
23for.body:                                         ; preds = %entry, %for.inc
24  %i = phi i64 [ 0, %entry ], [ %i.next, %for.inc ]
25  %call = call i32 @func(ptr %A)
26  %tmp = add nsw i64 %i, 2
27  %arrayidx = getelementptr inbounds i32, ptr %A, i64 %tmp
28  store i32 %call, ptr %arrayidx, align 4
29  br label %for.inc
30
31for.inc:                                          ; preds = %for.body
32  %i.next = add nuw nsw i64 %i, 1
33  %exitcond = icmp ne i64 %i.next, 1024
34  br i1 %exitcond, label %for.body, label %for.end
35
36for.end:                                          ; preds = %for.inc
37  ret void
38}
39
40attributes #1 = { nounwind readonly }
41