1 ; RUN: opt < %s -simple-loop-unswitch -enable-nontrivial-unswitch -S 2>&1 | FileCheck %s
2 ; RUN: opt < %s -passes='unswitch<nontrivial>' -S 2>&1 | FileCheck %s
4 ; Checking that (dead) blocks from inner loop are deleted after unswitch.
9 define void @Test(i32) {
13 %oi = phi i32 [ 0, %entry ], [ %oinc, %outer_continue]
16 %ii = phi i32 [ 0, %outer ], [ %iinc, %continue]
18 switch i32 %0, label %get_out2 [
19 i32 0, label %continue
24 ; since we unswitch on the above switch, %case1 and %continue blocks
25 ; become dead in the original loop
30 ; CHECK-NOT: {{^}}continue:
32 %iinc = add i32 %ii, 1
33 %icmp = icmp eq i32 %ii, 100
34 br i1 %icmp, label %inner, label %outer_continue
37 %oinc = add i32 %oi, 1
38 %ocmp = icmp eq i32 %oi, 100
39 br i1 %ocmp, label %outer, label %get_out
48 ; This comes from PR38778
50 define void @Test2(i32) {
54 switch i32 %0, label %continue [
55 i32 -2147483648, label %check
56 i32 98, label %guarded1
57 i32 99, label %guarded2
59 ; CHECK-NOT: {{^}}guarded1:
61 br i1 undef, label %continue, label %leave
66 br i1 undef, label %continue, label %leave
70 %local = phi i32 [ 0, %guarded1 ], [ %val, %check ]
75 ; Yet another test from PR38778
78 define void @Test3(i32) {
82 %bad_input.i = icmp eq i32 %0, -2147483648
85 br i1 %bad_input.i, label %overflow, label %switchme
89 switch i32 %0, label %continue [
93 ; CHECK-NOT: {{^}}case2:
97 %local_11_92 = phi i32 [ 0, %switchme ], [ 18, %case2 ], [ 0, %overflow ]
98 br i1 undef, label %outer, label %inner