[polly] r278026 - [GPGPU] Create code to verify run-time conditions
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 8 10:35:55 PDT 2016
Author: grosser
Date: Mon Aug 8 12:35:55 2016
New Revision: 278026
URL: http://llvm.org/viewvc/llvm-project?rev=278026&view=rev
Log:
[GPGPU] Create code to verify run-time conditions
Added:
polly/trunk/test/GPGPU/run-time-check.ll
Modified:
polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
Modified: polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp?rev=278026&r1=278025&r2=278026&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Mon Aug 8 12:35:55 2016
@@ -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();
Added: polly/trunk/test/GPGPU/run-time-check.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/GPGPU/run-time-check.ll?rev=278026&view=auto
==============================================================================
--- polly/trunk/test/GPGPU/run-time-check.ll (added)
+++ polly/trunk/test/GPGPU/run-time-check.ll Mon Aug 8 12:35:55 2016
@@ -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
+}
More information about the llvm-commits
mailing list