llvm-project
92 строки · 2.6 Кб
1; RUN: opt %loadNPMPolly '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s
2
3target 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"
4
5; Two sequential loops right after each other.
6;
7; void f(long A[], long N) {
8; long i;
9; for (i = 0; i < N; ++i)
10; A[i] = i;
11; for (i = 0; i < N; ++i)
12; A[i] = i;
13; }
14
15define void @f1(ptr %A, i64 %N) nounwind {
16; CHECK-LABEL: Detected Scops in Function f1
17entry:
18fence seq_cst
19br label %for.i.1
20
21for.i.1:
22%indvar = phi i64 [ 0, %entry ], [ %indvar.next, %for.i.1 ]
23%scevgep = getelementptr i64, ptr %A, i64 %indvar
24store i64 %indvar, ptr %scevgep
25%indvar.next = add nsw i64 %indvar, 1
26%exitcond = icmp eq i64 %indvar.next, %N
27br i1 %exitcond, label %for.i.2, label %for.i.1
28
29for.i.2:
30%indvar.2 = phi i64 [ 0, %for.i.1 ], [ %indvar.next.2, %for.i.2 ]
31%scevgep.2 = getelementptr i64, ptr %A, i64 %indvar.2
32store i64 %indvar.2, ptr %scevgep.2
33%indvar.next.2 = add nsw i64 %indvar.2, 1
34%exitcond.2 = icmp eq i64 %indvar.next.2, %N
35br i1 %exitcond.2, label %return, label %for.i.2
36
37return:
38fence seq_cst
39ret void
40}
41
42; C-H-E-C-K: Valid Region for Scop: for.i.1 => return
43; This one is currently not completely detected due to the PHI node in
44; for.i.2 causing a 'PHI node in exit BB' error for the first loop. This should
45; be fixed at some point. Such test cases do not really show up for us, as
46; the -loop-simplify pass always inserts a preheader as in the test case below.
47
48; Two sequential loops with a basic block in between.
49;
50; void f(long A[], long N) {
51; long i;
52;
53; for (i = 0; i < N; ++i)
54; A[i] = i;
55; preheader:
56; ;
57;
58; for (i = 0; i < N; ++i)
59; A[i] = i;
60; }
61
62define void @f2(ptr %A, i64 %N) nounwind {
63; CHECK-LABEL: Detected Scops in Function f2
64entry:
65fence seq_cst
66br label %for.i.1
67
68for.i.1:
69%indvar = phi i64 [ 0, %entry ], [ %indvar.next, %for.i.1 ]
70%scevgep = getelementptr i64, ptr %A, i64 %indvar
71store i64 %indvar, ptr %scevgep
72%indvar.next = add nsw i64 %indvar, 1
73%exitcond = icmp eq i64 %indvar.next, %N
74br i1 %exitcond, label %preheader, label %for.i.1
75
76preheader:
77br label %for.i.2
78
79for.i.2:
80%indvar.2 = phi i64 [ 0, %preheader ], [ %indvar.next.2, %for.i.2 ]
81%scevgep.2 = getelementptr i64, ptr %A, i64 %indvar.2
82store i64 %indvar.2, ptr %scevgep.2
83%indvar.next.2 = add nsw i64 %indvar.2, 1
84%exitcond.2 = icmp eq i64 %indvar.next.2, %N
85br i1 %exitcond.2, label %return, label %for.i.2
86
87return:
88fence seq_cst
89ret void
90}
91
92; CHECK: Valid Region for Scop: for.i.1 => return
93