llvm-project
50 строк · 1.5 Кб
1; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s -check-prefix=PHI
2
3; void f(long A[], long N, long *init_ptr) {
4; long i, j;
5; long i_non_canonical;
6;
7; for (i = 0; i < N; ++i) {
8; init = *init_ptr;
9; i_non_canonical = init;
10; for (i = 0; i < N; ++i) {
11; A[i] = i_non_canonical;
12; i_non_canonical += 1;
13; }
14; }
15; }
16
17target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
18
19define void @f(ptr noalias %A, i64 %N, ptr noalias %init_ptr) nounwind {
20entry:
21br label %for.i
22
23for.i:
24%indvar.i = phi i64 [ 0, %entry ], [ %indvar.i.next, %for.i.end ]
25%indvar.i.next = add nsw i64 %indvar.i, 1
26br label %entry.next
27
28entry.next:
29%init = load i64, ptr %init_ptr
30br label %for.j
31
32for.j:
33%indvar.j = phi i64 [ 0, %entry.next ], [ %indvar.j.next, %for.j ]
34%indvar.j.non_canonical = phi i64 [ %init, %entry.next ], [ %indvar.j.non_canonical.next, %for.j ]
35%scevgep = getelementptr i64, ptr %A, i64 %indvar.j
36store i64 %indvar.j.non_canonical, ptr %scevgep
37%indvar.j.next = add nsw i64 %indvar.j, 1
38%indvar.j.non_canonical.next = add nsw i64 %indvar.j.non_canonical, 1
39%exitcond.j = icmp eq i64 %indvar.j.next, %N
40br i1 %exitcond.j, label %for.i.end, label %for.j
41
42for.i.end:
43%exitcond.i = icmp eq i64 %indvar.i.next, %N
44br i1 %exitcond.i, label %return, label %for.i
45
46return:
47ret void
48}
49
50; PHI: Valid Region for Scop: for.i => return
51