1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 --min-jump-table-entries=5 < %s \
3 ; RUN: | FileCheck %s --check-prefix=LA32
4 ; RUN: llc --mtriple=loongarch64 --min-jump-table-entries=5 < %s \
5 ; RUN: | FileCheck %s --check-prefix=LA64
6 ; RUN: llc --mtriple=loongarch32 --min-jump-table-entries=4 < %s \
7 ; RUN: | FileCheck %s --check-prefix=LA32-JT
8 ; RUN: llc --mtriple=loongarch64 --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 $a3, $zero, 1
23 ; LA32-NEXT: beq $a0, $a3, .LBB0_7
24 ; LA32-NEXT: # %bb.2: # %entry
25 ; LA32-NEXT: bne $a0, $a2, .LBB0_9
26 ; LA32-NEXT: # %bb.3: # %bb2
27 ; LA32-NEXT: ori $a0, $zero, 3
28 ; LA32-NEXT: st.w $a0, $a1, 0
30 ; LA32-NEXT: .LBB0_4: # %entry
31 ; LA32-NEXT: ori $a3, $zero, 3
32 ; LA32-NEXT: beq $a0, $a3, .LBB0_8
33 ; LA32-NEXT: # %bb.5: # %entry
34 ; LA32-NEXT: ori $a2, $zero, 4
35 ; LA32-NEXT: bne $a0, $a2, .LBB0_9
36 ; LA32-NEXT: # %bb.6: # %bb4
37 ; LA32-NEXT: ori $a0, $zero, 1
38 ; LA32-NEXT: st.w $a0, $a1, 0
40 ; LA32-NEXT: .LBB0_7: # %bb1
41 ; LA32-NEXT: ori $a0, $zero, 4
42 ; LA32-NEXT: st.w $a0, $a1, 0
44 ; LA32-NEXT: .LBB0_8: # %bb3
45 ; LA32-NEXT: st.w $a2, $a1, 0
46 ; LA32-NEXT: .LBB0_9: # %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 $a3, $zero, 1
56 ; LA64-NEXT: beq $a0, $a3, .LBB0_7
57 ; LA64-NEXT: # %bb.2: # %entry
58 ; LA64-NEXT: bne $a0, $a2, .LBB0_9
59 ; LA64-NEXT: # %bb.3: # %bb2
60 ; LA64-NEXT: ori $a0, $zero, 3
61 ; LA64-NEXT: st.w $a0, $a1, 0
63 ; LA64-NEXT: .LBB0_4: # %entry
64 ; LA64-NEXT: ori $a3, $zero, 3
65 ; LA64-NEXT: beq $a0, $a3, .LBB0_8
66 ; LA64-NEXT: # %bb.5: # %entry
67 ; LA64-NEXT: ori $a2, $zero, 4
68 ; LA64-NEXT: bne $a0, $a2, .LBB0_9
69 ; LA64-NEXT: # %bb.6: # %bb4
70 ; LA64-NEXT: ori $a0, $zero, 1
71 ; LA64-NEXT: st.w $a0, $a1, 0
73 ; LA64-NEXT: .LBB0_7: # %bb1
74 ; LA64-NEXT: ori $a0, $zero, 4
75 ; LA64-NEXT: st.w $a0, $a1, 0
77 ; LA64-NEXT: .LBB0_8: # %bb3
78 ; LA64-NEXT: st.w $a2, $a1, 0
79 ; LA64-NEXT: .LBB0_9: # %exit
82 ; LA32-JT-LABEL: switch_4_arms:
83 ; LA32-JT: # %bb.0: # %entry
84 ; LA32-JT-NEXT: addi.w $a2, $a0, -1
85 ; LA32-JT-NEXT: ori $a0, $zero, 3
86 ; LA32-JT-NEXT: bltu $a0, $a2, .LBB0_6
87 ; LA32-JT-NEXT: # %bb.1: # %entry
88 ; LA32-JT-NEXT: pcalau12i $a3, %pc_hi20(.LJTI0_0)
89 ; LA32-JT-NEXT: addi.w $a3, $a3, %pc_lo12(.LJTI0_0)
90 ; LA32-JT-NEXT: alsl.w $a2, $a2, $a3, 2
91 ; LA32-JT-NEXT: ld.w $a2, $a2, 0
92 ; LA32-JT-NEXT: jr $a2
93 ; LA32-JT-NEXT: .LBB0_2: # %bb1
94 ; LA32-JT-NEXT: ori $a0, $zero, 4
95 ; LA32-JT-NEXT: b .LBB0_5
96 ; LA32-JT-NEXT: .LBB0_3: # %bb3
97 ; LA32-JT-NEXT: ori $a0, $zero, 2
98 ; LA32-JT-NEXT: b .LBB0_5
99 ; LA32-JT-NEXT: .LBB0_4: # %bb4
100 ; LA32-JT-NEXT: ori $a0, $zero, 1
101 ; LA32-JT-NEXT: .LBB0_5: # %exit
102 ; LA32-JT-NEXT: st.w $a0, $a1, 0
103 ; LA32-JT-NEXT: .LBB0_6: # %exit
106 ; LA64-JT-LABEL: switch_4_arms:
107 ; LA64-JT: # %bb.0: # %entry
108 ; LA64-JT-NEXT: addi.w $a0, $a0, 0
109 ; LA64-JT-NEXT: addi.d $a2, $a0, -1
110 ; LA64-JT-NEXT: ori $a0, $zero, 3
111 ; LA64-JT-NEXT: bltu $a0, $a2, .LBB0_6
112 ; LA64-JT-NEXT: # %bb.1: # %entry
113 ; LA64-JT-NEXT: slli.d $a2, $a2, 3
114 ; LA64-JT-NEXT: pcalau12i $a3, %pc_hi20(.LJTI0_0)
115 ; LA64-JT-NEXT: addi.d $a3, $a3, %pc_lo12(.LJTI0_0)
116 ; LA64-JT-NEXT: ldx.d $a2, $a2, $a3
117 ; LA64-JT-NEXT: jr $a2
118 ; LA64-JT-NEXT: .LBB0_2: # %bb1
119 ; LA64-JT-NEXT: ori $a0, $zero, 4
120 ; LA64-JT-NEXT: b .LBB0_5
121 ; LA64-JT-NEXT: .LBB0_3: # %bb3
122 ; LA64-JT-NEXT: ori $a0, $zero, 2
123 ; LA64-JT-NEXT: b .LBB0_5
124 ; LA64-JT-NEXT: .LBB0_4: # %bb4
125 ; LA64-JT-NEXT: ori $a0, $zero, 1
126 ; LA64-JT-NEXT: .LBB0_5: # %exit
127 ; LA64-JT-NEXT: st.w $a0, $a1, 0
128 ; LA64-JT-NEXT: .LBB0_6: # %exit
131 switch i32 %in, label %exit [
138 store i32 4, ptr %out
141 store i32 3, ptr %out
144 store i32 2, ptr %out
147 store i32 1, ptr %out