@@ -115,6 +115,125 @@ return:
115
115
116
116
}
117
117
118
+ ; The minimal table range is [122, -128]([122, 128]).
119
+
120
+ define i32 @f_i8_128 (i8 %c ) {
121
+ ; CHECK-LABEL: @f_i8_128(
122
+ ; CHECK-NEXT: entry:
123
+ ; CHECK-NEXT: switch i8 [[C:%.*]], label [[SW_DEFAULT:%.*]] [
124
+ ; CHECK-NEXT: i8 122, label [[RETURN:%.*]]
125
+ ; CHECK-NEXT: i8 123, label [[SW_BB1:%.*]]
126
+ ; CHECK-NEXT: i8 124, label [[SW_BB2:%.*]]
127
+ ; CHECK-NEXT: i8 125, label [[SW_BB3:%.*]]
128
+ ; CHECK-NEXT: i8 126, label [[SW_BB4:%.*]]
129
+ ; CHECK-NEXT: i8 127, label [[SW_BB5:%.*]]
130
+ ; CHECK-NEXT: i8 -128, label [[SW_BB6:%.*]]
131
+ ; CHECK-NEXT: ]
132
+ ; CHECK: sw.bb1:
133
+ ; CHECK-NEXT: br label [[RETURN]]
134
+ ; CHECK: sw.bb2:
135
+ ; CHECK-NEXT: br label [[RETURN]]
136
+ ; CHECK: sw.bb3:
137
+ ; CHECK-NEXT: br label [[RETURN]]
138
+ ; CHECK: sw.bb4:
139
+ ; CHECK-NEXT: br label [[RETURN]]
140
+ ; CHECK: sw.bb5:
141
+ ; CHECK-NEXT: br label [[RETURN]]
142
+ ; CHECK: sw.bb6:
143
+ ; CHECK-NEXT: br label [[RETURN]]
144
+ ; CHECK: sw.default:
145
+ ; CHECK-NEXT: br label [[RETURN]]
146
+ ; CHECK: return:
147
+ ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ 15, [[SW_DEFAULT]] ], [ 1, [[SW_BB6]] ], [ 62, [[SW_BB5]] ], [ 27, [[SW_BB4]] ], [ -1, [[SW_BB3]] ], [ 0, [[SW_BB2]] ], [ 123, [[SW_BB1]] ], [ 55, [[ENTRY:%.*]] ]
148
+ ; CHECK-NEXT: ret i32 [[RETVAL_0]]
149
+ ;
150
+ entry:
151
+ switch i8 %c , label %sw.default [
152
+ i8 122 , label %return
153
+ i8 123 , label %sw.bb1
154
+ i8 124 , label %sw.bb2
155
+ i8 125 , label %sw.bb3
156
+ i8 126 , label %sw.bb4
157
+ i8 127 , label %sw.bb5
158
+ i8 -128 , label %sw.bb6
159
+ ]
160
+
161
+ sw.bb1: br label %return
162
+ sw.bb2: br label %return
163
+ sw.bb3: br label %return
164
+ sw.bb4: br label %return
165
+ sw.bb5: br label %return
166
+ sw.bb6: br label %return
167
+ sw.default: br label %return
168
+ return:
169
+ %retval.0 = phi i32 [ 15 , %sw.default ], [ 1 , %sw.bb6 ], [ 62 , %sw.bb5 ], [ 27 , %sw.bb4 ], [ -1 , %sw.bb3 ], [ 0 , %sw.bb2 ], [ 123 , %sw.bb1 ], [ 55 , %entry ]
170
+ ret i32 %retval.0
171
+ }
172
+
173
+ ; The minimal table range is [3, 0].
174
+
175
+ define i32 @f_min_max (i3 %c ) {
176
+ ; CHECK-LABEL: @f_min_max(
177
+ ; CHECK-NEXT: entry:
178
+ ; CHECK-NEXT: [[SWITCH_TABLEIDX:%.*]] = sub i3 [[C:%.*]], -4
179
+ ; CHECK-NEXT: [[SWITCH_TABLEIDX_ZEXT:%.*]] = zext i3 [[SWITCH_TABLEIDX]] to i4
180
+ ; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [8 x i32], ptr @switch.table.f_min_max, i32 0, i4 [[SWITCH_TABLEIDX_ZEXT]]
181
+ ; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i32, ptr [[SWITCH_GEP]], align 4
182
+ ; CHECK-NEXT: ret i32 [[SWITCH_LOAD]]
183
+ ;
184
+ entry:
185
+ switch i3 %c , label %sw.default [
186
+ i3 -4 , label %return
187
+ i3 -3 , label %sw.bb1
188
+ i3 -2 , label %sw.bb2
189
+ i3 -1 , label %sw.bb3
190
+ i3 0 , label %sw.bb4
191
+ i3 3 , label %sw.bb6
192
+ ]
193
+
194
+ sw.bb1: br label %return
195
+ sw.bb2: br label %return
196
+ sw.bb3: br label %return
197
+ sw.bb4: br label %return
198
+ sw.bb6: br label %return
199
+ sw.default: br label %return
200
+ return:
201
+ %retval.0 = phi i32 [ 15 , %sw.default ], [ 1 , %sw.bb6 ], [ 27 , %sw.bb4 ], [ -1 , %sw.bb3 ], [ 0 , %sw.bb2 ], [ 123 , %sw.bb1 ], [ 55 , %entry ]
202
+ ret i32 %retval.0
203
+ }
204
+
205
+ ; The minimal table range is [-1, -4].
206
+
207
+ define i32 @f_min_max_2 (i3 %c ) {
208
+ ; CHECK-LABEL: @f_min_max_2(
209
+ ; CHECK-NEXT: entry:
210
+ ; CHECK-NEXT: [[SWITCH_TABLEIDX:%.*]] = sub i3 [[C:%.*]], -4
211
+ ; CHECK-NEXT: [[SWITCH_TABLEIDX_ZEXT:%.*]] = zext i3 [[SWITCH_TABLEIDX]] to i4
212
+ ; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [8 x i32], ptr @switch.table.f_min_max_2, i32 0, i4 [[SWITCH_TABLEIDX_ZEXT]]
213
+ ; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i32, ptr [[SWITCH_GEP]], align 4
214
+ ; CHECK-NEXT: ret i32 [[SWITCH_LOAD]]
215
+ ;
216
+ entry:
217
+ switch i3 %c , label %sw.default [
218
+ i3 -1 , label %return
219
+ i3 0 , label %sw.bb1
220
+ i3 1 , label %sw.bb2
221
+ i3 2 , label %sw.bb3
222
+ i3 3 , label %sw.bb4
223
+ i3 -4 , label %sw.bb6
224
+ ]
225
+
226
+ sw.bb1: br label %return
227
+ sw.bb2: br label %return
228
+ sw.bb3: br label %return
229
+ sw.bb4: br label %return
230
+ sw.bb6: br label %return
231
+ sw.default: br label %return
232
+ return:
233
+ %retval.0 = phi i32 [ 15 , %sw.default ], [ 1 , %sw.bb6 ], [ 27 , %sw.bb4 ], [ -1 , %sw.bb3 ], [ 0 , %sw.bb2 ], [ 123 , %sw.bb1 ], [ 55 , %entry ]
234
+ ret i32 %retval.0
235
+ }
236
+
118
237
; A switch used to initialize two variables, an i8 and a float.
119
238
120
239
declare void @dummy (i8 signext , float )
0 commit comments