[polly] r275956 - GPGPU: generate control flow within the kernel
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 19 00:33:12 PDT 2016
Author: grosser
Date: Tue Jul 19 02:33:11 2016
New Revision: 275956
URL: http://llvm.org/viewvc/llvm-project?rev=275956&view=rev
Log:
GPGPU: generate control flow within the kernel
Modified:
polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
polly/trunk/test/GPGPU/double-parallel-loop.ll
polly/trunk/test/GPGPU/host-control-flow.ll
polly/trunk/test/GPGPU/kernel-params-scop-parameter.ll
Modified: polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp?rev=275956&r1=275955&r2=275956&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Tue Jul 19 02:33:11 2016
@@ -192,6 +192,8 @@ void GPUNodeBuilder::createKernel(__isl_
createKernelFunction(Kernel);
+ create(isl_ast_node_copy(Kernel->tree));
+
Builder.SetInsertPoint(&HostInsertPoint);
IDToValue = HostIDs;
@@ -304,8 +306,12 @@ void GPUNodeBuilder::createKernelFunctio
Function *FN = createKernelFunctionDecl(Kernel);
+ BasicBlock *PrevBlock = Builder.GetInsertBlock();
auto EntryBlock = BasicBlock::Create(Builder.getContext(), "entry", FN);
+ DominatorTree &DT = P->getAnalysis<DominatorTreeWrapperPass>().getDomTree();
+ DT.addNewBlock(EntryBlock, PrevBlock);
+
Builder.SetInsertPoint(EntryBlock);
Builder.CreateRetVoid();
Builder.SetInsertPoint(EntryBlock, EntryBlock->begin());
Modified: polly/trunk/test/GPGPU/double-parallel-loop.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/GPGPU/double-parallel-loop.ll?rev=275956&r1=275955&r2=275956&view=diff
==============================================================================
--- polly/trunk/test/GPGPU/double-parallel-loop.ll (original)
+++ polly/trunk/test/GPGPU/double-parallel-loop.ll Tue Jul 19 02:33:11 2016
@@ -93,7 +93,7 @@
; IR: polly.exiting:
; IR-NEXT: br label %polly.merge_new_and_old
-; KERNEL-IR: define ptx_kernel void @kernel_0(i8* %MemRef_A) {
+; KERNEL-IR-LABEL: define ptx_kernel void @kernel_0(i8* %MemRef_A) {
; KERNEL-IR-NEXT: entry:
; KERNEL-IR-NEXT: %0 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()
; KERNEL-IR-NEXT: %b0 = zext i32 %0 to i64
@@ -103,7 +103,19 @@
; KERNEL-IR-NEXT: %t0 = zext i32 %2 to i64
; KERNEL-IR-NEXT: %3 = call i32 @llvm.nvvm.read.ptx.sreg.tid.y()
; KERNEL-IR-NEXT: %t1 = zext i32 %3 to i64
+; KERNEL-IR-NEXT: br label %polly.loop_preheader
+
+; KERNEL-IR-LABEL: polly.loop_exit:
; KERNEL-IR-NEXT: ret void
+
+; KERNEL-IR-LABEL: polly.loop_header:
+; KERNEL-IR-NEXT: %polly.indvar = phi i64 [ 0, %polly.loop_preheader ], [ %polly.indvar_next, %polly.loop_header ]
+; KERNEL-IR-NEXT: %polly.indvar_next = add nsw i64 %polly.indvar, 1
+; KERNEL-IR-NEXT: %polly.loop_cond = icmp sle i64 %polly.indvar, 0
+; KERNEL-IR-NEXT: br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit
+
+; KERNEL-IR-LABEL: polly.loop_preheader:
+; KERNEL-IR-NEXT: br label %polly.loop_header
; KERNEL-IR-NEXT: }
; void double_parallel_loop(float A[][1024]) {
Modified: polly/trunk/test/GPGPU/host-control-flow.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/GPGPU/host-control-flow.ll?rev=275956&r1=275955&r2=275956&view=diff
==============================================================================
--- polly/trunk/test/GPGPU/host-control-flow.ll (original)
+++ polly/trunk/test/GPGPU/host-control-flow.ll Tue Jul 19 02:33:11 2016
@@ -34,13 +34,28 @@
; IR-NEXT: %polly.loop_cond = icmp sle i64 %polly.indvar, 98
; IR-NEXT: br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit
-; KERNEL-IR: define ptx_kernel void @kernel_0(i8* %MemRef_A, i64 %c0) {
+; KERNEL-IR-LABEL: define ptx_kernel void @kernel_0(i8* %MemRef_A, i64 %c0) {
; KERNEL-IR-NEXT: entry:
; KERNEL-IR-NEXT: %0 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()
; KERNEL-IR-NEXT: %b0 = zext i32 %0 to i64
; KERNEL-IR-NEXT: %1 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
; KERNEL-IR-NEXT: %t0 = zext i32 %1 to i64
+; KERNEL-IR-NEXT: br label %polly.cond
+
+; KERNEL-IR-LABEL: polly.cond:
+; KERNEL-IR-NEXT: %2 = mul nsw i64 32, %b0
+; KERNEL-IR-NEXT: %3 = add nsw i64 %2, %t0
+; KERNEL-IR-NEXT: %4 = icmp sle i64 %3, 97
+; KERNEL-IR-NEXT: br i1 %4, label %polly.then, label %polly.else
+
+; KERNEL-IR-LABEL: polly.merge:
; KERNEL-IR-NEXT: ret void
+
+; KERNEL-IR-LABEL: polly.then:
+; KERNEL-IR-NEXT: br label %polly.merge
+
+; KERNEL-IR-LABEL: polly.else:
+; KERNEL-IR-NEXT: br label %polly.merge
; KERNEL-IR-NEXT: }
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
Modified: polly/trunk/test/GPGPU/kernel-params-scop-parameter.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/GPGPU/kernel-params-scop-parameter.ll?rev=275956&r1=275955&r2=275956&view=diff
==============================================================================
--- polly/trunk/test/GPGPU/kernel-params-scop-parameter.ll (original)
+++ polly/trunk/test/GPGPU/kernel-params-scop-parameter.ll Tue Jul 19 02:33:11 2016
@@ -8,13 +8,6 @@
; }
; KERNEL-IR: define ptx_kernel void @kernel_0(i8* %MemRef_A, i64 %n) {
-; KERNEL-IR-NEXT: entry:
-; KERNEL-IR-NEXT: %0 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()
-; KERNEL-IR-NEXT: %b0 = zext i32 %0 to i64
-; KERNEL-IR-NEXT: %1 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
-; KERNEL-IR-NEXT: %t0 = zext i32 %1 to i64
-; KERNEL-IR-NEXT: ret void
-; KERNEL-IR-NEXT: }
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
More information about the llvm-commits
mailing list