1 ; RUN: opt < %s -simple-loop-unswitch -enable-nontrivial-unswitch -S 2>&1 | FileCheck %s
2 ; RUN: opt < %s -passes='simple-loop-unswitch<nontrivial>' -S 2>&1 | FileCheck %s
3 ; RUN: opt < %s -passes='loop-mssa(simple-loop-unswitch<nontrivial>)' -S 2>&1 | FileCheck %s
5 ; Checking that (dead) blocks from inner loop are deleted after unswitch.
10 define void @Test(i32) {
14 %oi = phi i32 [ 0, %entry ], [ %oinc, %outer_continue]
17 %ii = phi i32 [ 0, %outer ], [ %iinc, %continue]
19 switch i32 %0, label %get_out2 [
20 i32 0, label %continue
25 ; since we unswitch on the above switch, %case1 and %continue blocks
26 ; become dead in the original loop
31 ; CHECK-NOT: {{^}}continue:
33 %iinc = add i32 %ii, 1
34 %icmp = icmp eq i32 %ii, 100
35 br i1 %icmp, label %inner, label %outer_continue
38 %oinc = add i32 %oi, 1
39 %ocmp = icmp eq i32 %oi, 100
40 br i1 %ocmp, label %outer, label %get_out
49 ; This comes from PR38778
51 define void @Test2(i32) {
55 switch i32 %0, label %continue [
56 i32 -2147483648, label %check
57 i32 98, label %guarded1
58 i32 99, label %guarded2
60 ; CHECK-NOT: {{^}}guarded1:
62 br i1 undef, label %continue, label %leave
67 br i1 undef, label %continue, label %leave
71 %local = phi i32 [ 0, %guarded1 ], [ %val, %check ]
76 ; Yet another test from PR38778
79 define void @Test3(i32) {
83 %bad_input.i = icmp eq i32 %0, -2147483648
86 br i1 %bad_input.i, label %overflow, label %switchme
90 switch i32 %0, label %continue [
94 ; CHECK-NOT: {{^}}case2:
98 %local_11_92 = phi i32 [ 0, %switchme ], [ 18, %case2 ], [ 0, %overflow ]
99 br i1 undef, label %outer, label %inner