summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorFedor Sergeev <fedor.sergeev@azul.com>2018-08-29 19:10:44 +0000
committerFedor Sergeev <fedor.sergeev@azul.com>2018-08-29 19:10:44 +0000
commit7b49aa03af9877ede00a100c6b178414e2f8656d (patch)
tree4dfde49be225ff4961d62462ec1088baba3d60ea /llvm/test
parentcf311cfc20a363ba1ee1a8115ab307d6745a6b73 (diff)
downloadbcm5719-llvm-7b49aa03af9877ede00a100c6b178414e2f8656d.tar.gz
bcm5719-llvm-7b49aa03af9877ede00a100c6b178414e2f8656d.zip
[SimpleLoopUnswitch] After unswitch delete dead blocks in parent loops
Summary: Assert from PR38737 happens on the dead block inside the parent loop after unswitching nontrivial switch in the inner loop. deleteDeadBlocksFromLoop now takes extra care to detect/remove dead blocks in all the parent loops in addition to the blocks from original loop being unswitched. Reviewers: asbirlea, chandlerc Reviewed By: asbirlea Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D51415 llvm-svn: 340955
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/SimpleLoopUnswitch/delete-dead-blocks.ll45
1 files changed, 45 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SimpleLoopUnswitch/delete-dead-blocks.ll b/llvm/test/Transforms/SimpleLoopUnswitch/delete-dead-blocks.ll
new file mode 100644
index 00000000000..0be1c8549ed
--- /dev/null
+++ b/llvm/test/Transforms/SimpleLoopUnswitch/delete-dead-blocks.ll
@@ -0,0 +1,45 @@
+; RUN: opt < %s -simple-loop-unswitch -enable-nontrivial-unswitch -S 2>&1 | FileCheck %s
+; RUN: opt < %s -passes=unswitch -enable-nontrivial-unswitch -S 2>&1 | FileCheck %s
+;
+; Checking that (dead) blocks from inner loop are deleted after unswitch.
+;
+declare void @foo()
+
+; CHECK-LABEL: @Test
+define void @Test(i32) {
+entry:
+ br label %outer
+outer:
+ %oi = phi i32 [ 0, %entry ], [ %oinc, %outer_continue]
+ br label %inner
+inner:
+ %ii = phi i32 [ 0, %outer ], [ %iinc, %continue]
+ call void @foo()
+ switch i32 %0, label %get_out2 [
+ i32 0, label %continue
+ i32 1, label %case1
+ i32 2, label %get_out
+ ]
+;
+; since we unswitch on the above switch, %case1 and %continue blocks
+; become dead in the original loop
+;
+; CHECK-NOT: case1:
+case1:
+ br label %continue
+; CHECK-NOT: {{^}}continue:
+continue:
+ %iinc = add i32 %ii, 1
+ %icmp = icmp eq i32 %ii, 100
+ br i1 %icmp, label %inner, label %outer_continue
+
+outer_continue:
+ %oinc = add i32 %oi, 1
+ %ocmp = icmp eq i32 %oi, 100
+ br i1 %ocmp, label %outer, label %get_out
+
+get_out:
+ ret void
+get_out2:
+ unreachable
+}
OpenPOWER on IntegriCloud