diff options
-rw-r--r-- | polly/lib/CodeGen/PPCGCodeGeneration.cpp | 8 | ||||
-rw-r--r-- | polly/test/GPGPU/scalar-param-and-value-32-bit.ll | 41 |
2 files changed, 47 insertions, 2 deletions
diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp index eb9836f77ec..d351e802ab2 100644 --- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp +++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp @@ -1161,8 +1161,12 @@ GPUNodeBuilder::createKernelFunctionDecl(ppcg_kernel *Kernel, int NumVars = isl_space_dim(Kernel->space, isl_dim_param); - for (long i = 0; i < NumVars; i++) - Args.push_back(Builder.getInt64Ty()); + for (long i = 0; i < NumVars; i++) { + isl_id *Id = isl_space_get_dim_id(Kernel->space, isl_dim_param, i); + Value *Val = IDToValue[Id]; + isl_id_free(Id); + Args.push_back(Val->getType()); + } for (auto *V : SubtreeValues) Args.push_back(V->getType()); diff --git a/polly/test/GPGPU/scalar-param-and-value-32-bit.ll b/polly/test/GPGPU/scalar-param-and-value-32-bit.ll new file mode 100644 index 00000000000..ffc6e676ae0 --- /dev/null +++ b/polly/test/GPGPU/scalar-param-and-value-32-bit.ll @@ -0,0 +1,41 @@ +; RUN: opt %loadPolly -polly-codegen-ppcg -polly-acc-dump-kernel-ir \ +; RUN: -disable-output < %s | \ +; RUN: FileCheck %s + +; REQUIRES: pollyacc +; +; void foo(float A[], int n) { +; for (long j = 0; j < n; j++) +; A[j + n] += 42; +; } + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +; CHECK: define ptx_kernel void @kernel_0(i8* %MemRef_A, i32 %n) + +define void @foo(float* %A, i32 %n) { +bb: + br label %bb1 + +bb1: ; preds = %bb9, %bb + %j.0 = phi i64 [ 0, %bb ], [ %tmp10, %bb9 ] + %tmp = sext i32 %n to i64 + %tmp2 = icmp slt i64 %j.0, %tmp + br i1 %tmp2, label %bb3, label %bb11 + +bb3: ; preds = %bb1 + %tmp4 = sext i32 %n to i64 + %tmp5 = add nsw i64 %j.0, %tmp4 + %tmp6 = getelementptr inbounds float, float* %A, i64 %tmp5 + %tmp7 = load float, float* %tmp6, align 4 + %tmp8 = fadd float %tmp7, 4.200000e+01 + store float %tmp8, float* %tmp6, align 4 + br label %bb9 + +bb9: ; preds = %bb3 + %tmp10 = add nuw nsw i64 %j.0, 1 + br label %bb1 + +bb11: ; preds = %bb1 + ret void +} |