1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=mipsel-linux-gnu -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32
3 # RUN: llc -O0 -mtriple=mipsel-linux-gnu -relocation-model=pic -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32_PIC
6 define i32 @mod4_0_to_11(i32 %a) {
8 switch i32 %a, label %sw.default [
19 sw.bb: ; preds = %entry, %entry
22 sw.bb1: ; preds = %entry, %entry
25 sw.bb2: ; preds = %entry, %entry
28 sw.bb3: ; preds = %entry, %entry
31 sw.default: ; preds = %entry
34 sw.epilog: ; preds = %sw.default
35 switch i32 %a, label %sw.default8 [
42 sw.bb4: ; preds = %sw.epilog
45 sw.bb5: ; preds = %sw.epilog
48 sw.bb6: ; preds = %sw.epilog
51 sw.bb7: ; preds = %sw.epilog
54 sw.default8: ; preds = %sw.epilog
64 tracksRegLiveness: true
69 blocks: [ '%bb.2', '%bb.3', '%bb.4', '%bb.5', '%bb.2', '%bb.3',
72 blocks: [ '%bb.8', '%bb.9', '%bb.10', '%bb.11' ]
74 ; MIPS32-LABEL: name: mod4_0_to_11
76 ; MIPS32: successors: %bb.6(0x40000000), %bb.1(0x40000000)
77 ; MIPS32: liveins: $a0
78 ; MIPS32: [[COPY:%[0-9]+]]:gpr32 = COPY $a0
79 ; MIPS32: [[ORi:%[0-9]+]]:gpr32 = ORi $zero, 7
80 ; MIPS32: [[ORi1:%[0-9]+]]:gpr32 = ORi $zero, 3
81 ; MIPS32: [[ORi2:%[0-9]+]]:gpr32 = ORi $zero, 2
82 ; MIPS32: [[ORi3:%[0-9]+]]:gpr32 = ORi $zero, 1
83 ; MIPS32: [[ORi4:%[0-9]+]]:gpr32 = ORi $zero, 0
84 ; MIPS32: [[ADDiu:%[0-9]+]]:gpr32 = ADDiu $zero, 65535
85 ; MIPS32: [[ORi5:%[0-9]+]]:gpr32 = ORi $zero, 0
86 ; MIPS32: [[SUBu:%[0-9]+]]:gpr32 = SUBu [[COPY]], [[ORi5]]
87 ; MIPS32: [[SLTu:%[0-9]+]]:gpr32 = SLTu [[ORi]], [[SUBu]]
88 ; MIPS32: [[ANDi:%[0-9]+]]:gpr32 = ANDi [[SLTu]], 1
89 ; MIPS32: BNE [[ANDi]], $zero, %bb.6, implicit-def $at
91 ; MIPS32: successors: %bb.2(0x20000000), %bb.3(0x20000000), %bb.4(0x20000000), %bb.5(0x20000000)
92 ; MIPS32: [[LUi:%[0-9]+]]:gpr32 = LUi target-flags(mips-abs-hi) %jump-table.0
93 ; MIPS32: [[SLL:%[0-9]+]]:gpr32 = SLL [[SUBu]], 2
94 ; MIPS32: [[ADDu:%[0-9]+]]:gpr32 = ADDu [[LUi]], [[SLL]]
95 ; MIPS32: [[LW:%[0-9]+]]:gpr32 = LW [[ADDu]], target-flags(mips-abs-lo) %jump-table.0 :: (load (s32))
96 ; MIPS32: PseudoIndirectBranch [[LW]]
98 ; MIPS32: $v0 = COPY [[ORi4]]
99 ; MIPS32: RetRA implicit $v0
100 ; MIPS32: bb.3.sw.bb1:
101 ; MIPS32: $v0 = COPY [[ORi3]]
102 ; MIPS32: RetRA implicit $v0
103 ; MIPS32: bb.4.sw.bb2:
104 ; MIPS32: $v0 = COPY [[ORi2]]
105 ; MIPS32: RetRA implicit $v0
106 ; MIPS32: bb.5.sw.bb3:
107 ; MIPS32: $v0 = COPY [[ORi1]]
108 ; MIPS32: RetRA implicit $v0
109 ; MIPS32: bb.6.sw.default:
110 ; MIPS32: successors: %bb.7(0x80000000)
111 ; MIPS32: bb.7.sw.epilog:
112 ; MIPS32: successors: %bb.13(0x40000000), %bb.8(0x40000000)
113 ; MIPS32: [[ORi6:%[0-9]+]]:gpr32 = ORi $zero, 8
114 ; MIPS32: [[SUBu1:%[0-9]+]]:gpr32 = SUBu [[COPY]], [[ORi6]]
115 ; MIPS32: [[SLTu1:%[0-9]+]]:gpr32 = SLTu [[ORi1]], [[SUBu1]]
116 ; MIPS32: [[ANDi1:%[0-9]+]]:gpr32 = ANDi [[SLTu1]], 1
117 ; MIPS32: BNE [[ANDi1]], $zero, %bb.13, implicit-def $at
118 ; MIPS32: bb.8.sw.epilog:
119 ; MIPS32: successors: %bb.9(0x20000000), %bb.10(0x20000000), %bb.11(0x20000000), %bb.12(0x20000000)
120 ; MIPS32: [[LUi1:%[0-9]+]]:gpr32 = LUi target-flags(mips-abs-hi) %jump-table.1
121 ; MIPS32: [[SLL1:%[0-9]+]]:gpr32 = SLL [[SUBu1]], 2
122 ; MIPS32: [[ADDu1:%[0-9]+]]:gpr32 = ADDu [[LUi1]], [[SLL1]]
123 ; MIPS32: [[LW1:%[0-9]+]]:gpr32 = LW [[ADDu1]], target-flags(mips-abs-lo) %jump-table.1 :: (load (s32))
124 ; MIPS32: PseudoIndirectBranch [[LW1]]
125 ; MIPS32: bb.9.sw.bb4:
126 ; MIPS32: $v0 = COPY [[ORi4]]
127 ; MIPS32: RetRA implicit $v0
128 ; MIPS32: bb.10.sw.bb5:
129 ; MIPS32: $v0 = COPY [[ORi3]]
130 ; MIPS32: RetRA implicit $v0
131 ; MIPS32: bb.11.sw.bb6:
132 ; MIPS32: $v0 = COPY [[ORi2]]
133 ; MIPS32: RetRA implicit $v0
134 ; MIPS32: bb.12.sw.bb7:
135 ; MIPS32: $v0 = COPY [[ORi1]]
136 ; MIPS32: RetRA implicit $v0
137 ; MIPS32: bb.13.sw.default8:
138 ; MIPS32: $v0 = COPY [[ADDiu]]
139 ; MIPS32: RetRA implicit $v0
140 ; MIPS32_PIC-LABEL: name: mod4_0_to_11
141 ; MIPS32_PIC: bb.0.entry:
142 ; MIPS32_PIC: successors: %bb.6(0x40000000), %bb.1(0x40000000)
143 ; MIPS32_PIC: liveins: $a0, $t9, $v0
144 ; MIPS32_PIC: [[ADDu:%[0-9]+]]:gpr32 = ADDu $v0, $t9
145 ; MIPS32_PIC: [[COPY:%[0-9]+]]:gpr32 = COPY $a0
146 ; MIPS32_PIC: [[ORi:%[0-9]+]]:gpr32 = ORi $zero, 7
147 ; MIPS32_PIC: [[ORi1:%[0-9]+]]:gpr32 = ORi $zero, 3
148 ; MIPS32_PIC: [[ORi2:%[0-9]+]]:gpr32 = ORi $zero, 2
149 ; MIPS32_PIC: [[ORi3:%[0-9]+]]:gpr32 = ORi $zero, 1
150 ; MIPS32_PIC: [[ORi4:%[0-9]+]]:gpr32 = ORi $zero, 0
151 ; MIPS32_PIC: [[ADDiu:%[0-9]+]]:gpr32 = ADDiu $zero, 65535
152 ; MIPS32_PIC: [[ORi5:%[0-9]+]]:gpr32 = ORi $zero, 0
153 ; MIPS32_PIC: [[SUBu:%[0-9]+]]:gpr32 = SUBu [[COPY]], [[ORi5]]
154 ; MIPS32_PIC: [[SLTu:%[0-9]+]]:gpr32 = SLTu [[ORi]], [[SUBu]]
155 ; MIPS32_PIC: [[ANDi:%[0-9]+]]:gpr32 = ANDi [[SLTu]], 1
156 ; MIPS32_PIC: BNE [[ANDi]], $zero, %bb.6, implicit-def $at
157 ; MIPS32_PIC: bb.1.entry:
158 ; MIPS32_PIC: successors: %bb.2(0x20000000), %bb.3(0x20000000), %bb.4(0x20000000), %bb.5(0x20000000)
159 ; MIPS32_PIC: [[LW:%[0-9]+]]:gpr32 = LW [[ADDu]], target-flags(mips-got) %jump-table.0 :: (load (s32) from got)
160 ; MIPS32_PIC: [[SLL:%[0-9]+]]:gpr32 = SLL [[SUBu]], 2
161 ; MIPS32_PIC: [[ADDu1:%[0-9]+]]:gpr32 = ADDu [[LW]], [[SLL]]
162 ; MIPS32_PIC: [[LW1:%[0-9]+]]:gpr32 = LW [[ADDu1]], target-flags(mips-abs-lo) %jump-table.0 :: (load (s32))
163 ; MIPS32_PIC: [[ADDu2:%[0-9]+]]:gpr32 = ADDu [[LW1]], [[ADDu]]
164 ; MIPS32_PIC: PseudoIndirectBranch [[ADDu2]]
165 ; MIPS32_PIC: bb.2.sw.bb:
166 ; MIPS32_PIC: $v0 = COPY [[ORi4]]
167 ; MIPS32_PIC: RetRA implicit $v0
168 ; MIPS32_PIC: bb.3.sw.bb1:
169 ; MIPS32_PIC: $v0 = COPY [[ORi3]]
170 ; MIPS32_PIC: RetRA implicit $v0
171 ; MIPS32_PIC: bb.4.sw.bb2:
172 ; MIPS32_PIC: $v0 = COPY [[ORi2]]
173 ; MIPS32_PIC: RetRA implicit $v0
174 ; MIPS32_PIC: bb.5.sw.bb3:
175 ; MIPS32_PIC: $v0 = COPY [[ORi1]]
176 ; MIPS32_PIC: RetRA implicit $v0
177 ; MIPS32_PIC: bb.6.sw.default:
178 ; MIPS32_PIC: successors: %bb.7(0x80000000)
179 ; MIPS32_PIC: bb.7.sw.epilog:
180 ; MIPS32_PIC: successors: %bb.13(0x40000000), %bb.8(0x40000000)
181 ; MIPS32_PIC: [[ORi6:%[0-9]+]]:gpr32 = ORi $zero, 8
182 ; MIPS32_PIC: [[SUBu1:%[0-9]+]]:gpr32 = SUBu [[COPY]], [[ORi6]]
183 ; MIPS32_PIC: [[SLTu1:%[0-9]+]]:gpr32 = SLTu [[ORi1]], [[SUBu1]]
184 ; MIPS32_PIC: [[ANDi1:%[0-9]+]]:gpr32 = ANDi [[SLTu1]], 1
185 ; MIPS32_PIC: BNE [[ANDi1]], $zero, %bb.13, implicit-def $at
186 ; MIPS32_PIC: bb.8.sw.epilog:
187 ; MIPS32_PIC: successors: %bb.9(0x20000000), %bb.10(0x20000000), %bb.11(0x20000000), %bb.12(0x20000000)
188 ; MIPS32_PIC: [[LW2:%[0-9]+]]:gpr32 = LW [[ADDu]], target-flags(mips-got) %jump-table.1 :: (load (s32) from got)
189 ; MIPS32_PIC: [[SLL1:%[0-9]+]]:gpr32 = SLL [[SUBu1]], 2
190 ; MIPS32_PIC: [[ADDu3:%[0-9]+]]:gpr32 = ADDu [[LW2]], [[SLL1]]
191 ; MIPS32_PIC: [[LW3:%[0-9]+]]:gpr32 = LW [[ADDu3]], target-flags(mips-abs-lo) %jump-table.1 :: (load (s32))
192 ; MIPS32_PIC: [[ADDu4:%[0-9]+]]:gpr32 = ADDu [[LW3]], [[ADDu]]
193 ; MIPS32_PIC: PseudoIndirectBranch [[ADDu4]]
194 ; MIPS32_PIC: bb.9.sw.bb4:
195 ; MIPS32_PIC: $v0 = COPY [[ORi4]]
196 ; MIPS32_PIC: RetRA implicit $v0
197 ; MIPS32_PIC: bb.10.sw.bb5:
198 ; MIPS32_PIC: $v0 = COPY [[ORi3]]
199 ; MIPS32_PIC: RetRA implicit $v0
200 ; MIPS32_PIC: bb.11.sw.bb6:
201 ; MIPS32_PIC: $v0 = COPY [[ORi2]]
202 ; MIPS32_PIC: RetRA implicit $v0
203 ; MIPS32_PIC: bb.12.sw.bb7:
204 ; MIPS32_PIC: $v0 = COPY [[ORi1]]
205 ; MIPS32_PIC: RetRA implicit $v0
206 ; MIPS32_PIC: bb.13.sw.default8:
207 ; MIPS32_PIC: $v0 = COPY [[ADDiu]]
208 ; MIPS32_PIC: RetRA implicit $v0
212 %0:gprb(s32) = COPY $a0
213 %4:gprb(s32) = G_CONSTANT i32 7
214 %8:gprb(s32) = G_CONSTANT i32 3
215 %9:gprb(s32) = G_CONSTANT i32 2
216 %10:gprb(s32) = G_CONSTANT i32 1
217 %11:gprb(s32) = G_CONSTANT i32 0
218 %18:gprb(s32) = G_CONSTANT i32 -1
219 %1:gprb(s32) = G_CONSTANT i32 0
220 %2:gprb(s32) = G_SUB %0, %1
221 %3:gprb(s32) = COPY %2(s32)
222 %5:gprb(s32) = COPY %4(s32)
223 %22:gprb(s32) = G_ICMP intpred(ugt), %3(s32), %5
224 %23:gprb(s32) = COPY %22(s32)
225 %21:gprb(s32) = G_AND %23, %10
226 G_BRCOND %21(s32), %bb.6
229 successors: %bb.2, %bb.3, %bb.4, %bb.5
231 %7:gprb(p0) = G_JUMP_TABLE %jump-table.0
232 G_BRJT %7(p0), %jump-table.0, %3(s32)
253 %12:gprb(s32) = G_CONSTANT i32 8
254 %13:gprb(s32) = G_SUB %0, %12
255 %14:gprb(s32) = COPY %13(s32)
256 %15:gprb(s32) = COPY %8(s32)
257 %20:gprb(s32) = G_ICMP intpred(ugt), %14(s32), %15
258 %24:gprb(s32) = G_CONSTANT i32 1
259 %25:gprb(s32) = COPY %20(s32)
260 %19:gprb(s32) = G_AND %25, %24
261 G_BRCOND %19(s32), %bb.12
264 successors: %bb.8, %bb.9, %bb.10, %bb.11
266 %17:gprb(p0) = G_JUMP_TABLE %jump-table.1
267 G_BRJT %17(p0), %jump-table.1, %14(s32)