1; RUN: opt %loadPolly -polly-codegen-ppcg -polly-acc-dump-kernel-ir \
2; RUN: -disable-output < %s | \
3; RUN: FileCheck -check-prefix=KERNEL %s
4
5; RUN: opt %loadPolly -polly-codegen-ppcg \
6; RUN: -S < %s | \
7; RUN: FileCheck -check-prefix=IR %s
8
9; REQUIRES: pollyacc
10;
11;    void kernel_params_only_some_arrays(float A[], float B[]) {
12;      for (long i = 0; i < 32; i++)
13;        A[i] += 42;
14;
15;      for (long i = 0; i < 32; i++)
16;        B[i] += 42;
17;    }
18
19; KERNEL: ; ModuleID = 'FUNC_kernel_params_only_some_arrays_SCOP_0_KERNEL_0'
20; KERNEL-NEXT: source_filename = "FUNC_kernel_params_only_some_arrays_SCOP_0_KERNEL_0"
21; KERNEL-NEXT: target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-i128:128:128-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
22; KERNEL-NEXT: target triple = "nvptx64-nvidia-cuda"
23
24; KERNEL: define ptx_kernel void @FUNC_kernel_params_only_some_arrays_SCOP_0_KERNEL_0(i8 addrspace(1)* %MemRef_B)
25; KERNEL-NEXT:   entry:
26; KERNEL-NEXT:     %0 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()
27; KERNEL-NEXT:     %b0 = zext i32 %0 to i64
28; KERNEL-NEXT:     %1 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
29; KERNEL-NEXT:     %t0 = zext i32 %1 to i64
30
31; KERNEL:     ret void
32; KERNEL-NEXT: }
33
34; KERNEL: ; ModuleID = 'FUNC_kernel_params_only_some_arrays_SCOP_0_KERNEL_1'
35; KERNEL-NEXT: source_filename = "FUNC_kernel_params_only_some_arrays_SCOP_0_KERNEL_1"
36; KERNEL-NEXT: target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-i128:128:128-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
37; KERNEL-NEXT: target triple = "nvptx64-nvidia-cuda"
38
39; KERNEL: define ptx_kernel void @FUNC_kernel_params_only_some_arrays_SCOP_0_KERNEL_1(i8 addrspace(1)* %MemRef_A)
40; KERNEL-NEXT:   entry:
41; KERNEL-NEXT:     %0 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()
42; KERNEL-NEXT:     %b0 = zext i32 %0 to i64
43; KERNEL-NEXT:     %1 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
44; KERNEL-NEXT:     %t0 = zext i32 %1 to i64
45
46; KERNEL:     ret void
47; KERNEL-NEXT: }
48
49
50; IR:       [[DEVPTR:%.*]] = call i8* @polly_getDevicePtr(i8* %p_dev_array_MemRef_B)
51; IR-NEXT:  [[SLOT:%.*]] = getelementptr [1 x i8*], [1 x i8*]* %polly_launch_0_params, i64 0, i64 0
52; IR-NEXT:  store i8* [[DEVPTR]], i8** %polly_launch_0_param_0
53; IR-NEXT:  [[DATA:%.*]] = bitcast i8** %polly_launch_0_param_0 to i8*
54; IR-NEXT:  store i8* [[DATA]], i8** [[SLOT]]
55
56; IR:       [[DEVPTR:%.*]] = call i8* @polly_getDevicePtr(i8* %p_dev_array_MemRef_A)
57; IR-NEXT:  [[SLOT:%.*]] = getelementptr [1 x i8*], [1 x i8*]* %polly_launch_1_params, i64 0, i64 0
58; IR-NEXT:  store i8* [[DEVPTR]], i8** %polly_launch_1_param_0
59; IR-NEXT:  [[DATA:%.*]] = bitcast i8** %polly_launch_1_param_0 to i8*
60; IR-NEXT:  store i8* [[DATA]], i8** [[SLOT]]
61
62
63target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
64
65define void @kernel_params_only_some_arrays(float* %A, float* %B) {
66entry:
67  br label %for.cond
68
69for.cond:                                         ; preds = %for.inc, %entry
70  %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ]
71  %exitcond1 = icmp ne i64 %i.0, 32
72  br i1 %exitcond1, label %for.body, label %for.end
73
74for.body:                                         ; preds = %for.cond
75  %arrayidx = getelementptr inbounds float, float* %A, i64 %i.0
76  %tmp = load float, float* %arrayidx, align 4
77  %add = fadd float %tmp, 4.200000e+01
78  store float %add, float* %arrayidx, align 4
79  br label %for.inc
80
81for.inc:                                          ; preds = %for.body
82  %inc = add nuw nsw i64 %i.0, 1
83  br label %for.cond
84
85for.end:                                          ; preds = %for.cond
86  br label %for.cond2
87
88for.cond2:                                        ; preds = %for.inc7, %for.end
89  %i1.0 = phi i64 [ 0, %for.end ], [ %inc8, %for.inc7 ]
90  %exitcond = icmp ne i64 %i1.0, 32
91  br i1 %exitcond, label %for.body4, label %for.end9
92
93for.body4:                                        ; preds = %for.cond2
94  %arrayidx5 = getelementptr inbounds float, float* %B, i64 %i1.0
95  %tmp2 = load float, float* %arrayidx5, align 4
96  %add6 = fadd float %tmp2, 4.200000e+01
97  store float %add6, float* %arrayidx5, align 4
98  br label %for.inc7
99
100for.inc7:                                         ; preds = %for.body4
101  %inc8 = add nuw nsw i64 %i1.0, 1
102  br label %for.cond2
103
104for.end9:                                         ; preds = %for.cond2
105  ret void
106}
107