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'
85
88
sil [ossa] @test_simplify_switch_enum1 : $@convention(thin) (@owned Klass) -> () {
86
89
bb0(%0 : @owned $Klass):
90
+ test_specification "simplify-cfg-simplify-switch-enum-block @instruction[1]"
87
91
%1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass
88
92
switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2
89
93
99
103
return %t : $()
100
104
}
101
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'
102
109
sil [ossa] @test_simplify_switch_enum2 : $@convention(thin) (@guaranteed Klass) -> () {
103
110
bb0(%0 : @guaranteed $Klass):
111
+ test_specification "simplify-cfg-simplify-switch-enum-block @instruction[1]"
104
112
%1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass
105
113
switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2
106
114
@@ -115,8 +123,12 @@ bb3:
115
123
return %t : $()
116
124
}
117
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'
118
129
sil [ossa] @test_simplify_switch_enum3 : $@convention(thin) (@owned Klass) -> () {
119
130
bb0(%0 : @owned $Klass):
131
+ test_specification "simplify-cfg-simplify-switch-enum-block @instruction[2]"
120
132
%b = begin_borrow %0 : $Klass
121
133
%1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %b : $Klass
122
134
switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2
@@ -136,8 +148,12 @@ bb3:
136
148
137
149
sil @use_optional : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
138
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'
139
154
sil [ossa] @test_simplify_switch_enum4 : $@convention(thin) (@guaranteed Klass) -> () {
140
155
bb0(%0 : @guaranteed $Klass):
156
+ test_specification "simplify-cfg-simplify-switch-enum-block @instruction[3]"
141
157
%1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass
142
158
%f = function_ref @use_optional : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
143
159
%c = apply %f(%1) : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
@@ -154,8 +170,12 @@ bb3:
154
170
return %t : $()
155
171
}
156
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'
157
176
sil [ossa] @test_simplify_switch_enum5 : $@convention(thin) (@owned Klass) -> () {
158
177
bb0(%0 : @owned $Klass):
178
+ test_specification "simplify-cfg-simplify-switch-enum-block @instruction[4]"
159
179
%b = begin_borrow %0 : $Klass
160
180
%1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %b : $Klass
161
181
%f = function_ref @use_optional : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
@@ -175,3 +195,34 @@ bb3:
175
195
return %t : $()
176
196
}
177
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