1; RUN: opt %loadPolly -polly-codegen-ppcg -polly-acc-dump-code \
2; RUN: -polly-acc-use-shared \
3; RUN: -disable-output < %s | \
4; RUN: FileCheck -check-prefix=CODE %s
5
6; RUN: opt %loadPolly -polly-codegen-ppcg \
7; RUN: -polly-acc-use-shared \
8; RUN: -disable-output -polly-acc-dump-kernel-ir < %s | \
9; RUN: FileCheck -check-prefix=KERNEL %s
10
11; REQUIRES: pollyacc
12
13;    void foo(float A[], float b[][8]) {
14;      for (long i = 0; i < 32; i++)
15;        for (long j = 0; j < 16; j++)
16;          for (long k = 0; k < 8; k++)
17;            A[i] += j * k * b[j][k];
18;    }
19
20
21; CODE:      # kernel0
22; CODE-NEXT: {
23; CODE-NEXT:   if (t0 <= 7)
24; CODE-NEXT:     for (int c0 = 0; c0 <= 15; c0 += 1)
25; CODE-NEXT:       read(c0, t0);
26; CODE-NEXT:   read(t0);
27; CODE-NEXT:   sync0();
28; CODE-NEXT:   for (int c3 = 0; c3 <= 15; c3 += 1)
29; CODE-NEXT:     for (int c4 = 0; c4 <= 7; c4 += 1)
30; CODE-NEXT:       Stmt_bb8(t0, c3, c4);
31; CODE-NEXT:   sync1();
32; CODE-NEXT:   write(t0);
33; CODE-NEXT: }
34
35; KERNEL: @shared_MemRef_b = internal addrspace(3) global [16 x [8 x float]] zeroinitializer, align 4
36
37; KERNEL:        %polly.access.mul.MemRef_b = mul nsw i64 %polly.indvar, 8
38; KERNEL-NEXT:   %polly.access.add.MemRef_b = add nsw i64 %polly.access.mul.MemRef_b, %t0
39; KERNEL-NEXT:   %polly.access.MemRef_b = getelementptr float, float addrspace(1)* %polly.access.cast.MemRef_b, i64 %polly.access.add.MemRef_b
40; KERNEL-NEXT:   %shared.read = load float, float addrspace(1)* %polly.access.MemRef_b
41; KERNEL-NEXT:   store float %shared.read, float addrspace(3)* %polly.access.shared_MemRef_b
42
43
44target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
45
46define void @foo(float* %A, [8 x float]* %b) {
47bb:
48  br label %bb3
49
50bb3:                                              ; preds = %bb22, %bb
51  %i.0 = phi i64 [ 0, %bb ], [ %tmp23, %bb22 ]
52  %exitcond2 = icmp ne i64 %i.0, 32
53  br i1 %exitcond2, label %bb4, label %bb24
54
55bb4:                                              ; preds = %bb3
56  br label %bb5
57
58bb5:                                              ; preds = %bb19, %bb4
59  %j.0 = phi i64 [ 0, %bb4 ], [ %tmp20, %bb19 ]
60  %exitcond1 = icmp ne i64 %j.0, 16
61  br i1 %exitcond1, label %bb6, label %bb21
62
63bb6:                                              ; preds = %bb5
64  br label %bb7
65
66bb7:                                              ; preds = %bb16, %bb6
67  %k.0 = phi i64 [ 0, %bb6 ], [ %tmp17, %bb16 ]
68  %exitcond = icmp ne i64 %k.0, 8
69  br i1 %exitcond, label %bb8, label %bb18
70
71bb8:                                              ; preds = %bb7
72  %tmp = mul nuw nsw i64 %j.0, %k.0
73  %tmp9 = sitofp i64 %tmp to float
74  %tmp10 = getelementptr inbounds [8 x float], [8 x float]* %b, i64 %j.0, i64 %k.0
75  %tmp11 = load float, float* %tmp10, align 4
76  %tmp12 = fmul float %tmp9, %tmp11
77  %tmp13 = getelementptr inbounds float, float* %A, i64 %i.0
78  %tmp14 = load float, float* %tmp13, align 4
79  %tmp15 = fadd float %tmp14, %tmp12
80  store float %tmp15, float* %tmp13, align 4
81  br label %bb16
82
83bb16:                                             ; preds = %bb8
84  %tmp17 = add nuw nsw i64 %k.0, 1
85  br label %bb7
86
87bb18:                                             ; preds = %bb7
88  br label %bb19
89
90bb19:                                             ; preds = %bb18
91  %tmp20 = add nuw nsw i64 %j.0, 1
92  br label %bb5
93
94bb21:                                             ; preds = %bb5
95  br label %bb22
96
97bb22:                                             ; preds = %bb21
98  %tmp23 = add nuw nsw i64 %i.0, 1
99  br label %bb3
100
101bb24:                                             ; preds = %bb3
102  ret void
103}
104