summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorMax Kazantsev <max.kazantsev@azul.com>2018-08-21 08:11:31 +0000
committerMax Kazantsev <max.kazantsev@azul.com>2018-08-21 08:11:31 +0000
commit097ef69182d65c6687822a2a846bf82de5cf2686 (patch)
tree17a091fb90aee9f7b46a7c30508ea8dad0f382af /llvm/test
parent880f29157770a2fe51f08887c363e789f8d47ba6 (diff)
downloadbcm5719-llvm-097ef69182d65c6687822a2a846bf82de5cf2686.tar.gz
bcm5719-llvm-097ef69182d65c6687822a2a846bf82de5cf2686.zip
[LICM] Hoist guards with invariant conditions
This patch teaches LICM to hoist guards from the loop if they are guaranteed to execute and if there are no side effects that could prevent that. Differential Revision: https://reviews.llvm.org/D50501 Reviewed By: reames llvm-svn: 340256
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/GuardWidening/loop-schedule.ll2
-rw-r--r--llvm/test/Transforms/LICM/guards.ll13
2 files changed, 8 insertions, 7 deletions
diff --git a/llvm/test/Transforms/GuardWidening/loop-schedule.ll b/llvm/test/Transforms/GuardWidening/loop-schedule.ll
index 94d1c863eac..ed4fde0b6b2 100644
--- a/llvm/test/Transforms/GuardWidening/loop-schedule.ll
+++ b/llvm/test/Transforms/GuardWidening/loop-schedule.ll
@@ -41,8 +41,8 @@ define void @within_loop(i32 %a, i32 %b, i1* %c_p) {
; CHECK: %cond_0 = icmp ult i32 %a, 10
; CHECK: %cond_1 = icmp ult i32 %b, 10
; CHECK: %wide.chk = and i1 %cond_0, %cond_1
-; CHECK-LABEL: loop:
; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %wide.chk) [ "deopt"() ]
+; CHECK-LABEL: loop:
entry:
br label %loop
diff --git a/llvm/test/Transforms/LICM/guards.ll b/llvm/test/Transforms/LICM/guards.ll
index 92d9a9d185d..ff248dfd5ba 100644
--- a/llvm/test/Transforms/LICM/guards.ll
+++ b/llvm/test/Transforms/LICM/guards.ll
@@ -1,13 +1,13 @@
; RUN: opt -licm -basicaa < %s -S | FileCheck %s
; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' < %s -S | FileCheck %s
-; TODO: should be able to hoist both guard and load
+; Hoist guard and load.
define void @test1(i1 %cond, i32* %ptr) {
; CHECK-LABEL: @test1(
; CHECK-LABEL: entry:
-; CHECK-LABEL: loop:
; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %cond)
; CHECK: %val = load i32, i32* %ptr
+; CHECK-LABEL: loop:
entry:
br label %loop
@@ -62,13 +62,14 @@ loop:
}
-; Could hoist, but don't
+; Hoist guard. Cannot hoist load because of aliasing.
define void @test3(i1 %cond, i32* %ptr) {
; CHECK-LABEL: @test3(
; CHECK-LABEL: entry:
-; CHECK-LABEL: loop:
; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %cond)
+; CHECK-LABEL: loop:
; CHECK: %val = load i32, i32* %ptr
+; CHECK: store i32 0, i32* %ptr
entry:
br label %loop
@@ -228,16 +229,16 @@ exit:
ret void
}
-; We can hoist an invariant guard, leave the following variant guard in the loop.
+; Hoist an invariant guard, leave the following variant guard in the loop.
define void @test5a(i1 %c, i32* %p, i32* %q) {
; CHECK-LABEL: @test5a(
; CHECK-LABEL: entry:
; CHECK: %a = load i32, i32* %p
; CHECK: %invariant_cond = icmp ne i32 %a, 100
+; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %invariant_cond)
; CHECK-LABEL: loop:
; CHECK: %variant_cond = icmp ne i32 %a, %iv
-; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %invariant_cond)
; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %variant_cond)
entry:
OpenPOWER on IntegriCloud