summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorJun Bum Lim <junbuml@codeaurora.org>2017-12-15 20:33:24 +0000
committerJun Bum Lim <junbuml@codeaurora.org>2017-12-15 20:33:24 +0000
commit44c58d35c1a7343128a38aa2a3f1648bd027a65d (patch)
tree8be5f8cb6e51eea2ab8eef997a12c3d62b267406 /llvm/test
parent67ca67d1b2223f1761ecd41d29b2e41c2bcd9dfc (diff)
downloadbcm5719-llvm-44c58d35c1a7343128a38aa2a3f1648bd027a65d.tar.gz
bcm5719-llvm-44c58d35c1a7343128a38aa2a3f1648bd027a65d.zip
Re-commit : [LICM] Allow sinking when foldable in loop
This recommits r320823 reverted due to the test failure in sink-foldable.ll and an unused variable. Added "REQUIRES: aarch64-registered-target" in the test and removed unused variable. Original commit message: Continue trying to sink an instruction if its users in the loop is foldable. This will allow the instruction to be folded in the loop by decoupling it from the user outside of the loop. Reviewers: hfinkel, majnemer, davidxl, efriedma, danielcdh, bmakam, mcrosier Reviewed By: hfinkel Subscribers: javed.absar, bmakam, mcrosier, llvm-commits Differential Revision: https://reviews.llvm.org/D37076 llvm-svn: 320858
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/LICM/sink-foldable.ll150
1 files changed, 150 insertions, 0 deletions
diff --git a/llvm/test/Transforms/LICM/sink-foldable.ll b/llvm/test/Transforms/LICM/sink-foldable.ll
new file mode 100644
index 00000000000..1d4a99081a1
--- /dev/null
+++ b/llvm/test/Transforms/LICM/sink-foldable.ll
@@ -0,0 +1,150 @@
+; REQUIRES: aarch64-registered-target
+
+; RUN: opt < %s -licm -S | FileCheck %s
+
+target triple = "aarch64--linux-gnueabi"
+
+; CHECK-LABEL:@test1
+; CHECK-LABEL:loopexit1:
+; CHECK: %[[PHI:.+]] = phi i8** [ %arrayidx0, %if.end ]
+; CHECK: getelementptr inbounds i8*, i8** %[[PHI]], i64 1
+define i8** @test1(i32 %j, i8** readonly %P, i8* readnone %Q) {
+entry:
+ %cmp0 = icmp slt i32 0, %j
+ br i1 %cmp0, label %for.body.lr.ph, label %return
+
+for.body.lr.ph:
+ br label %for.body
+
+for.body:
+ %P.addr = phi i8** [ %P, %for.body.lr.ph ], [ %arrayidx0, %if.end ]
+ %i0 = phi i32 [ 0, %for.body.lr.ph ], [ %i.add, %if.end]
+
+ %i0.ext = sext i32 %i0 to i64
+ %arrayidx0 = getelementptr inbounds i8*, i8** %P.addr, i64 %i0.ext
+ %l0 = load i8*, i8** %arrayidx0, align 8
+ %cmp1 = icmp ugt i8* %l0, %Q
+ br i1 %cmp1, label %loopexit0, label %if.end
+
+if.end: ; preds = %for.body
+ %arrayidx1 = getelementptr inbounds i8*, i8** %arrayidx0, i64 1
+ %l1 = load i8*, i8** %arrayidx1, align 8
+ %cmp4 = icmp ugt i8* %l1, %Q
+ %i.add = add nsw i32 %i0, 2
+ br i1 %cmp4, label %loopexit1, label %for.body
+
+loopexit0:
+ %p1 = phi i8** [%arrayidx0, %for.body]
+ br label %return
+
+loopexit1:
+ %p2 = phi i8** [%arrayidx1, %if.end]
+ br label %return
+
+return:
+ %retval.0 = phi i8** [ %p1, %loopexit0 ], [%p2, %loopexit1], [ null, %entry ]
+ ret i8** %retval.0
+}
+
+; CHECK-LABEL: @test2
+; CHECK-LABEL: loopexit2:
+; CHECK: %[[PHI:.*]] = phi i8** [ %add.ptr, %if.end ]
+; CHECK: getelementptr inbounds i8*, i8** %[[PHI]]
+define i8** @test2(i32 %j, i8** readonly %P, i8* readnone %Q) {
+
+entry:
+ br label %for.body
+
+for.cond:
+ %i.addr.0 = phi i32 [ %add, %if.end ]
+ %P.addr.0 = phi i8** [ %add.ptr, %if.end ]
+ %cmp = icmp slt i32 %i.addr.0, %j
+ br i1 %cmp, label %for.body, label %loopexit0
+
+for.body:
+ %P.addr = phi i8** [ %P, %entry ], [ %P.addr.0, %for.cond ]
+ %i.addr = phi i32 [ 0, %entry ], [ %i.addr.0, %for.cond ]
+
+ %idx.ext = sext i32 %i.addr to i64
+ %add.ptr = getelementptr inbounds i8*, i8** %P.addr, i64 %idx.ext
+ %l0 = load i8*, i8** %add.ptr, align 8
+
+ %cmp1 = icmp ugt i8* %l0, %Q
+ br i1 %cmp1, label %loopexit1, label %if.end
+
+if.end:
+ %add.i = add i32 %i.addr, 1
+ %idx2.ext = sext i32 %add.i to i64
+ %arrayidx2 = getelementptr inbounds i8*, i8** %add.ptr, i64 %idx2.ext
+ %l1 = load i8*, i8** %arrayidx2, align 8
+ %cmp2 = icmp ugt i8* %l1, %Q
+ %add = add nsw i32 %add.i, 1
+ br i1 %cmp2, label %loopexit2, label %for.cond
+
+loopexit0:
+ %p0 = phi i8** [ null, %for.cond ]
+ br label %return
+
+loopexit1:
+ %p1 = phi i8** [ %add.ptr, %for.body ]
+ br label %return
+
+loopexit2:
+ %p2 = phi i8** [ %arrayidx2, %if.end ]
+ br label %return
+
+return:
+ %retval.0 = phi i8** [ %p1, %loopexit1 ], [ %p2, %loopexit2 ], [ %p0, %loopexit0 ]
+ ret i8** %retval.0
+}
+
+
+; CHECK-LABEL: @test3
+; CHECK-LABEL: loopexit1:
+; CHECK: %[[ADD:.*]] = phi i64 [ %add, %if.end ]
+; CHECK: %[[ADDR:.*]] = phi i8** [ %P.addr, %if.end ]
+; CHECK: %[[TRUNC:.*]] = trunc i64 %[[ADD]] to i32
+; CHECK: getelementptr inbounds i8*, i8** %[[ADDR]], i32 %[[TRUNC]]
+; CHECK: call void @dummy(i32 %[[TRUNC]])
+define i8** @test3(i64 %j, i8** readonly %P, i8* readnone %Q) {
+entry:
+ %cmp0 = icmp slt i64 0, %j
+ br i1 %cmp0, label %for.body.lr.ph, label %return
+
+for.body.lr.ph:
+ br label %for.body
+
+for.body:
+ %P.addr = phi i8** [ %P, %for.body.lr.ph ], [ %arrayidx0, %if.end ]
+ %i0 = phi i32 [ 0, %for.body.lr.ph ], [ %i.add, %if.end]
+
+ %i0.ext = sext i32 %i0 to i64
+ %arrayidx0 = getelementptr inbounds i8*, i8** %P.addr, i64 %i0.ext
+ %l0 = load i8*, i8** %arrayidx0, align 8
+ %cmp1 = icmp ugt i8* %l0, %Q
+ br i1 %cmp1, label %loopexit0, label %if.end
+
+if.end: ; preds = %for.body
+ %add = add i64 %i0.ext, 1
+ %trunc = trunc i64 %add to i32
+ %arrayidx1 = getelementptr inbounds i8*, i8** %P.addr, i32 %trunc
+ %l1 = load i8*, i8** %arrayidx1, align 8
+ %cmp4 = icmp ugt i8* %l1, %Q
+ %i.add = add nsw i32 %i0, 2
+ br i1 %cmp4, label %loopexit1, label %for.body
+
+loopexit0:
+ %p1 = phi i8** [%arrayidx0, %for.body]
+ br label %return
+
+loopexit1:
+ %p2 = phi i8** [%arrayidx1, %if.end]
+ call void @dummy(i32 %trunc)
+ br label %return
+
+return:
+ %retval.0 = phi i8** [ %p1, %loopexit0 ], [%p2, %loopexit1], [ null, %entry ]
+ ret i8** %retval.0
+}
+
+declare void @dummy(i32)
OpenPOWER on IntegriCloud