• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-import-jscop-postfix=transformed -polly-import-jscop -analyze          < %s | FileCheck %s
2; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-import-jscop-postfix=transformed -polly-import-jscop -polly-codegen -S < %s | FileCheck %s --check-prefix=CODEGEN
3
4define void @map_scalar_access(double* noalias nonnull %A) {
5entry:
6  br label %outer.for
7
8outer.for:
9  %j = phi i32 [0, %entry], [%j.inc, %outer.inc]
10  %j.cmp = icmp slt i32 %j, 1
11  br i1 %j.cmp, label %reduction.for, label %outer.exit
12
13
14    reduction.for:
15      %i = phi i32 [0, %outer.for], [%i.inc, %reduction.inc]
16      %phi = phi double [0.0, %outer.for], [%add, %reduction.inc]
17      %i.cmp = icmp slt i32 %i, 4
18      br i1 %i.cmp, label %body, label %reduction.exit
19
20    body:
21      %add = fadd double %phi, 4.2
22      br label %reduction.inc
23
24    reduction.inc:
25      %i.inc = add nuw nsw i32 %i, 1
26      br label %reduction.for
27
28    reduction.exit:
29      %A_idx = getelementptr inbounds double, double* %A, i32 %j
30      store double %phi, double* %A_idx
31      br label %outer.inc
32
33
34outer.inc:
35  %j.inc = add nuw nsw i32 %j, 1
36  br label %outer.for
37
38outer.exit:
39  br label %return
40
41return:
42  ret void
43}
44
45
46
47; CHECK:          Arrays {
48; CHECK-NEXT:         double MemRef_phi__phi; // Element size 8
49; CHECK-NEXT:         double MemRef_phi; // Element size 8
50; CHECK-NEXT:         double MemRef_add; // Element size 8
51; CHECK-NEXT:         double MemRef_A[*]; // Element size 8
52; CHECK-NEXT:     }
53; CHECK:          Statements {
54; CHECK-NEXT:         Stmt_outer_for
55; CHECK-NEXT:             Domain :=
56; CHECK-NEXT:                 { Stmt_outer_for[i0] : 0 <= i0 <= 1 };
57; CHECK-NEXT:             Schedule :=
58; CHECK-NEXT:                 { Stmt_outer_for[i0] -> [i0, 0, 0, 0] };
59; CHECK-NEXT:             MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 1]
60; CHECK-NEXT:                 { Stmt_outer_for[i0] -> MemRef_phi__phi[] };
61; CHECK-NEXT:            new: { Stmt_outer_for[i0] -> MemRef_A[i0] };
62; CHECK-NEXT:         Stmt_reduction_for
63; CHECK-NEXT:             Domain :=
64; CHECK-NEXT:                 { Stmt_reduction_for[0, i1] : 0 <= i1 <= 4 };
65; CHECK-NEXT:             Schedule :=
66; CHECK-NEXT:                 { Stmt_reduction_for[i0, i1] -> [0, 1, i1, 0] };
67; CHECK-NEXT:             ReadAccess :=    [Reduction Type: NONE] [Scalar: 1]
68; CHECK-NEXT:                 { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
69; CHECK-NEXT:            new: { Stmt_reduction_for[i0, i1] -> MemRef_A[0] };
70; CHECK-NEXT:             MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 1]
71; CHECK-NEXT:                 { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
72; CHECK-NEXT:            new: { Stmt_reduction_for[i0, i1] -> MemRef_A[0] };
73; CHECK-NEXT:         Stmt_body
74; CHECK-NEXT:             Domain :=
75; CHECK-NEXT:                 { Stmt_body[0, i1] : 0 <= i1 <= 3 };
76; CHECK-NEXT:             Schedule :=
77; CHECK-NEXT:                 { Stmt_body[i0, i1] -> [0, 1, i1, 1] };
78; CHECK-NEXT:             MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 1]
79; CHECK-NEXT:                 { Stmt_body[i0, i1] -> MemRef_add[] };
80; CHECK-NEXT:            new: { Stmt_body[i0, i1] -> MemRef_A[0] };
81; CHECK-NEXT:             ReadAccess :=    [Reduction Type: NONE] [Scalar: 1]
82; CHECK-NEXT:                 { Stmt_body[i0, i1] -> MemRef_phi[] };
83; CHECK-NEXT:            new: { Stmt_body[i0, i1] -> MemRef_A[0] };
84; CHECK-NEXT:         Stmt_reduction_inc
85; CHECK-NEXT:             Domain :=
86; CHECK-NEXT:                 { Stmt_reduction_inc[0, i1] : 0 <= i1 <= 3 };
87; CHECK-NEXT:             Schedule :=
88; CHECK-NEXT:                 { Stmt_reduction_inc[i0, i1] -> [0, 1, i1, 2] };
89; CHECK-NEXT:             ReadAccess :=    [Reduction Type: NONE] [Scalar: 1]
90; CHECK-NEXT:                 { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
91; CHECK-NEXT:            new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[0] };
92; CHECK-NEXT:             MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 1]
93; CHECK-NEXT:                 { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
94; CHECK-NEXT:            new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[0] };
95; CHECK-NEXT:         Stmt_reduction_exit
96; CHECK-NEXT:             Domain :=
97; CHECK-NEXT:                 { Stmt_reduction_exit[0] };
98; CHECK-NEXT:             Schedule :=
99; CHECK-NEXT:                 { Stmt_reduction_exit[i0] -> [0, 2, 0, 0] };
100; CHECK-NEXT:             MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
101; CHECK-NEXT:                 { Stmt_reduction_exit[i0] -> MemRef_A[0] };
102; CHECK-NEXT:            new: { Stmt_reduction_exit[i0] -> MemRef_A[0] };
103; CHECK-NEXT:             ReadAccess :=    [Reduction Type: NONE] [Scalar: 1]
104; CHECK-NEXT:                 { Stmt_reduction_exit[i0] -> MemRef_phi[] };
105; CHECK-NEXT:            new: { Stmt_reduction_exit[i0] -> MemRef_A[0] };
106; CHECK-NEXT:     }
107; CHECK:      New access function '{ Stmt_outer_for[i0] -> MemRef_A[i0] }' detected in JSCOP file
108; CHECK-NEXT: New access function '{ Stmt_reduction_for[i0, i1] -> MemRef_A[i0] }' detected in JSCOP file
109; CHECK-NEXT: New access function '{ Stmt_reduction_for[i0, i1] -> MemRef_A[i0] }' detected in JSCOP file
110; CHECK-NEXT: New access function '{ Stmt_body[i0, i1] -> MemRef_A[i0] }' detected in JSCOP file
111; CHECK-NEXT: New access function '{ Stmt_body[i0, i1] -> MemRef_A[i0] }' detected in JSCOP file
112; CHECK-NEXT: New access function '{ Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] }' detected in JSCOP file
113; CHECK-NEXT: New access function '{ Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] }' detected in JSCOP file
114; CHECK-NEXT: New access function '{ Stmt_reduction_exit[i0] -> MemRef_A[i0] }' detected in JSCOP file
115; CHECK-NEXT: New access function '{ Stmt_reduction_exit[i0] -> MemRef_A[i0] }' detected in JSCOP file
116
117; CODEGEN:      polly.stmt.outer.for:
118; CODEGEN-NEXT:   %polly.access.A[[R0:[0-9]*]] = getelementptr double, double* %A, i64 %polly.indvar
119; CODEGEN-NEXT:   store double 0.000000e+00, double* %polly.access.A[[R0]]
120; CODEGEN-NEXT:   br label %polly.cond
121
122; CODEGEN:      polly.stmt.reduction.exit:
123; CODEGEN-NEXT:   %polly.access.A[[R1:[0-9]*]] = getelementptr double, double* %A, i64 0
124; CODEGEN-NEXT:   %polly.access.A[[R1]].reload = load double, double* %polly.access.A[[R1]]
125; CODEGEN-NEXT:   %polly.access.A[[R2:[0-9]*]] = getelementptr double, double* %A, i64 0
126; CODEGEN-NEXT:   store double %polly.access.A[[R1]].reload, double* %polly.access.A[[R2]]
127; CODEGEN-NEXT:   br label %polly.merge
128
129; CODEGEN:      polly.stmt.reduction.for:
130; CODEGEN-NEXT:   %polly.access.A[[R3:[0-9]*]] = getelementptr double, double* %A, i64 0
131; CODEGEN-NEXT:   %polly.access.A[[R3]].reload = load double, double* %polly.access.A[[R3]]
132; CODEGEN-NEXT:   %polly.access.A[[R4:[0-9]*]] = getelementptr double, double* %A, i64 0
133; CODEGEN-NEXT:   store double %polly.access.A[[R3]].reload, double* %polly.access.A[[R4]]
134; CODEGEN-NEXT:   br label %polly.cond9
135
136; CODEGEN:      polly.stmt.body:
137; CODEGEN-NEXT:   %polly.access.A[[R5:[0-9]*]] = getelementptr double, double* %A, i64 0
138; CODEGEN-NEXT:   %polly.access.A[[R5]].reload = load double, double* %polly.access.A[[R5]]
139; CODEGEN-NEXT:   %p_add = fadd double %polly.access.A13.reload, 4.200000e+00
140; CODEGEN-NEXT:   %polly.access.A[[R6:[0-9]*]] = getelementptr double, double* %A, i64 0
141; CODEGEN-NEXT:   store double %p_add, double* %polly.access.A[[R6]]
142; CODEGEN-NEXT:   br label %polly.stmt.reduction.inc
143
144; CODEGEN:      polly.stmt.reduction.inc:
145; CODEGEN-NEXT:   %polly.access.A[[R7:[0-9]*]] = getelementptr double, double* %A, i64 0
146; CODEGEN-NEXT:   %polly.access.A[[R7]].reload = load double, double* %polly.access.A[[R7]]
147; CODEGEN-NEXT:   %polly.access.A[[R8:[0-9]*]] = getelementptr double, double* %A, i64 0
148; CODEGEN-NEXT:   store double %polly.access.A[[R7]].reload, double* %polly.access.A[[R8]]
149; CODEGEN-NEXT:   br label %polly.merge10
150