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: [[COPY6:%[0-9]+]]:_(s32) = COPY [[XOR]](s32)
159 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY6]], [[C]]
160 ; MIPS32: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[COPY2]], [[COPY3]]
161 ; MIPS32: $v0 = COPY [[SELECT]](s32)
162 ; MIPS32: RetRA implicit $v0
167 %5:_(s1) = G_CONSTANT i1 true
168 %4:_(s1) = G_ICMP intpred(slt), %0(s32), %1
169 %6:_(s1) = G_XOR %4, %5
170 %7:_(s32) = G_SELECT %6(s1), %2, %3
178 tracksRegLiveness: true
180 - { id: 0, offset: 20, size: 4, alignment: 4, isImmutable: true }
181 - { id: 1, offset: 16, size: 4, alignment: 8, isImmutable: true }
184 liveins: $a0, $a2, $a3
186 ; MIPS32-LABEL: name: select_i64
187 ; MIPS32: liveins: $a0, $a2, $a3
188 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
189 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a2
190 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a3
191 ; MIPS32: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY1]](s32), [[COPY2]](s32)
192 ; MIPS32: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
193 ; MIPS32: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0, align 8)
194 ; MIPS32: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
195 ; MIPS32: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s32) from %fixed-stack.1)
196 ; MIPS32: [[MV1:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[LOAD]](s32), [[LOAD1]](s32)
197 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
198 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
199 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]]
200 ; MIPS32: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND]](s32), [[MV]], [[MV1]]
201 ; MIPS32: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[SELECT]](s64)
202 ; MIPS32: $v0 = COPY [[UV]](s32)
203 ; MIPS32: $v1 = COPY [[UV1]](s32)
204 ; MIPS32: RetRA implicit $v0, implicit $v1
206 %0:_(s1) = G_TRUNC %3(s32)
209 %1:_(s64) = G_MERGE_VALUES %4(s32), %5(s32)
210 %8:_(p0) = G_FRAME_INDEX %fixed-stack.1
211 %6:_(s32) = G_LOAD %8(p0) :: (load (s32) from %fixed-stack.1, align 8)
212 %9:_(p0) = G_FRAME_INDEX %fixed-stack.0
213 %7:_(s32) = G_LOAD %9(p0) :: (load (s32) from %fixed-stack.0)
214 %2:_(s64) = G_MERGE_VALUES %6(s32), %7(s32)
215 %10:_(s64) = G_SELECT %0(s1), %1, %2
216 %11:_(s32), %12:_(s32) = G_UNMERGE_VALUES %10(s64)
219 RetRA implicit $v0, implicit $v1
225 tracksRegLiveness: true
228 liveins: $a0, $a1, $a2
230 ; MIPS32-LABEL: name: select_float
231 ; MIPS32: liveins: $a0, $a1, $a2
232 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
233 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
234 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
235 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
236 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
237 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]]
238 ; MIPS32: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[COPY1]], [[COPY2]]
239 ; MIPS32: $f0 = COPY [[SELECT]](s32)
240 ; MIPS32: RetRA implicit $f0
242 %0:_(s1) = G_TRUNC %3(s32)
245 %4:_(s32) = G_SELECT %0(s1), %1, %2
253 tracksRegLiveness: true
255 - { id: 0, offset: 16, size: 4, alignment: 8, isImmutable: true }
260 ; MIPS32-LABEL: name: select_double
261 ; MIPS32: liveins: $d6, $d7
262 ; MIPS32: [[COPY:%[0-9]+]]:_(s64) = COPY $d6
263 ; MIPS32: [[COPY1:%[0-9]+]]:_(s64) = COPY $d7
264 ; MIPS32: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
265 ; MIPS32: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0, align 8)
266 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
267 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32)
268 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]]
269 ; MIPS32: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND]](s32), [[COPY]], [[COPY1]]
270 ; MIPS32: $d0 = COPY [[SELECT]](s64)
271 ; MIPS32: RetRA implicit $d0
274 %4:_(p0) = G_FRAME_INDEX %fixed-stack.0
275 %3:_(s32) = G_LOAD %4(p0) :: (load (s32) from %fixed-stack.0, align 8)
276 %2:_(s1) = G_TRUNC %3(s32)
277 %5:_(s64) = G_SELECT %2(s1), %0, %1