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: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY1]], [[COPY]]
51 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
52 ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[SUB]], [[C]](s32)
53 ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32)
54 ; MIPS32: $v0 = COPY [[ASHR]](s32)
55 ; MIPS32: RetRA implicit $v0
57 %0:_(s8) = G_TRUNC %2(s32)
59 %1:_(s8) = G_TRUNC %3(s32)
60 %4:_(s8) = G_SUB %1, %0
61 %5:_(s32) = G_SEXT %4(s8)
69 tracksRegLiveness: true
74 ; MIPS32-LABEL: name: sub_i8_zext
75 ; MIPS32: liveins: $a0, $a1
76 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
77 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
78 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY1]], [[COPY]]
79 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
80 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[SUB]], [[C]]
81 ; MIPS32: $v0 = COPY [[AND]](s32)
82 ; MIPS32: RetRA implicit $v0
84 %0:_(s8) = G_TRUNC %2(s32)
86 %1:_(s8) = G_TRUNC %3(s32)
87 %4:_(s8) = G_SUB %1, %0
88 %5:_(s32) = G_ZEXT %4(s8)
96 tracksRegLiveness: true
101 ; MIPS32-LABEL: name: sub_i8_aext
102 ; MIPS32: liveins: $a0, $a1
103 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
104 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
105 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY1]], [[COPY]]
106 ; MIPS32: $v0 = COPY [[SUB]](s32)
107 ; MIPS32: RetRA implicit $v0
109 %0:_(s8) = G_TRUNC %2(s32)
111 %1:_(s8) = G_TRUNC %3(s32)
112 %4:_(s8) = G_SUB %1, %0
113 %5:_(s32) = G_ANYEXT %4(s8)
121 tracksRegLiveness: true
126 ; MIPS32-LABEL: name: sub_i16_sext
127 ; MIPS32: liveins: $a0, $a1
128 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
129 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
130 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY1]], [[COPY]]
131 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
132 ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[SUB]], [[C]](s32)
133 ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32)
134 ; MIPS32: $v0 = COPY [[ASHR]](s32)
135 ; MIPS32: RetRA implicit $v0
137 %0:_(s16) = G_TRUNC %2(s32)
139 %1:_(s16) = G_TRUNC %3(s32)
140 %4:_(s16) = G_SUB %1, %0
141 %5:_(s32) = G_SEXT %4(s16)
149 tracksRegLiveness: true
154 ; MIPS32-LABEL: name: sub_i16_zext
155 ; MIPS32: liveins: $a0, $a1
156 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
157 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
158 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY1]], [[COPY]]
159 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
160 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[SUB]], [[C]]
161 ; MIPS32: $v0 = COPY [[AND]](s32)
162 ; MIPS32: RetRA implicit $v0
164 %0:_(s16) = G_TRUNC %2(s32)
166 %1:_(s16) = G_TRUNC %3(s32)
167 %4:_(s16) = G_SUB %1, %0
168 %5:_(s32) = G_ZEXT %4(s16)
176 tracksRegLiveness: true
181 ; MIPS32-LABEL: name: sub_i16_aext
182 ; MIPS32: liveins: $a0, $a1
183 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
184 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
185 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY1]], [[COPY]]
186 ; MIPS32: $v0 = COPY [[SUB]](s32)
187 ; MIPS32: RetRA implicit $v0
189 %0:_(s16) = G_TRUNC %2(s32)
191 %1:_(s16) = G_TRUNC %3(s32)
192 %4:_(s16) = G_SUB %1, %0
193 %5:_(s32) = G_ANYEXT %4(s16)
201 tracksRegLiveness: true
204 liveins: $a0, $a1, $a2, $a3
206 ; MIPS32-LABEL: name: sub_i64
207 ; MIPS32: liveins: $a0, $a1, $a2, $a3
208 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
209 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
210 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
211 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY $a3
212 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY3]], [[COPY1]]
213 ; MIPS32: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[COPY3]](s32), [[COPY1]]
214 ; MIPS32: [[SUB1:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY]]
215 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
216 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]]
217 ; MIPS32: [[SUB2:%[0-9]+]]:_(s32) = G_SUB [[SUB1]], [[AND]]
218 ; MIPS32: $v0 = COPY [[SUB2]](s32)
219 ; MIPS32: $v1 = COPY [[SUB]](s32)
220 ; MIPS32: RetRA implicit $v0, implicit $v1
223 %0:_(s64) = G_MERGE_VALUES %3(s32), %2(s32)
226 %1:_(s64) = G_MERGE_VALUES %5(s32), %4(s32)
227 %6:_(s64) = G_SUB %1, %0
228 %7:_(s32), %8:_(s32) = G_UNMERGE_VALUES %6(s64)
231 RetRA implicit $v0, implicit $v1
237 tracksRegLiveness: true
239 - { id: 0, offset: 28, size: 4, alignment: 4, stack-id: default, isImmutable: true }
240 - { id: 1, offset: 24, size: 4, alignment: 8, stack-id: default, isImmutable: true }
241 - { id: 2, offset: 20, size: 4, alignment: 4, stack-id: default, isImmutable: true }
242 - { id: 3, offset: 16, size: 4, alignment: 8, stack-id: default, isImmutable: true }
245 liveins: $a0, $a1, $a2, $a3
247 ; MIPS32-LABEL: name: sub_i128
248 ; MIPS32: liveins: $a0, $a1, $a2, $a3
249 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
250 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
251 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
252 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY $a3
253 ; MIPS32: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
254 ; MIPS32: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0, align 8)
255 ; MIPS32: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
256 ; MIPS32: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s32) from %fixed-stack.1)
257 ; MIPS32: [[FRAME_INDEX2:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.2
258 ; MIPS32: [[LOAD2:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX2]](p0) :: (load (s32) from %fixed-stack.2, align 8)
259 ; MIPS32: [[FRAME_INDEX3:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.3
260 ; MIPS32: [[LOAD3:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX3]](p0) :: (load (s32) from %fixed-stack.3)
261 ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[LOAD]], [[COPY]]
262 ; MIPS32: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[LOAD]](s32), [[COPY]]
263 ; MIPS32: [[SUB1:%[0-9]+]]:_(s32) = G_SUB [[LOAD1]], [[COPY1]]
264 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
265 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]]
266 ; MIPS32: [[SUB2:%[0-9]+]]:_(s32) = G_SUB [[SUB1]], [[AND]]
267 ; MIPS32: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[LOAD1]](s32), [[COPY1]]
268 ; MIPS32: [[ICMP2:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[LOAD1]](s32), [[COPY1]]
269 ; MIPS32: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ICMP1]], [[C]]
270 ; MIPS32: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND1]](s32), [[ICMP]], [[ICMP2]]
271 ; MIPS32: [[SUB3:%[0-9]+]]:_(s32) = G_SUB [[LOAD2]], [[COPY2]]
272 ; MIPS32: [[AND2:%[0-9]+]]:_(s32) = G_AND [[SELECT]], [[C]]
273 ; MIPS32: [[SUB4:%[0-9]+]]:_(s32) = G_SUB [[SUB3]], [[AND2]]
274 ; MIPS32: [[ICMP3:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[LOAD2]](s32), [[COPY2]]
275 ; MIPS32: [[ICMP4:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[LOAD2]](s32), [[COPY2]]
276 ; MIPS32: [[AND3:%[0-9]+]]:_(s32) = G_AND [[ICMP3]], [[C]]
277 ; MIPS32: [[SELECT1:%[0-9]+]]:_(s32) = G_SELECT [[AND3]](s32), [[SELECT]], [[ICMP4]]
278 ; MIPS32: [[SUB5:%[0-9]+]]:_(s32) = G_SUB [[LOAD3]], [[COPY3]]
279 ; MIPS32: [[AND4:%[0-9]+]]:_(s32) = G_AND [[SELECT1]], [[C]]
280 ; MIPS32: [[SUB6:%[0-9]+]]:_(s32) = G_SUB [[SUB5]], [[AND4]]
281 ; MIPS32: $v0 = COPY [[SUB]](s32)
282 ; MIPS32: $v1 = COPY [[SUB2]](s32)
283 ; MIPS32: $a0 = COPY [[SUB4]](s32)
284 ; MIPS32: $a1 = COPY [[SUB6]](s32)
285 ; MIPS32: RetRA implicit $v0, implicit $v1, implicit $a0, implicit $a1
290 %0:_(s128) = G_MERGE_VALUES %2(s32), %3(s32), %4(s32), %5(s32)
291 %10:_(p0) = G_FRAME_INDEX %fixed-stack.3
292 %6:_(s32) = G_LOAD %10(p0) :: (load (s32) from %fixed-stack.3, align 8)
293 %11:_(p0) = G_FRAME_INDEX %fixed-stack.2
294 %7:_(s32) = G_LOAD %11(p0) :: (load (s32) from %fixed-stack.2, align 4)
295 %12:_(p0) = G_FRAME_INDEX %fixed-stack.1
296 %8:_(s32) = G_LOAD %12(p0) :: (load (s32) from %fixed-stack.1, align 8)
297 %13:_(p0) = G_FRAME_INDEX %fixed-stack.0
298 %9:_(s32) = G_LOAD %13(p0) :: (load (s32) from %fixed-stack.0, align 4)
299 %1:_(s128) = G_MERGE_VALUES %6(s32), %7(s32), %8(s32), %9(s32)
300 %14:_(s128) = G_SUB %1, %0
301 %15:_(s32), %16:_(s32), %17:_(s32), %18:_(s32) = G_UNMERGE_VALUES %14(s128)
306 RetRA implicit $v0, implicit $v1, implicit $a0, implicit $a1