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 add(float *A) {
14;      for (long i = 0; i < 32; i++)
15;        for (long j = 0; j < 10; j++)
16;          A[i] += 1;
17;    }
18
19; CODE: # kernel0
20; CODE: {
21; CODE:   read(t0);
22; CODE:   sync0();
23; CODE:   for (int c3 = 0; c3 <= 9; c3 += 1)
24; CODE:     Stmt_bb5(t0, c3);
25; CODE:   sync1();
26; CODE:   write(t0);
27; CODE: }
28
29; KERNEL: @shared_MemRef_A = internal addrspace(3) global [32 x float] zeroinitializer, align 4
30
31; KERNEL:   %polly.access.shared_MemRef_A = getelementptr float, float addrspace(3)* getelementptr inbounds ([32 x float], [32 x float] addrspace(3)* @shared_MemRef_A, i32 0, i32 0), i64 %t0
32; KERNEL-NEXT:   %polly.access.cast.MemRef_A = bitcast i8 addrspace(1)* %MemRef_A to float addrspace(1)*
33; KERNEL-NEXT:   %polly.access.MemRef_A = getelementptr float, float addrspace(1)* %polly.access.cast.MemRef_A, i64 %t0
34; KERNEL-NEXT:   %shared.read = load float, float addrspace(1)* %polly.access.MemRef_A
35; KERNEL-NEXT:   store float %shared.read, float addrspace(3)* %polly.access.shared_MemRef_A
36
37; KERNEL:   %polly.access.shared_MemRef_A3 = getelementptr float, float addrspace(3)* getelementptr inbounds ([32 x float], [32 x float] addrspace(3)* @shared_MemRef_A, i32 0, i32 0), i64 %t0
38; KERNEL-NEXT:   %polly.access.cast.MemRef_A4 = bitcast i8 addrspace(1)* %MemRef_A to float addrspace(1)*
39; KERNEL-NEXT:   %polly.access.MemRef_A5 = getelementptr float, float addrspace(1)* %polly.access.cast.MemRef_A4, i64 %t0
40; KERNEL-NEXT:   %shared.write = load float, float addrspace(3)* %polly.access.shared_MemRef_A3
41; KERNEL-NEXT:   store float %shared.write, float addrspace(1)* %polly.access.MemRef_A5
42
43
44target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
45
46define void @add(float* %A) {
47bb:
48  br label %bb2
49
50bb2:                                              ; preds = %bb11, %bb
51  %i.0 = phi i64 [ 0, %bb ], [ %tmp12, %bb11 ]
52  %exitcond1 = icmp ne i64 %i.0, 32
53  br i1 %exitcond1, label %bb3, label %bb13
54
55bb3:                                              ; preds = %bb2
56  br label %bb4
57
58bb4:                                              ; preds = %bb8, %bb3
59  %j.0 = phi i64 [ 0, %bb3 ], [ %tmp9, %bb8 ]
60  %exitcond = icmp ne i64 %j.0, 10
61  br i1 %exitcond, label %bb5, label %bb10
62
63bb5:                                              ; preds = %bb4
64  %tmp = getelementptr inbounds float, float* %A, i64 %i.0
65  %tmp6 = load float, float* %tmp, align 4
66  %tmp7 = fadd float %tmp6, 1.000000e+00
67  store float %tmp7, float* %tmp, align 4
68  br label %bb8
69
70bb8:                                              ; preds = %bb5
71  %tmp9 = add nuw nsw i64 %j.0, 1
72  br label %bb4
73
74bb10:                                             ; preds = %bb4
75  br label %bb11
76
77bb11:                                             ; preds = %bb10
78  %tmp12 = add nuw nsw i64 %i.0, 1
79  br label %bb2
80
81bb13:                                             ; preds = %bb2
82  ret void
83}
84