summaryrefslogtreecommitdiffstats
path: root/polly/test/ScopInfo/int2ptr_ptr2int_2.ll
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2016-06-11 19:26:08 +0000
committerTobias Grosser <tobias@grosser.es>2016-06-11 19:26:08 +0000
commit423642a59701ce381d9d4120929e5cc8c27f8489 (patch)
tree1710b8192563b06074c9d27fb4cb033542e24185 /polly/test/ScopInfo/int2ptr_ptr2int_2.ll
parent3fc09f7be672dd1adf4e0d939aa86badcdfd5df8 (diff)
downloadbcm5719-llvm-423642a59701ce381d9d4120929e5cc8c27f8489.tar.gz
bcm5719-llvm-423642a59701ce381d9d4120929e5cc8c27f8489.zip
Recommit: "Look through IntToPtr & PtrToInt instructions"
IntToPtr and PtrToInt instructions are basically no-ops that we can handle as such. In order to generate them properly as parameters we had to improve the ScopExpander, though the change is the first in the direction of a more aggressive scalar synthetization. This patch was originally contributed by Johannes Doerfert in r271888, but was in conflict with the revert in r272483. This is a recommit with some minor adjustment to the test cases to take care of differing instruction names. llvm-svn: 272485
Diffstat (limited to 'polly/test/ScopInfo/int2ptr_ptr2int_2.ll')
-rw-r--r--polly/test/ScopInfo/int2ptr_ptr2int_2.ll72
1 files changed, 72 insertions, 0 deletions
diff --git a/polly/test/ScopInfo/int2ptr_ptr2int_2.ll b/polly/test/ScopInfo/int2ptr_ptr2int_2.ll
new file mode 100644
index 00000000000..e47e181c97b
--- /dev/null
+++ b/polly/test/ScopInfo/int2ptr_ptr2int_2.ll
@@ -0,0 +1,72 @@
+; RUN: opt %loadPolly -analyze -polly-scops < %s | FileCheck %s
+; RUN: opt %loadPolly -S -polly-codegen < %s | FileCheck %s --check-prefix=IR
+;
+; void f(long *A, long *B, long *ptr, long val) {
+; for (long i = 0; i < 100; i++) {
+; long ptrV = ((long)(ptr + 1)) + 1;
+; long valP = (long)(((long *)(val + 1)) + 1);
+; A[ptrV] += B[valP];
+; }
+; }
+;
+; CHECK: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_B[9 + val] };
+; CHECK-NEXT: Execution Context: [val, ptr] -> { : val <= 9223372036854775806 }
+;
+; CHECK: ReadAccess := [Reduction Type: +] [Scalar: 0]
+; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_A[9 + ptr] };
+; CHECK-NEXT: MustWriteAccess := [Reduction Type: +] [Scalar: 0]
+; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_A[9 + ptr] };
+;
+; IR: polly.stmt.for.body:
+; IR-NEXT: %p_tmp = ptrtoint i64* %scevgep to i64
+; IR-NEXT: %p_add = add nsw i64 %p_tmp, 1
+; IR-NEXT: %p_tmp1 = inttoptr i64 %26 to i64*
+; IR-NEXT: %p_add.ptr2 = getelementptr inbounds i64, i64* %p_tmp1, i64 1
+; IR-NEXT: %p_tmp2 = ptrtoint i64* %p_add.ptr2 to i64
+; IR-NEXT: %p_arrayidx = getelementptr inbounds i64, i64* %B, i64 %p_tmp2
+; IR-NEXT: %p_arrayidx3 = getelementptr inbounds i64, i64* %A, i64 %p_add
+; IR-NEXT: %tmp4_p_scalar_ = load i64, i64* %p_arrayidx3
+; IR-NEXT: %p_add4 = add nsw i64 %tmp4_p_scalar_, %polly.preload.tmp3.merge
+; IR-NEXT: store i64 %p_add4, i64* %p_arrayidx3
+;
+; IR: polly.loop_preheader:
+; IR-NEXT: %scevgep = getelementptr i64, i64* %ptr, i64 1
+; IR-NEXT: %26 = add i64 %val, 1
+; IR-NEXT: br label %polly.loop_header
+;
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @f(i64* %A, i64* %B, i64* %ptr, i64 %val) {
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+ %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ]
+ %exitcond = icmp ne i64 %i.0, 100
+ br i1 %exitcond, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+ %add.ptr = getelementptr inbounds i64, i64* %ptr, i64 1
+ %tmp = ptrtoint i64* %add.ptr to i64
+ %add = add nsw i64 %tmp, 1
+ %add1 = add nsw i64 %val, 1
+ %tmp1 = inttoptr i64 %add1 to i64*
+ %add.ptr2 = getelementptr inbounds i64, i64* %tmp1, i64 1
+ %tmp2 = ptrtoint i64* %add.ptr2 to i64
+ %arrayidx = getelementptr inbounds i64, i64* %B, i64 %tmp2
+ %tmp3 = load i64, i64* %arrayidx
+ %arrayidx3 = getelementptr inbounds i64, i64* %A, i64 %add
+ %tmp4 = load i64, i64* %arrayidx3
+ %add4 = add nsw i64 %tmp4, %tmp3
+ store i64 %add4, i64* %arrayidx3
+ br label %for.inc
+
+for.inc: ; preds = %for.body
+ %inc = add nuw nsw i64 %i.0, 1
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ ret void
+}
OpenPOWER on IntegriCloud