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 @add_i32() {entry: ret void}
6 define void @add_i8_sext() {entry: ret void}
7 define void @add_i8_zext() {entry: ret void}
8 define void @add_i8_aext() {entry: ret void}
9 define void @add_i16_sext() {entry: ret void}
10 define void @add_i16_zext() {entry: ret void}
11 define void @add_i16_aext() {entry: ret void}
12 define void @add_i64() {entry: ret void}
13 define void @add_i128() {entry: ret void}
14 define void @uadd_with_overflow(i32 %lhs, i32 %rhs, ptr %padd, ptr %pcarry_flag) { ret void }
20 tracksRegLiveness: true
25 ; MIPS32-LABEL: name: add_i32
26 ; MIPS32: liveins: $a0, $a1
27 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
28 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
29 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[COPY1]]
30 ; MIPS32: $v0 = COPY [[ADD]](s32)
31 ; MIPS32: RetRA implicit $v0
34 %2:_(s32) = G_ADD %0, %1
42 tracksRegLiveness: true
47 ; MIPS32-LABEL: name: add_i8_sext
48 ; MIPS32: liveins: $a0, $a1
49 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
50 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
51 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[COPY]]
52 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
53 ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[ADD]], [[C]](s32)
54 ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32)
55 ; MIPS32: $v0 = COPY [[ASHR]](s32)
56 ; MIPS32: RetRA implicit $v0
58 %0:_(s8) = G_TRUNC %2(s32)
60 %1:_(s8) = G_TRUNC %3(s32)
61 %4:_(s8) = G_ADD %1, %0
62 %5:_(s32) = G_SEXT %4(s8)
70 tracksRegLiveness: true
75 ; MIPS32-LABEL: name: add_i8_zext
76 ; MIPS32: liveins: $a0, $a1
77 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
78 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
79 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[COPY]]
80 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
81 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
82 ; MIPS32: $v0 = COPY [[AND]](s32)
83 ; MIPS32: RetRA implicit $v0
85 %0:_(s8) = G_TRUNC %2(s32)
87 %1:_(s8) = G_TRUNC %3(s32)
88 %4:_(s8) = G_ADD %1, %0
89 %5:_(s32) = G_ZEXT %4(s8)
97 tracksRegLiveness: true
102 ; MIPS32-LABEL: name: add_i8_aext
103 ; MIPS32: liveins: $a0, $a1
104 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
105 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
106 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[COPY]]
107 ; MIPS32: $v0 = COPY [[ADD]](s32)
108 ; MIPS32: RetRA implicit $v0
110 %0:_(s8) = G_TRUNC %2(s32)
112 %1:_(s8) = G_TRUNC %3(s32)
113 %4:_(s8) = G_ADD %1, %0
114 %5:_(s32) = G_ANYEXT %4(s8)
122 tracksRegLiveness: true
127 ; MIPS32-LABEL: name: add_i16_sext
128 ; MIPS32: liveins: $a0, $a1
129 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
130 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
131 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[COPY]]
132 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
133 ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[ADD]], [[C]](s32)
134 ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32)
135 ; MIPS32: $v0 = COPY [[ASHR]](s32)
136 ; MIPS32: RetRA implicit $v0
138 %0:_(s16) = G_TRUNC %2(s32)
140 %1:_(s16) = G_TRUNC %3(s32)
141 %4:_(s16) = G_ADD %1, %0
142 %5:_(s32) = G_SEXT %4(s16)
150 tracksRegLiveness: true
155 ; MIPS32-LABEL: name: add_i16_zext
156 ; MIPS32: liveins: $a0, $a1
157 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
158 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
159 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[COPY]]
160 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
161 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
162 ; MIPS32: $v0 = COPY [[AND]](s32)
163 ; MIPS32: RetRA implicit $v0
165 %0:_(s16) = G_TRUNC %2(s32)
167 %1:_(s16) = G_TRUNC %3(s32)
168 %4:_(s16) = G_ADD %1, %0
169 %5:_(s32) = G_ZEXT %4(s16)
177 tracksRegLiveness: true
182 ; MIPS32-LABEL: name: add_i16_aext
183 ; MIPS32: liveins: $a0, $a1
184 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
185 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
186 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[COPY]]
187 ; MIPS32: $v0 = COPY [[ADD]](s32)
188 ; MIPS32: RetRA implicit $v0
190 %0:_(s16) = G_TRUNC %2(s32)
192 %1:_(s16) = G_TRUNC %3(s32)
193 %4:_(s16) = G_ADD %1, %0
194 %5:_(s32) = G_ANYEXT %4(s16)
202 tracksRegLiveness: true
205 liveins: $a0, $a1, $a2, $a3
207 ; MIPS32-LABEL: name: add_i64
208 ; MIPS32: liveins: $a0, $a1, $a2, $a3
209 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
210 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
211 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
212 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY $a3
213 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY3]], [[COPY1]]
214 ; MIPS32: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[ADD]](s32), [[COPY1]]
215 ; MIPS32: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY2]], [[COPY]]
216 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
217 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]]
218 ; MIPS32: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[ADD1]], [[AND]]
219 ; MIPS32: $v0 = COPY [[ADD2]](s32)
220 ; MIPS32: $v1 = COPY [[ADD]](s32)
221 ; MIPS32: RetRA implicit $v0, implicit $v1
224 %0:_(s64) = G_MERGE_VALUES %3(s32), %2(s32)
227 %1:_(s64) = G_MERGE_VALUES %5(s32), %4(s32)
228 %6:_(s64) = G_ADD %1, %0
229 %7:_(s32), %8:_(s32) = G_UNMERGE_VALUES %6(s64)
232 RetRA implicit $v0, implicit $v1
238 tracksRegLiveness: true
240 - { id: 0, offset: 28, size: 4, alignment: 4, stack-id: default, isImmutable: true }
241 - { id: 1, offset: 24, size: 4, alignment: 8, stack-id: default, isImmutable: true }
242 - { id: 2, offset: 20, size: 4, alignment: 4, stack-id: default, isImmutable: true }
243 - { id: 3, offset: 16, size: 4, alignment: 8, stack-id: default, isImmutable: true }
246 liveins: $a0, $a1, $a2, $a3
248 ; MIPS32-LABEL: name: add_i128
249 ; MIPS32: liveins: $a0, $a1, $a2, $a3
250 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
251 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
252 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
253 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY $a3
254 ; MIPS32: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
255 ; MIPS32: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0)
256 ; MIPS32: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
257 ; MIPS32: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s32) from %fixed-stack.1)
258 ; MIPS32: [[FRAME_INDEX2:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.2
259 ; MIPS32: [[LOAD2:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX2]](p0) :: (load (s32) from %fixed-stack.2)
260 ; MIPS32: [[FRAME_INDEX3:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.3
261 ; MIPS32: [[LOAD3:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX3]](p0) :: (load (s32) from %fixed-stack.3)
262 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[LOAD]], [[COPY]]
263 ; MIPS32: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[ADD]](s32), [[COPY]]
264 ; MIPS32: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[LOAD1]], [[COPY1]]
265 ; MIPS32: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[ADD1]](s32), [[LOAD1]]
266 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
267 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]]
268 ; MIPS32: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[ADD1]], [[AND]]
269 ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
270 ; MIPS32: [[ICMP2:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[ADD2]](s32), [[C1]]
271 ; MIPS32: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ICMP2]], [[ICMP]]
272 ; MIPS32: [[OR:%[0-9]+]]:_(s32) = G_OR [[ICMP1]], [[AND1]]
273 ; MIPS32: [[ADD3:%[0-9]+]]:_(s32) = G_ADD [[LOAD2]], [[COPY2]]
274 ; MIPS32: [[ICMP3:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[ADD3]](s32), [[LOAD2]]
275 ; MIPS32: [[AND2:%[0-9]+]]:_(s32) = G_AND [[OR]], [[C]]
276 ; MIPS32: [[ADD4:%[0-9]+]]:_(s32) = G_ADD [[ADD3]], [[AND2]]
277 ; MIPS32: [[ICMP4:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[ADD4]](s32), [[C1]]
278 ; MIPS32: [[AND3:%[0-9]+]]:_(s32) = G_AND [[ICMP4]], [[OR]]
279 ; MIPS32: [[OR1:%[0-9]+]]:_(s32) = G_OR [[ICMP3]], [[AND3]]
280 ; MIPS32: [[ADD5:%[0-9]+]]:_(s32) = G_ADD [[LOAD3]], [[COPY3]]
281 ; MIPS32: [[AND4:%[0-9]+]]:_(s32) = G_AND [[OR1]], [[C]]
282 ; MIPS32: [[ADD6:%[0-9]+]]:_(s32) = G_ADD [[ADD5]], [[AND4]]
283 ; MIPS32: $v0 = COPY [[ADD]](s32)
284 ; MIPS32: $v1 = COPY [[ADD2]](s32)
285 ; MIPS32: $a0 = COPY [[ADD4]](s32)
286 ; MIPS32: $a1 = COPY [[ADD6]](s32)
287 ; MIPS32: RetRA implicit $v0, implicit $v1, implicit $a0, implicit $a1
292 %0:_(s128) = G_MERGE_VALUES %2(s32), %3(s32), %4(s32), %5(s32)
293 %10:_(p0) = G_FRAME_INDEX %fixed-stack.3
294 %6:_(s32) = G_LOAD %10(p0) :: (load (s32) from %fixed-stack.3, align 4)
295 %11:_(p0) = G_FRAME_INDEX %fixed-stack.2
296 %7:_(s32) = G_LOAD %11(p0) :: (load (s32) from %fixed-stack.2, align 4)
297 %12:_(p0) = G_FRAME_INDEX %fixed-stack.1
298 %8:_(s32) = G_LOAD %12(p0) :: (load (s32) from %fixed-stack.1, align 4)
299 %13:_(p0) = G_FRAME_INDEX %fixed-stack.0
300 %9:_(s32) = G_LOAD %13(p0) :: (load (s32) from %fixed-stack.0, align 4)
301 %1:_(s128) = G_MERGE_VALUES %6(s32), %7(s32), %8(s32), %9(s32)
302 %14:_(s128) = G_ADD %1, %0
303 %15:_(s32), %16:_(s32), %17:_(s32), %18:_(s32) = G_UNMERGE_VALUES %14(s128)
308 RetRA implicit $v0, implicit $v1, implicit $a0, implicit $a1
312 name: uadd_with_overflow
314 tracksRegLiveness: true
317 liveins: $a0, $a1, $a2, $a3
319 ; MIPS32-LABEL: name: uadd_with_overflow
320 ; MIPS32: liveins: $a0, $a1, $a2, $a3
321 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
322 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
323 ; MIPS32: [[COPY2:%[0-9]+]]:_(p0) = COPY $a2
324 ; MIPS32: [[COPY3:%[0-9]+]]:_(p0) = COPY $a3
325 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[COPY1]]
326 ; MIPS32: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[ADD]](s32), [[COPY1]]
327 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
328 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]]
329 ; MIPS32: [[AND1:%[0-9]+]]:_(s32) = G_AND [[AND]], [[C]]
330 ; MIPS32: G_STORE [[AND1]](s32), [[COPY3]](p0) :: (store (s8) into %ir.pcarry_flag)
331 ; MIPS32: G_STORE [[ADD]](s32), [[COPY2]](p0) :: (store (s32) into %ir.padd)
337 %4:_(s32), %5:_(s1) = G_UADDO %0, %1
338 G_STORE %5(s1), %3(p0) :: (store (s1) into %ir.pcarry_flag)
339 G_STORE %4(s32), %2(p0) :: (store (s32) into %ir.padd)