[llvm-commits] [polly] r136789 - in /polly/trunk: include/polly/ScopInfo.h lib/CodeGeneration.cpp test/CodeGen/MemAccess/memaccess_codegen_simple.c test/CodeGen/MemAccess/memaccess_codegen_simple.ll test/CodeGen/MemAccess/memaccess_codegen_simple___%for.cond---%for.end.jscop test/CodeGen/MemAccess/memaccess_codegen_simple___%for.cond---%for.end.jscop.transformed
Raghesh Aloor
raghesh.a at gmail.com
Wed Aug 3 10:02:50 PDT 2011
Author: raghesh
Date: Wed Aug 3 12:02:50 2011
New Revision: 136789
URL: http://llvm.org/viewvc/llvm-project?rev=136789&view=rev
Log:
Memaccess: Codegeneration for a simple access function change
Code is generated for a simple access function change imported
from JSCOP file. An access of A[i] is changed to A[0]. The code
for A[0] is generated directly without refering to isl function calls.
Added:
polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple.c
polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple.ll
polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple___%for.cond---%for.end.jscop
polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple___%for.cond---%for.end.jscop.transformed
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/CodeGeneration.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=136789&r1=136788&r2=136789&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Wed Aug 3 12:02:50 2011
@@ -130,6 +130,11 @@
return BaseName;
}
+ /// @brief Get the new access function imported from JSCOP file
+ isl_map *getNewAccessFunction() {
+ return newAccessRelation;
+ }
+
/// @brief Get the stride of this memory access in the specified domain
/// subset.
isl_set *getStride(const isl_set *domainSubset) const;
Modified: polly/trunk/lib/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=136789&r1=136788&r2=136789&view=diff
==============================================================================
--- polly/trunk/lib/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGeneration.cpp Wed Aug 3 12:02:50 2011
@@ -314,9 +314,36 @@
return vector;
}
+ /// @brief Get the new operand address according to the changed access in
+ /// JSCOP file.
+ Value *getNewAccessOperand(isl_map *newAccessRelation, Value *baseAddr,
+ const Value *OldOperand, ValueMapT &BBMap) {
+ unsigned accessIdx = 0;
+ Value *newOperand = Builder.CreateStructGEP(baseAddr,
+ accessIdx, "p_newarrayidx_");
+ return newOperand;
+ }
+
+ /// @brief Generate the operand address
+ Value *generateLocationAccessed(const Instruction *Inst,
+ const Value *pointer, ValueMapT &BBMap ) {
+ MemoryAccess &Access = statement.getAccessFor(Inst);
+ isl_map *newAccessRelation = Access.getNewAccessFunction();
+ if (!newAccessRelation) {
+ Value *newPointer = getOperand(pointer, BBMap);
+ return newPointer;
+ }
+
+ Value *baseAddr = const_cast<Value*>(Access.getBaseAddr());
+ Value *newPointer = getNewAccessOperand(newAccessRelation, baseAddr,
+ pointer, BBMap);
+ return newPointer;
+ }
+
Value *generateScalarLoad(const LoadInst *load, ValueMapT &BBMap) {
const Value *pointer = load->getPointerOperand();
- Value *newPointer = getOperand(pointer, BBMap);
+ const Instruction *Inst = dyn_cast<Instruction>(load);
+ Value *newPointer = generateLocationAccessed(Inst, pointer, BBMap);
Value *scalarLoad = Builder.CreateLoad(newPointer,
load->getNameStr() + "_p_scalar_");
return scalarLoad;
Added: polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple.c?rev=136789&view=auto
==============================================================================
--- polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple.c (added)
+++ polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple.c Wed Aug 3 12:02:50 2011
@@ -0,0 +1,8 @@
+int A[100];
+
+int memaccess_codegen_simple () {
+ for (int i = 0; i < 12; i++)
+ A[13] = A[i] + A[i-1];
+
+ return 0;
+}
Added: polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple.ll?rev=136789&view=auto
==============================================================================
--- polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple.ll (added)
+++ polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple.ll Wed Aug 3 12:02:50 2011
@@ -0,0 +1,34 @@
+;RUN: opt %loadPolly -polly-import-jscop -polly-import-jscop-dir=`dirname %s` -polly-import-jscop-postfix=transformed -polly-codegen -instnamer %s -S | FileCheck %s
+; ModuleID = 'memaccess_codegen_simple.ll'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
+target triple = "i386-pc-linux-gnu"
+
+ at A = common global [100 x i32] zeroinitializer, align 4
+
+define i32 @memaccess_codegen_simple() nounwind {
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+ %tmp1 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
+ %tmp = add i32 %tmp1, -1
+ %arrayidx4 = getelementptr [100 x i32]* @A, i32 0, i32 %tmp
+ %arrayidx = getelementptr [100 x i32]* @A, i32 0, i32 %tmp1
+ %exitcond = icmp ne i32 %tmp1, 12
+ br i1 %exitcond, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+ %tmp2 = load i32* %arrayidx, align 4
+ %tmp5 = load i32* %arrayidx4, align 4
+ %add = add nsw i32 %tmp2, %tmp5
+ store i32 %add, i32* getelementptr inbounds ([100 x i32]* @A, i32 0, i32 13), align 4
+ br label %for.inc
+
+for.inc: ; preds = %for.body
+ %inc = add nsw i32 %tmp1, 1
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ ret i32 0
+}
+; CHECK: load i32* getelementptr inbounds ([100 x i32]* @A, i32 0, i32 0)
Added: polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple___%for.cond---%for.end.jscop
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple___%25for.cond---%25for.end.jscop?rev=136789&view=auto
==============================================================================
--- polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple___%for.cond---%for.end.jscop (added)
+++ polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple___%for.cond---%for.end.jscop Wed Aug 3 12:02:50 2011
@@ -0,0 +1,25 @@
+{
+ "context" : "{ [] }",
+ "name" : "for.cond => for.end",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "read",
+ "relation" : "{ Stmt_for_body[i0] -> MemRef_A[i0] }"
+ },
+ {
+ "kind" : "read",
+ "relation" : "{ Stmt_for_body[i0] -> MemRef_A[-1 + i0] }"
+ },
+ {
+ "kind" : "write",
+ "relation" : "{ Stmt_for_body[i0] -> MemRef_A[13] }"
+ }
+ ],
+ "domain" : "{ Stmt_for_body[i0] : i0 >= 0 and i0 <= 11 }",
+ "name" : "Stmt_for_body",
+ "schedule" : "{ Stmt_for_body[i0] -> scattering[0, i0, 0] }"
+ }
+ ]
+}
Added: polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple___%for.cond---%for.end.jscop.transformed
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple___%25for.cond---%25for.end.jscop.transformed?rev=136789&view=auto
==============================================================================
--- polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple___%for.cond---%for.end.jscop.transformed (added)
+++ polly/trunk/test/CodeGen/MemAccess/memaccess_codegen_simple___%for.cond---%for.end.jscop.transformed Wed Aug 3 12:02:50 2011
@@ -0,0 +1,25 @@
+{
+ "context" : "{ [] }",
+ "name" : "for.cond => for.end",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "read",
+ "relation" : "{ Stmt_for_body[i0] -> MemRef_A[0] }"
+ },
+ {
+ "kind" : "read",
+ "relation" : "{ Stmt_for_body[i0] -> MemRef_A[-1 + i0] }"
+ },
+ {
+ "kind" : "write",
+ "relation" : "{ Stmt_for_body[i0] -> MemRef_A[13] }"
+ }
+ ],
+ "domain" : "{ Stmt_for_body[i0] : i0 >= 0 and i0 <= 11 }",
+ "name" : "Stmt_for_body",
+ "schedule" : "{ Stmt_for_body[i0] -> scattering[0, i0, 0] }"
+ }
+ ]
+}
More information about the llvm-commits
mailing list