|
82 | 82 | return %t : $()
|
83 | 83 | }
|
84 | 84 |
|
| 85 | +// CHECK-LABEL: sil [ossa] @test_simplify_switch_enum1 : |
| 86 | +// CHECK-NOT: switch_enum |
| 87 | +// CHECK-LABEL: } // end sil function 'test_simplify_switch_enum1' |
| 88 | +sil [ossa] @test_simplify_switch_enum1 : $@convention(thin) (@owned Klass) -> () { |
| 89 | +bb0(%0 : @owned $Klass): |
| 90 | + test_specification "simplify-cfg-simplify-switch-enum-block @instruction[1]" |
| 91 | + %1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass |
| 92 | + switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2 |
| 93 | + |
| 94 | +bb2: |
| 95 | + br bb3 |
| 96 | + |
| 97 | +bb1(%3 : @owned $Klass): |
| 98 | + destroy_value %3 : $Klass |
| 99 | + br bb3 |
| 100 | + |
| 101 | +bb3: |
| 102 | + %t = tuple () |
| 103 | + return %t : $() |
| 104 | +} |
| 105 | + |
| 106 | +// CHECK-LABEL: sil [ossa] @test_simplify_switch_enum2 : |
| 107 | +// CHECK-NOT: switch_enum |
| 108 | +// CHECK-LABEL: } // end sil function 'test_simplify_switch_enum2' |
| 109 | +sil [ossa] @test_simplify_switch_enum2 : $@convention(thin) (@guaranteed Klass) -> () { |
| 110 | +bb0(%0 : @guaranteed $Klass): |
| 111 | + test_specification "simplify-cfg-simplify-switch-enum-block @instruction[1]" |
| 112 | + %1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass |
| 113 | + switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2 |
| 114 | + |
| 115 | +bb2: |
| 116 | + br bb3 |
| 117 | + |
| 118 | +bb1(%3 : @guaranteed $Klass): |
| 119 | + br bb3 |
| 120 | + |
| 121 | +bb3: |
| 122 | + %t = tuple () |
| 123 | + return %t : $() |
| 124 | +} |
| 125 | + |
| 126 | +// CHECK-LABEL: sil [ossa] @test_simplify_switch_enum3 : |
| 127 | +// CHECK-NOT: switch_enum |
| 128 | +// CHECK-LABEL: } // end sil function 'test_simplify_switch_enum3' |
| 129 | +sil [ossa] @test_simplify_switch_enum3 : $@convention(thin) (@owned Klass) -> () { |
| 130 | +bb0(%0 : @owned $Klass): |
| 131 | + test_specification "simplify-cfg-simplify-switch-enum-block @instruction[2]" |
| 132 | + %b = begin_borrow %0 : $Klass |
| 133 | + %1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %b : $Klass |
| 134 | + switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2 |
| 135 | + |
| 136 | +bb2: |
| 137 | + br bb3 |
| 138 | + |
| 139 | +bb1(%3 : @guaranteed $Klass): |
| 140 | + br bb3 |
| 141 | + |
| 142 | +bb3: |
| 143 | + end_borrow %b : $Klass |
| 144 | + destroy_value %0 : $Klass |
| 145 | + %t = tuple () |
| 146 | + return %t : $() |
| 147 | +} |
| 148 | + |
| 149 | +sil @use_optional : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> () |
| 150 | + |
| 151 | +// CHECK-LABEL: sil [ossa] @test_simplify_switch_enum4 : |
| 152 | +// CHECK-NOT: switch_enum |
| 153 | +// CHECK-LABEL: } // end sil function 'test_simplify_switch_enum4' |
| 154 | +sil [ossa] @test_simplify_switch_enum4 : $@convention(thin) (@guaranteed Klass) -> () { |
| 155 | +bb0(%0 : @guaranteed $Klass): |
| 156 | + test_specification "simplify-cfg-simplify-switch-enum-block @instruction[3]" |
| 157 | + %1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass |
| 158 | + %f = function_ref @use_optional : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> () |
| 159 | + %c = apply %f(%1) : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> () |
| 160 | + switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2 |
| 161 | + |
| 162 | +bb2: |
| 163 | + br bb3 |
| 164 | + |
| 165 | +bb1(%3 : @guaranteed $Klass): |
| 166 | + br bb3 |
| 167 | + |
| 168 | +bb3: |
| 169 | + %t = tuple () |
| 170 | + return %t : $() |
| 171 | +} |
| 172 | + |
| 173 | +// CHECK-LABEL: sil [ossa] @test_simplify_switch_enum5 : |
| 174 | +// CHECK-NOT: switch_enum |
| 175 | +// CHECK-LABEL: } // end sil function 'test_simplify_switch_enum5' |
| 176 | +sil [ossa] @test_simplify_switch_enum5 : $@convention(thin) (@owned Klass) -> () { |
| 177 | +bb0(%0 : @owned $Klass): |
| 178 | + test_specification "simplify-cfg-simplify-switch-enum-block @instruction[4]" |
| 179 | + %b = begin_borrow %0 : $Klass |
| 180 | + %1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %b : $Klass |
| 181 | + %f = function_ref @use_optional : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> () |
| 182 | + %c = apply %f(%1) : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> () |
| 183 | + switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2 |
| 184 | + |
| 185 | +bb2: |
| 186 | + br bb3 |
| 187 | + |
| 188 | +bb1(%3 : @guaranteed $Klass): |
| 189 | + br bb3 |
| 190 | + |
| 191 | +bb3: |
| 192 | + end_borrow %b : $Klass |
| 193 | + destroy_value %0 : $Klass |
| 194 | + %t = tuple () |
| 195 | + return %t : $() |
| 196 | +} |
| 197 | + |
| 198 | +// CHECK-LABEL: sil [ossa] @test_simplify_switch_enum6 : |
| 199 | +// CHECK-NOT: switch_enum |
| 200 | +// CHECK-LABEL: } // end sil function 'test_simplify_switch_enum6' |
| 201 | +sil [ossa] @test_simplify_switch_enum6 : $@convention(thin) (@owned Klass) -> () { |
| 202 | +bb0(%0 : @owned $Klass): |
| 203 | + cond_br undef, bb1, bb2 |
| 204 | + |
| 205 | +bb1: |
| 206 | + %2 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass |
| 207 | + br bb3(%2 : $FakeOptional<Klass>) |
| 208 | + |
| 209 | +bb2: |
| 210 | + %4 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass |
| 211 | + br bb3(%4 : $FakeOptional<Klass>) |
| 212 | + |
| 213 | +bb3(%6 :@owned $FakeOptional<Klass>): |
| 214 | + test_specification "simplify-cfg-simplify-switch-enum-block @instruction[7]" |
| 215 | + switch_enum %6 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb4, case #FakeOptional.none!enumelt: bb5 |
| 216 | + |
| 217 | +bb4(%8 : @owned $Klass): |
| 218 | + destroy_value %8 : $Klass |
| 219 | + br bb6 |
| 220 | + |
| 221 | +bb5: |
| 222 | + br bb6 |
| 223 | + |
| 224 | +bb6: |
| 225 | + %t = tuple () |
| 226 | + return %t : $() |
| 227 | +} |
| 228 | + |
0 commit comments