@@ -7,7 +7,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
77
88define i32 @single_succ_switch (i32 %x ) {
99; THROUGHPUT-LABEL: 'single_succ_switch'
10- ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: switch i32 %x, label %default [
10+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: switch i32 %x, label %default [
1111; THROUGHPUT-NEXT: ]
1212; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 1
1313;
@@ -30,7 +30,7 @@ default:
3030
3131define i32 @dense_switch (i32 %x ) {
3232; THROUGHPUT-LABEL: 'dense_switch'
33- ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: switch i32 %x, label %default [
33+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: switch i32 %x, label %default [
3434; THROUGHPUT-NEXT: i32 0, label %bb0
3535; THROUGHPUT-NEXT: i32 1, label %bb1
3636; THROUGHPUT-NEXT: i32 2, label %bb2
@@ -60,7 +60,7 @@ define i32 @dense_switch(i32 %x) {
6060; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: unreachable
6161;
6262; CODESIZE-LABEL: 'dense_switch'
63- ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 3 for instruction: switch i32 %x, label %default [
63+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: switch i32 %x, label %default [
6464; CODESIZE-NEXT: i32 0, label %bb0
6565; CODESIZE-NEXT: i32 1, label %bb1
6666; CODESIZE-NEXT: i32 2, label %bb2
@@ -96,9 +96,77 @@ default:
9696 unreachable
9797}
9898
99+ define i32 @dense_switch_reachable_default (i32 %x ) {
100+ ; THROUGHPUT-LABEL: 'dense_switch_reachable_default'
101+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: switch i32 %x, label %default [
102+ ; THROUGHPUT-NEXT: i32 0, label %bb0
103+ ; THROUGHPUT-NEXT: i32 1, label %bb1
104+ ; THROUGHPUT-NEXT: i32 2, label %bb2
105+ ; THROUGHPUT-NEXT: i32 3, label %bb3
106+ ; THROUGHPUT-NEXT: i32 4, label %bb4
107+ ; THROUGHPUT-NEXT: ]
108+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 0
109+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 1
110+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 2
111+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 3
112+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 4
113+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 5
114+ ;
115+ ; LATENCY-LABEL: 'dense_switch_reachable_default'
116+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: switch i32 %x, label %default [
117+ ; LATENCY-NEXT: i32 0, label %bb0
118+ ; LATENCY-NEXT: i32 1, label %bb1
119+ ; LATENCY-NEXT: i32 2, label %bb2
120+ ; LATENCY-NEXT: i32 3, label %bb3
121+ ; LATENCY-NEXT: i32 4, label %bb4
122+ ; LATENCY-NEXT: ]
123+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 0
124+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 1
125+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 2
126+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 3
127+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 4
128+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 5
129+ ;
130+ ; CODESIZE-LABEL: 'dense_switch_reachable_default'
131+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: switch i32 %x, label %default [
132+ ; CODESIZE-NEXT: i32 0, label %bb0
133+ ; CODESIZE-NEXT: i32 1, label %bb1
134+ ; CODESIZE-NEXT: i32 2, label %bb2
135+ ; CODESIZE-NEXT: i32 3, label %bb3
136+ ; CODESIZE-NEXT: i32 4, label %bb4
137+ ; CODESIZE-NEXT: ]
138+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 0
139+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 1
140+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 2
141+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 3
142+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 4
143+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 5
144+ ;
145+ entry:
146+ switch i32 %x , label %default [
147+ i32 0 , label %bb0
148+ i32 1 , label %bb1
149+ i32 2 , label %bb2
150+ i32 3 , label %bb3
151+ i32 4 , label %bb4
152+ ]
153+ bb0:
154+ ret i32 0
155+ bb1:
156+ ret i32 1
157+ bb2:
158+ ret i32 2
159+ bb3:
160+ ret i32 3
161+ bb4:
162+ ret i32 4
163+ default:
164+ ret i32 5
165+ }
166+
99167define i32 @sparse_switch (i32 %x ) {
100168; THROUGHPUT-LABEL: 'sparse_switch'
101- ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: switch i32 %x, label %default [
169+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: switch i32 %x, label %default [
102170; THROUGHPUT-NEXT: i32 0, label %bb0
103171; THROUGHPUT-NEXT: i32 100, label %bb1
104172; THROUGHPUT-NEXT: i32 200, label %bb2
@@ -164,9 +232,77 @@ default:
164232 unreachable
165233}
166234
235+ define i32 @sparse_switch_reachable_default (i32 %x ) {
236+ ; THROUGHPUT-LABEL: 'sparse_switch_reachable_default'
237+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: switch i32 %x, label %default [
238+ ; THROUGHPUT-NEXT: i32 0, label %bb0
239+ ; THROUGHPUT-NEXT: i32 100, label %bb1
240+ ; THROUGHPUT-NEXT: i32 200, label %bb2
241+ ; THROUGHPUT-NEXT: i32 300, label %bb3
242+ ; THROUGHPUT-NEXT: i32 400, label %bb4
243+ ; THROUGHPUT-NEXT: ]
244+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 0
245+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 1
246+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 2
247+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 3
248+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 4
249+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 5
250+ ;
251+ ; LATENCY-LABEL: 'sparse_switch_reachable_default'
252+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: switch i32 %x, label %default [
253+ ; LATENCY-NEXT: i32 0, label %bb0
254+ ; LATENCY-NEXT: i32 100, label %bb1
255+ ; LATENCY-NEXT: i32 200, label %bb2
256+ ; LATENCY-NEXT: i32 300, label %bb3
257+ ; LATENCY-NEXT: i32 400, label %bb4
258+ ; LATENCY-NEXT: ]
259+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 0
260+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 1
261+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 2
262+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 3
263+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 4
264+ ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 5
265+ ;
266+ ; CODESIZE-LABEL: 'sparse_switch_reachable_default'
267+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 6 for instruction: switch i32 %x, label %default [
268+ ; CODESIZE-NEXT: i32 0, label %bb0
269+ ; CODESIZE-NEXT: i32 100, label %bb1
270+ ; CODESIZE-NEXT: i32 200, label %bb2
271+ ; CODESIZE-NEXT: i32 300, label %bb3
272+ ; CODESIZE-NEXT: i32 400, label %bb4
273+ ; CODESIZE-NEXT: ]
274+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 0
275+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 1
276+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 2
277+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 3
278+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 4
279+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 5
280+ ;
281+ entry:
282+ switch i32 %x , label %default [
283+ i32 0 , label %bb0
284+ i32 100 , label %bb1
285+ i32 200 , label %bb2
286+ i32 300 , label %bb3
287+ i32 400 , label %bb4
288+ ]
289+ bb0:
290+ ret i32 0
291+ bb1:
292+ ret i32 1
293+ bb2:
294+ ret i32 2
295+ bb3:
296+ ret i32 3
297+ bb4:
298+ ret i32 4
299+ default:
300+ ret i32 5
301+ }
302+
167303define i32 @dense_big_switch (i32 %x ) {
168304; THROUGHPUT-LABEL: 'dense_big_switch'
169- ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: switch i32 %x, label %default [
305+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: switch i32 %x, label %default [
170306; THROUGHPUT-NEXT: i32 0, label %bb0
171307; THROUGHPUT-NEXT: i32 1, label %bb1
172308; THROUGHPUT-NEXT: i32 2, label %bb2
@@ -220,7 +356,7 @@ define i32 @dense_big_switch(i32 %x) {
220356; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: unreachable
221357;
222358; CODESIZE-LABEL: 'dense_big_switch'
223- ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 3 for instruction: switch i32 %x, label %default [
359+ ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: switch i32 %x, label %default [
224360; CODESIZE-NEXT: i32 0, label %bb0
225361; CODESIZE-NEXT: i32 1, label %bb1
226362; CODESIZE-NEXT: i32 2, label %bb2
@@ -288,7 +424,7 @@ default:
288424
289425define i32 @sparse_big_switch (i32 %x ) {
290426; THROUGHPUT-LABEL: 'sparse_big_switch'
291- ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: switch i32 %x, label %default [
427+ ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: switch i32 %x, label %default [
292428; THROUGHPUT-NEXT: i32 0, label %bb0
293429; THROUGHPUT-NEXT: i32 100, label %bb1
294430; THROUGHPUT-NEXT: i32 200, label %bb2
0 commit comments