1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=mipsel-linux-gnu -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32
5 define void @sub_i32() {entry: ret void}
6 define void @sub_i8_sext() {entry: ret void}
7 define void @sub_i8_zext() {entry: ret void}
8 define void @sub_i8_aext() {entry: ret void}
9 define void @sub_i16_sext() {entry: ret void}
10 define void @sub_i16_zext() {entry: ret void}
11 define void @sub_i16_aext() {entry: ret void}
12 define void @sub_i64() {entry: ret void}
13 define void @sub_i128() {entry: ret void}
19 tracksRegLiveness: true
24 ; MIPS32-LABEL: name: sub_i32
25 ; MIPS32: liveins: $a0, $a1
26 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
27 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
28 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY]], [[COPY1]]
29 ; MIPS32: $v0 = COPY [[SUB]](s32)
30 ; MIPS32: RetRA implicit $v0
33 %2:_(s32) = G_SUB %0, %1
41 tracksRegLiveness: true
46 ; MIPS32-LABEL: name: sub_i8_sext
47 ; MIPS32: liveins: $a0, $a1
48 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
49 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
50 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32)
51 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
52 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY3]]
53 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32)
54 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
55 ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32)
56 ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32)
57 ; MIPS32: $v0 = COPY [[ASHR]](s32)
58 ; MIPS32: RetRA implicit $v0
60 %0:_(s8) = G_TRUNC %2(s32)
62 %1:_(s8) = G_TRUNC %3(s32)
63 %4:_(s8) = G_SUB %1, %0
64 %5:_(s32) = G_SEXT %4(s8)
72 tracksRegLiveness: true
77 ; MIPS32-LABEL: name: sub_i8_zext
78 ; MIPS32: liveins: $a0, $a1
79 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
80 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
81 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32)
82 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
83 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY3]]
84 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
85 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32)
86 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY4]], [[C]]
87 ; MIPS32: $v0 = COPY [[AND]](s32)
88 ; MIPS32: RetRA implicit $v0
90 %0:_(s8) = G_TRUNC %2(s32)
92 %1:_(s8) = G_TRUNC %3(s32)
93 %4:_(s8) = G_SUB %1, %0
94 %5:_(s32) = G_ZEXT %4(s8)
102 tracksRegLiveness: true
107 ; MIPS32-LABEL: name: sub_i8_aext
108 ; MIPS32: liveins: $a0, $a1
109 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
110 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
111 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32)
112 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
113 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY3]]
114 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32)
115 ; MIPS32: $v0 = COPY [[COPY4]](s32)
116 ; MIPS32: RetRA implicit $v0
118 %0:_(s8) = G_TRUNC %2(s32)
120 %1:_(s8) = G_TRUNC %3(s32)
121 %4:_(s8) = G_SUB %1, %0
122 %5:_(s32) = G_ANYEXT %4(s8)
130 tracksRegLiveness: true
135 ; MIPS32-LABEL: name: sub_i16_sext
136 ; MIPS32: liveins: $a0, $a1
137 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
138 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
139 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32)
140 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
141 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY3]]
142 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32)
143 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
144 ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32)
145 ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32)
146 ; MIPS32: $v0 = COPY [[ASHR]](s32)
147 ; MIPS32: RetRA implicit $v0
149 %0:_(s16) = G_TRUNC %2(s32)
151 %1:_(s16) = G_TRUNC %3(s32)
152 %4:_(s16) = G_SUB %1, %0
153 %5:_(s32) = G_SEXT %4(s16)
161 tracksRegLiveness: true
166 ; MIPS32-LABEL: name: sub_i16_zext
167 ; MIPS32: liveins: $a0, $a1
168 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
169 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
170 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32)
171 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
172 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY3]]
173 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
174 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32)
175 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY4]], [[C]]
176 ; MIPS32: $v0 = COPY [[AND]](s32)
177 ; MIPS32: RetRA implicit $v0
179 %0:_(s16) = G_TRUNC %2(s32)
181 %1:_(s16) = G_TRUNC %3(s32)
182 %4:_(s16) = G_SUB %1, %0
183 %5:_(s32) = G_ZEXT %4(s16)
191 tracksRegLiveness: true
196 ; MIPS32-LABEL: name: sub_i16_aext
197 ; MIPS32: liveins: $a0, $a1
198 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
199 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
200 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32)
201 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
202 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY3]]
203 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32)
204 ; MIPS32: $v0 = COPY [[COPY4]](s32)
205 ; MIPS32: RetRA implicit $v0
207 %0:_(s16) = G_TRUNC %2(s32)
209 %1:_(s16) = G_TRUNC %3(s32)
210 %4:_(s16) = G_SUB %1, %0
211 %5:_(s32) = G_ANYEXT %4(s16)
219 tracksRegLiveness: true
222 liveins: $a0, $a1, $a2, $a3
224 ; MIPS32-LABEL: name: sub_i64
225 ; MIPS32: liveins: $a0, $a1, $a2, $a3
226 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
227 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
228 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
229 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY $a3
230 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY3]], [[COPY1]]
231 ; MIPS32: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[COPY3]](s32), [[COPY1]]
232 ; MIPS32: [[SUB1:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY]]
233 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
234 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ICMP]](s32)
235 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY4]], [[C]]
236 ; MIPS32: [[SUB2:%[0-9]+]]:_(s32) = G_SUB [[SUB1]], [[AND]]
237 ; MIPS32: $v0 = COPY [[SUB2]](s32)
238 ; MIPS32: $v1 = COPY [[SUB]](s32)
239 ; MIPS32: RetRA implicit $v0, implicit $v1
242 %0:_(s64) = G_MERGE_VALUES %3(s32), %2(s32)
245 %1:_(s64) = G_MERGE_VALUES %5(s32), %4(s32)
246 %6:_(s64) = G_SUB %1, %0
247 %7:_(s32), %8:_(s32) = G_UNMERGE_VALUES %6(s64)
250 RetRA implicit $v0, implicit $v1
256 tracksRegLiveness: true
258 - { id: 0, offset: 28, size: 4, alignment: 4, stack-id: default, isImmutable: true }
259 - { id: 1, offset: 24, size: 4, alignment: 8, stack-id: default, isImmutable: true }
260 - { id: 2, offset: 20, size: 4, alignment: 4, stack-id: default, isImmutable: true }
261 - { id: 3, offset: 16, size: 4, alignment: 8, stack-id: default, isImmutable: true }
264 liveins: $a0, $a1, $a2, $a3
266 ; MIPS32-LABEL: name: sub_i128
267 ; MIPS32: liveins: $a0, $a1, $a2, $a3
268 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
269 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
270 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
271 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY $a3
272 ; MIPS32: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
273 ; MIPS32: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load 4 from %fixed-stack.0, align 8)
274 ; MIPS32: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
275 ; MIPS32: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load 4 from %fixed-stack.1)
276 ; MIPS32: [[FRAME_INDEX2:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.2
277 ; MIPS32: [[LOAD2:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX2]](p0) :: (load 4 from %fixed-stack.2, align 8)
278 ; MIPS32: [[FRAME_INDEX3:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.3
279 ; MIPS32: [[LOAD3:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX3]](p0) :: (load 4 from %fixed-stack.3)
280 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[LOAD]], [[COPY]]
281 ; MIPS32: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[LOAD]](s32), [[COPY]]
282 ; MIPS32: [[SUB1:%[0-9]+]]:_(s32) = G_SUB [[LOAD1]], [[COPY1]]
283 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
284 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ICMP]](s32)
285 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY4]], [[C]]
286 ; MIPS32: [[SUB2:%[0-9]+]]:_(s32) = G_SUB [[SUB1]], [[AND]]
287 ; MIPS32: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[LOAD1]](s32), [[COPY1]]
288 ; MIPS32: [[ICMP2:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[LOAD1]](s32), [[COPY1]]
289 ; MIPS32: [[COPY5:%[0-9]+]]:_(s32) = COPY [[ICMP]](s32)
290 ; MIPS32: [[COPY6:%[0-9]+]]:_(s32) = COPY [[ICMP2]](s32)
291 ; MIPS32: [[COPY7:%[0-9]+]]:_(s32) = COPY [[ICMP1]](s32)
292 ; MIPS32: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY7]], [[C]]
293 ; MIPS32: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND1]](s32), [[COPY5]], [[COPY6]]
294 ; MIPS32: [[SUB3:%[0-9]+]]:_(s32) = G_SUB [[LOAD2]], [[COPY2]]
295 ; MIPS32: [[COPY8:%[0-9]+]]:_(s32) = COPY [[SELECT]](s32)
296 ; MIPS32: [[AND2:%[0-9]+]]:_(s32) = G_AND [[COPY8]], [[C]]
297 ; MIPS32: [[SUB4:%[0-9]+]]:_(s32) = G_SUB [[SUB3]], [[AND2]]
298 ; MIPS32: [[ICMP3:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[LOAD2]](s32), [[COPY2]]
299 ; MIPS32: [[ICMP4:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[LOAD2]](s32), [[COPY2]]
300 ; MIPS32: [[COPY9:%[0-9]+]]:_(s32) = COPY [[SELECT]](s32)
301 ; MIPS32: [[COPY10:%[0-9]+]]:_(s32) = COPY [[ICMP4]](s32)
302 ; MIPS32: [[COPY11:%[0-9]+]]:_(s32) = COPY [[ICMP3]](s32)
303 ; MIPS32: [[AND3:%[0-9]+]]:_(s32) = G_AND [[COPY11]], [[C]]
304 ; MIPS32: [[SELECT1:%[0-9]+]]:_(s32) = G_SELECT [[AND3]](s32), [[COPY9]], [[COPY10]]
305 ; MIPS32: [[SUB5:%[0-9]+]]:_(s32) = G_SUB [[LOAD3]], [[COPY3]]
306 ; MIPS32: [[COPY12:%[0-9]+]]:_(s32) = COPY [[SELECT1]](s32)
307 ; MIPS32: [[AND4:%[0-9]+]]:_(s32) = G_AND [[COPY12]], [[C]]
308 ; MIPS32: [[SUB6:%[0-9]+]]:_(s32) = G_SUB [[SUB5]], [[AND4]]
309 ; MIPS32: $v0 = COPY [[SUB]](s32)
310 ; MIPS32: $v1 = COPY [[SUB2]](s32)
311 ; MIPS32: $a0 = COPY [[SUB4]](s32)
312 ; MIPS32: $a1 = COPY [[SUB6]](s32)
313 ; MIPS32: RetRA implicit $v0, implicit $v1, implicit $a0, implicit $a1
318 %0:_(s128) = G_MERGE_VALUES %2(s32), %3(s32), %4(s32), %5(s32)
319 %10:_(p0) = G_FRAME_INDEX %fixed-stack.3
320 %6:_(s32) = G_LOAD %10(p0) :: (load 4 from %fixed-stack.3, align 8)
321 %11:_(p0) = G_FRAME_INDEX %fixed-stack.2
322 %7:_(s32) = G_LOAD %11(p0) :: (load 4 from %fixed-stack.2, align 4)
323 %12:_(p0) = G_FRAME_INDEX %fixed-stack.1
324 %8:_(s32) = G_LOAD %12(p0) :: (load 4 from %fixed-stack.1, align 8)
325 %13:_(p0) = G_FRAME_INDEX %fixed-stack.0
326 %9:_(s32) = G_LOAD %13(p0) :: (load 4 from %fixed-stack.0, align 4)
327 %1:_(s128) = G_MERGE_VALUES %6(s32), %7(s32), %8(s32), %9(s32)
328 %14:_(s128) = G_SUB %1, %0
329 %15:_(s32), %16:_(s32), %17:_(s32), %18:_(s32) = G_UNMERGE_VALUES %14(s128)
334 RetRA implicit $v0, implicit $v1, implicit $a0, implicit $a1