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 @select_i8() {entry: ret void}
6 define void @select_i16() {entry: ret void}
7 define void @select_i32() {entry: ret void}
8 define void @select_ptr() {entry: ret void}
9 define void @select_with_negation() {entry: ret void}
10 define void @select_i64() {entry: ret void}
11 define void @select_float() {entry: ret void}
12 define void @select_double() {entry: ret void}
18 tracksRegLiveness: true
21 liveins: $a0, $a1, $a2
23 ; MIPS32-LABEL: name: select_i8
24 ; MIPS32: liveins: $a0, $a1, $a2
25 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
26 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
27 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
28 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32)
29 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[COPY2]](s32)
30 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
31 ; MIPS32: [[COPY5:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
32 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY5]], [[C]]
33 ; MIPS32: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[COPY3]], [[COPY4]]
34 ; MIPS32: [[COPY6:%[0-9]+]]:_(s32) = COPY [[SELECT]](s32)
35 ; MIPS32: $v0 = COPY [[COPY6]](s32)
36 ; MIPS32: RetRA implicit $v0
38 %0:_(s1) = G_TRUNC %3(s32)
40 %1:_(s8) = G_TRUNC %4(s32)
42 %2:_(s8) = G_TRUNC %5(s32)
43 %6:_(s8) = G_SELECT %0(s1), %1, %2
44 %7:_(s32) = G_ANYEXT %6(s8)
52 tracksRegLiveness: true
55 liveins: $a0, $a1, $a2
57 ; MIPS32-LABEL: name: select_i16
58 ; MIPS32: liveins: $a0, $a1, $a2
59 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
60 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
61 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
62 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32)
63 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[COPY2]](s32)
64 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
65 ; MIPS32: [[COPY5:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
66 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY5]], [[C]]
67 ; MIPS32: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[COPY3]], [[COPY4]]
68 ; MIPS32: [[COPY6:%[0-9]+]]:_(s32) = COPY [[SELECT]](s32)
69 ; MIPS32: $v0 = COPY [[COPY6]](s32)
70 ; MIPS32: RetRA implicit $v0
72 %0:_(s1) = G_TRUNC %3(s32)
74 %1:_(s16) = G_TRUNC %4(s32)
76 %2:_(s16) = G_TRUNC %5(s32)
77 %6:_(s16) = G_SELECT %0(s1), %1, %2
78 %7:_(s32) = G_ANYEXT %6(s16)
86 tracksRegLiveness: true
89 liveins: $a0, $a1, $a2
91 ; MIPS32-LABEL: name: select_i32
92 ; MIPS32: liveins: $a0, $a1, $a2
93 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
94 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
95 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
96 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
97 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
98 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]]
99 ; MIPS32: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[COPY1]], [[COPY2]]
100 ; MIPS32: $v0 = COPY [[SELECT]](s32)
101 ; MIPS32: RetRA implicit $v0
103 %0:_(s1) = G_TRUNC %3(s32)
106 %4:_(s32) = G_SELECT %0(s1), %1, %2
114 tracksRegLiveness: true
117 liveins: $a0, $a1, $a2
119 ; MIPS32-LABEL: name: select_ptr
120 ; MIPS32: liveins: $a0, $a1, $a2
121 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
122 ; MIPS32: [[COPY1:%[0-9]+]]:_(p0) = COPY $a1
123 ; MIPS32: [[COPY2:%[0-9]+]]:_(p0) = COPY $a2
124 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
125 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
126 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]]
127 ; MIPS32: [[SELECT:%[0-9]+]]:_(p0) = G_SELECT [[AND]](s32), [[COPY1]], [[COPY2]]
128 ; MIPS32: $v0 = COPY [[SELECT]](p0)
129 ; MIPS32: RetRA implicit $v0
131 %0:_(s1) = G_TRUNC %3(s32)
134 %4:_(p0) = G_SELECT %0(s1), %1, %2
140 name: select_with_negation
142 tracksRegLiveness: true
145 liveins: $a0, $a1, $a2, $a3
147 ; MIPS32-LABEL: name: select_with_negation
148 ; MIPS32: liveins: $a0, $a1, $a2, $a3
149 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
150 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
151 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
152 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY $a3
153 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
154 ; MIPS32: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(slt), [[COPY]](s32), [[COPY1]]
155 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ICMP]](s32)
156 ; MIPS32: [[COPY5:%[0-9]+]]:_(s32) = COPY [[C]](s32)
157 ; MIPS32: [[XOR:%[0-9]+]]:_(s32) = G_XOR [[COPY4]], [[COPY5]]
158 ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
159 ; MIPS32: [[COPY6:%[0-9]+]]:_(s32) = COPY [[XOR]](s32)
160 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY6]], [[C1]]
161 ; MIPS32: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[COPY2]], [[COPY3]]
162 ; MIPS32: $v0 = COPY [[SELECT]](s32)
163 ; MIPS32: RetRA implicit $v0
168 %5:_(s1) = G_CONSTANT i1 true
169 %4:_(s1) = G_ICMP intpred(slt), %0(s32), %1
170 %6:_(s1) = G_XOR %4, %5
171 %7:_(s32) = G_SELECT %6(s1), %2, %3
179 tracksRegLiveness: true
181 - { id: 0, offset: 20, size: 4, alignment: 4, isImmutable: true }
182 - { id: 1, offset: 16, size: 4, alignment: 8, isImmutable: true }
185 liveins: $a0, $a2, $a3
187 ; MIPS32-LABEL: name: select_i64
188 ; MIPS32: liveins: $a0, $a2, $a3
189 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
190 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a2
191 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a3
192 ; MIPS32: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY1]](s32), [[COPY2]](s32)
193 ; MIPS32: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
194 ; MIPS32: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load 4 from %fixed-stack.0, align 8)
195 ; MIPS32: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
196 ; MIPS32: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load 4 from %fixed-stack.1)
197 ; MIPS32: [[MV1:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[LOAD]](s32), [[LOAD1]](s32)
198 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
199 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
200 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]]
201 ; MIPS32: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND]](s32), [[MV]], [[MV1]]
202 ; MIPS32: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[SELECT]](s64)
203 ; MIPS32: $v0 = COPY [[UV]](s32)
204 ; MIPS32: $v1 = COPY [[UV1]](s32)
205 ; MIPS32: RetRA implicit $v0, implicit $v1
207 %0:_(s1) = G_TRUNC %3(s32)
210 %1:_(s64) = G_MERGE_VALUES %4(s32), %5(s32)
211 %8:_(p0) = G_FRAME_INDEX %fixed-stack.1
212 %6:_(s32) = G_LOAD %8(p0) :: (load 4 from %fixed-stack.1, align 8)
213 %9:_(p0) = G_FRAME_INDEX %fixed-stack.0
214 %7:_(s32) = G_LOAD %9(p0) :: (load 4 from %fixed-stack.0)
215 %2:_(s64) = G_MERGE_VALUES %6(s32), %7(s32)
216 %10:_(s64) = G_SELECT %0(s1), %1, %2
217 %11:_(s32), %12:_(s32) = G_UNMERGE_VALUES %10(s64)
220 RetRA implicit $v0, implicit $v1
226 tracksRegLiveness: true
229 liveins: $a0, $a1, $a2
231 ; MIPS32-LABEL: name: select_float
232 ; MIPS32: liveins: $a0, $a1, $a2
233 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
234 ; MIPS32: [[MTC1_:%[0-9]+]]:fgr32(s32) = MTC1 $a1
235 ; MIPS32: [[MTC1_1:%[0-9]+]]:fgr32(s32) = MTC1 $a2
236 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
237 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
238 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]]
239 ; MIPS32: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[MTC1_]], [[MTC1_1]]
240 ; MIPS32: $f0 = COPY [[SELECT]](s32)
241 ; MIPS32: RetRA implicit $f0
243 %0:_(s1) = G_TRUNC %3(s32)
244 %1:fgr32(s32) = MTC1 $a1
245 %2:fgr32(s32) = MTC1 $a2
246 %4:_(s32) = G_SELECT %0(s1), %1, %2
254 tracksRegLiveness: true
256 - { id: 0, offset: 16, size: 4, alignment: 8, isImmutable: true }
261 ; MIPS32-LABEL: name: select_double
262 ; MIPS32: liveins: $d6, $d7
263 ; MIPS32: [[COPY:%[0-9]+]]:_(s64) = COPY $d6
264 ; MIPS32: [[COPY1:%[0-9]+]]:_(s64) = COPY $d7
265 ; MIPS32: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
266 ; MIPS32: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load 4 from %fixed-stack.0, align 8)
267 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
268 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32)
269 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]]
270 ; MIPS32: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND]](s32), [[COPY]], [[COPY1]]
271 ; MIPS32: $d0 = COPY [[SELECT]](s64)
272 ; MIPS32: RetRA implicit $d0
275 %4:_(p0) = G_FRAME_INDEX %fixed-stack.0
276 %3:_(s32) = G_LOAD %4(p0) :: (load 4 from %fixed-stack.0, align 8)
277 %2:_(s1) = G_TRUNC %3(s32)
278 %5:_(s64) = G_SELECT %2(s1), %0, %1