1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 -mattr=+d --min-jump-table-entries=5 < %s \
3 ; RUN: | FileCheck %s --check-prefix=LA32
4 ; RUN: llc --mtriple=loongarch64 -mattr=+d --min-jump-table-entries=5 < %s \
5 ; RUN: | FileCheck %s --check-prefix=LA64
6 ; RUN: llc --mtriple=loongarch32 -mattr=+d --min-jump-table-entries=4 < %s \
7 ; RUN: | FileCheck %s --check-prefix=LA32-JT
8 ; RUN: llc --mtriple=loongarch64 -mattr=+d --min-jump-table-entries=4 < %s \
9 ; RUN: | FileCheck %s --check-prefix=LA64-JT
11 ;; The default mininum number of entries to use a jump table is 4.
13 ;; Note: The parameter `--min-jump-table-entries` will have no effect once we
14 ;; have set the default value using `setMinimumJumpTableEntries`.
16 define void @switch_4_arms(i32 %in, ptr %out) nounwind {
17 ; LA32-LABEL: switch_4_arms:
18 ; LA32: # %bb.0: # %entry
19 ; LA32-NEXT: ori $a2, $zero, 2
20 ; LA32-NEXT: blt $a2, $a0, .LBB0_4
21 ; LA32-NEXT: # %bb.1: # %entry
22 ; LA32-NEXT: ori $a2, $zero, 1
23 ; LA32-NEXT: beq $a0, $a2, .LBB0_7
24 ; LA32-NEXT: # %bb.2: # %entry
25 ; LA32-NEXT: ori $a2, $zero, 2
26 ; LA32-NEXT: bne $a0, $a2, .LBB0_10
27 ; LA32-NEXT: # %bb.3: # %bb2
28 ; LA32-NEXT: ori $a0, $zero, 3
29 ; LA32-NEXT: b .LBB0_9
30 ; LA32-NEXT: .LBB0_4: # %entry
31 ; LA32-NEXT: ori $a2, $zero, 3
32 ; LA32-NEXT: beq $a0, $a2, .LBB0_8
33 ; LA32-NEXT: # %bb.5: # %entry
34 ; LA32-NEXT: ori $a2, $zero, 4
35 ; LA32-NEXT: bne $a0, $a2, .LBB0_10
36 ; LA32-NEXT: # %bb.6: # %bb4
37 ; LA32-NEXT: ori $a0, $zero, 1
38 ; LA32-NEXT: b .LBB0_9
39 ; LA32-NEXT: .LBB0_7: # %bb1
40 ; LA32-NEXT: ori $a0, $zero, 4
41 ; LA32-NEXT: b .LBB0_9
42 ; LA32-NEXT: .LBB0_8: # %bb3
43 ; LA32-NEXT: ori $a0, $zero, 2
44 ; LA32-NEXT: .LBB0_9: # %exit
45 ; LA32-NEXT: st.w $a0, $a1, 0
46 ; LA32-NEXT: .LBB0_10: # %exit
49 ; LA64-LABEL: switch_4_arms:
50 ; LA64: # %bb.0: # %entry
51 ; LA64-NEXT: addi.w $a0, $a0, 0
52 ; LA64-NEXT: ori $a2, $zero, 2
53 ; LA64-NEXT: blt $a2, $a0, .LBB0_4
54 ; LA64-NEXT: # %bb.1: # %entry
55 ; LA64-NEXT: ori $a2, $zero, 1
56 ; LA64-NEXT: beq $a0, $a2, .LBB0_7
57 ; LA64-NEXT: # %bb.2: # %entry
58 ; LA64-NEXT: ori $a2, $zero, 2
59 ; LA64-NEXT: bne $a0, $a2, .LBB0_10
60 ; LA64-NEXT: # %bb.3: # %bb2
61 ; LA64-NEXT: ori $a0, $zero, 3
62 ; LA64-NEXT: b .LBB0_9
63 ; LA64-NEXT: .LBB0_4: # %entry
64 ; LA64-NEXT: ori $a2, $zero, 3
65 ; LA64-NEXT: beq $a0, $a2, .LBB0_8
66 ; LA64-NEXT: # %bb.5: # %entry
67 ; LA64-NEXT: ori $a2, $zero, 4
68 ; LA64-NEXT: bne $a0, $a2, .LBB0_10
69 ; LA64-NEXT: # %bb.6: # %bb4
70 ; LA64-NEXT: ori $a0, $zero, 1
71 ; LA64-NEXT: b .LBB0_9
72 ; LA64-NEXT: .LBB0_7: # %bb1
73 ; LA64-NEXT: ori $a0, $zero, 4
74 ; LA64-NEXT: b .LBB0_9
75 ; LA64-NEXT: .LBB0_8: # %bb3
76 ; LA64-NEXT: ori $a0, $zero, 2
77 ; LA64-NEXT: .LBB0_9: # %exit
78 ; LA64-NEXT: st.w $a0, $a1, 0
79 ; LA64-NEXT: .LBB0_10: # %exit
82 ; LA32-JT-LABEL: switch_4_arms:
83 ; LA32-JT: # %bb.0: # %entry
84 ; LA32-JT-NEXT: addi.w $a0, $a0, -1
85 ; LA32-JT-NEXT: ori $a2, $zero, 3
86 ; LA32-JT-NEXT: bltu $a2, $a0, .LBB0_7
87 ; LA32-JT-NEXT: # %bb.1: # %entry
88 ; LA32-JT-NEXT: pcalau12i $a2, %pc_hi20(.LJTI0_0)
89 ; LA32-JT-NEXT: addi.w $a2, $a2, %pc_lo12(.LJTI0_0)
90 ; LA32-JT-NEXT: alsl.w $a0, $a0, $a2, 2
91 ; LA32-JT-NEXT: ld.w $a0, $a0, 0
92 ; LA32-JT-NEXT: jr $a0
93 ; LA32-JT-NEXT: .LBB0_2: # %bb1
94 ; LA32-JT-NEXT: ori $a0, $zero, 4
95 ; LA32-JT-NEXT: b .LBB0_6
96 ; LA32-JT-NEXT: .LBB0_3: # %bb3
97 ; LA32-JT-NEXT: ori $a0, $zero, 2
98 ; LA32-JT-NEXT: b .LBB0_6
99 ; LA32-JT-NEXT: .LBB0_4: # %bb4
100 ; LA32-JT-NEXT: ori $a0, $zero, 1
101 ; LA32-JT-NEXT: b .LBB0_6
102 ; LA32-JT-NEXT: .LBB0_5: # %bb2
103 ; LA32-JT-NEXT: ori $a0, $zero, 3
104 ; LA32-JT-NEXT: .LBB0_6: # %exit
105 ; LA32-JT-NEXT: st.w $a0, $a1, 0
106 ; LA32-JT-NEXT: .LBB0_7: # %exit
109 ; LA64-JT-LABEL: switch_4_arms:
110 ; LA64-JT: # %bb.0: # %entry
111 ; LA64-JT-NEXT: addi.w $a0, $a0, 0
112 ; LA64-JT-NEXT: addi.d $a0, $a0, -1
113 ; LA64-JT-NEXT: ori $a2, $zero, 3
114 ; LA64-JT-NEXT: bltu $a2, $a0, .LBB0_7
115 ; LA64-JT-NEXT: # %bb.1: # %entry
116 ; LA64-JT-NEXT: slli.d $a0, $a0, 3
117 ; LA64-JT-NEXT: pcalau12i $a2, %pc_hi20(.LJTI0_0)
118 ; LA64-JT-NEXT: addi.d $a2, $a2, %pc_lo12(.LJTI0_0)
119 ; LA64-JT-NEXT: ldx.d $a0, $a0, $a2
120 ; LA64-JT-NEXT: jr $a0
121 ; LA64-JT-NEXT: .LBB0_2: # %bb1
122 ; LA64-JT-NEXT: ori $a0, $zero, 4
123 ; LA64-JT-NEXT: b .LBB0_6
124 ; LA64-JT-NEXT: .LBB0_3: # %bb3
125 ; LA64-JT-NEXT: ori $a0, $zero, 2
126 ; LA64-JT-NEXT: b .LBB0_6
127 ; LA64-JT-NEXT: .LBB0_4: # %bb4
128 ; LA64-JT-NEXT: ori $a0, $zero, 1
129 ; LA64-JT-NEXT: b .LBB0_6
130 ; LA64-JT-NEXT: .LBB0_5: # %bb2
131 ; LA64-JT-NEXT: ori $a0, $zero, 3
132 ; LA64-JT-NEXT: .LBB0_6: # %exit
133 ; LA64-JT-NEXT: st.w $a0, $a1, 0
134 ; LA64-JT-NEXT: .LBB0_7: # %exit
137 switch i32 %in, label %exit [
144 store i32 4, ptr %out
147 store i32 3, ptr %out
150 store i32 2, ptr %out
153 store i32 1, ptr %out