diff options
| author | Tobias Grosser <tobias@grosser.es> | 2016-08-08 17:35:55 +0000 |
|---|---|---|
| committer | Tobias Grosser <tobias@grosser.es> | 2016-08-08 17:35:55 +0000 |
| commit | cb1aef8de4abe60c75f154aa9d7100a36064e9c2 (patch) | |
| tree | ac44dfd2552a7e39812158de80f89aeee78dcf9b | |
| parent | fa9abd1f03c74e172c3de5899b4d889228588225 (diff) | |
| download | bcm5719-llvm-cb1aef8de4abe60c75f154aa9d7100a36064e9c2.tar.gz bcm5719-llvm-cb1aef8de4abe60c75f154aa9d7100a36064e9c2.zip | |
[GPGPU] Create code to verify run-time conditions
llvm-svn: 278026
| -rw-r--r-- | polly/lib/CodeGen/PPCGCodeGeneration.cpp | 10 | ||||
| -rw-r--r-- | polly/test/GPGPU/run-time-check.ll | 58 |
2 files changed, 67 insertions, 1 deletions
diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp index fa37f097f4c..9d851d1b967 100644 --- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp +++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#include "polly/CodeGen/IslAst.h" #include "polly/CodeGen/IslNodeBuilder.h" #include "polly/CodeGen/Utils.h" #include "polly/DependenceInfo.h" @@ -2038,10 +2039,17 @@ public: executeScopConditionally(*S, this, Builder.getTrue()); // TODO: Handle LICM - // TODO: Verify run-time checks auto SplitBlock = StartBlock->getSinglePredecessor(); Builder.SetInsertPoint(SplitBlock->getTerminator()); NodeBuilder.addParameters(S->getContext()); + + isl_ast_build *Build = isl_ast_build_alloc(S->getIslCtx()); + isl_ast_expr *Condition = IslAst::buildRunCondition(S, Build); + isl_ast_build_free(Build); + + Value *RTC = NodeBuilder.createRTC(Condition); + Builder.GetInsertBlock()->getTerminator()->setOperand(0, RTC); + Builder.SetInsertPoint(&*StartBlock->begin()); NodeBuilder.initializeAfterRTH(); diff --git a/polly/test/GPGPU/run-time-check.ll b/polly/test/GPGPU/run-time-check.ll new file mode 100644 index 00000000000..eb20867e79e --- /dev/null +++ b/polly/test/GPGPU/run-time-check.ll @@ -0,0 +1,58 @@ +; RUN: opt %loadPolly -polly-codegen-ppcg -S < %s | \ +; RUN: FileCheck %s -check-prefix=IR +; +; REQUIRES: pollyacc +; +; void foo(long n, float A[][32]) { +; for (long i = 0; i < n; i++) +; for (long j = 0; j < n; j++) +; A[i][j] += A[i + 1][j + 1]; +; } + +; IR: %tmp = icmp slt i64 %i.0, %n +; IR-NEXT: br i1 %tmp, label %bb2, label %polly.merge_new_and_old + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +define void @foo(i64 %n, [32 x float]* %A) { +bb: + br label %bb1 + +bb1: ; preds = %bb15, %bb + %i.0 = phi i64 [ 0, %bb ], [ %tmp16, %bb15 ] + %tmp = icmp slt i64 %i.0, %n + br i1 %tmp, label %bb2, label %bb17 + +bb2: ; preds = %bb1 + br label %bb3 + +bb3: ; preds = %bb12, %bb2 + %j.0 = phi i64 [ 0, %bb2 ], [ %tmp13, %bb12 ] + %exitcond = icmp ne i64 %j.0, %n + br i1 %exitcond, label %bb4, label %bb14 + +bb4: ; preds = %bb3 + %tmp5 = add nuw nsw i64 %j.0, 1 + %tmp6 = add nuw nsw i64 %i.0, 1 + %tmp7 = getelementptr inbounds [32 x float], [32 x float]* %A, i64 %tmp6, i64 %tmp5 + %tmp8 = load float, float* %tmp7, align 4 + %tmp9 = getelementptr inbounds [32 x float], [32 x float]* %A, i64 %i.0, i64 %j.0 + %tmp10 = load float, float* %tmp9, align 4 + %tmp11 = fadd float %tmp10, %tmp8 + store float %tmp11, float* %tmp9, align 4 + br label %bb12 + +bb12: ; preds = %bb4 + %tmp13 = add nuw nsw i64 %j.0, 1 + br label %bb3 + +bb14: ; preds = %bb3 + br label %bb15 + +bb15: ; preds = %bb14 + %tmp16 = add nuw nsw i64 %i.0, 1 + br label %bb1 + +bb17: ; preds = %bb1 + ret void +} |

