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
26 ; MIPS32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
27 ; MIPS32-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
28 ; MIPS32-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
29 ; MIPS32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
30 ; MIPS32-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
31 ; MIPS32-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[COPY1]], [[COPY2]]
32 ; MIPS32-NEXT: $v0 = COPY [[SELECT]](s32)
33 ; MIPS32-NEXT: RetRA implicit $v0
35 %0:_(s1) = G_TRUNC %3(s32)
37 %1:_(s8) = G_TRUNC %4(s32)
39 %2:_(s8) = G_TRUNC %5(s32)
40 %6:_(s8) = G_SELECT %0(s1), %1, %2
41 %7:_(s32) = G_ANYEXT %6(s8)
49 tracksRegLiveness: true
52 liveins: $a0, $a1, $a2
54 ; MIPS32-LABEL: name: select_i16
55 ; MIPS32: liveins: $a0, $a1, $a2
57 ; MIPS32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
58 ; MIPS32-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
59 ; MIPS32-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
60 ; MIPS32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
61 ; MIPS32-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
62 ; MIPS32-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[COPY1]], [[COPY2]]
63 ; MIPS32-NEXT: $v0 = COPY [[SELECT]](s32)
64 ; MIPS32-NEXT: RetRA implicit $v0
66 %0:_(s1) = G_TRUNC %3(s32)
68 %1:_(s16) = G_TRUNC %4(s32)
70 %2:_(s16) = G_TRUNC %5(s32)
71 %6:_(s16) = G_SELECT %0(s1), %1, %2
72 %7:_(s32) = G_ANYEXT %6(s16)
80 tracksRegLiveness: true
83 liveins: $a0, $a1, $a2
85 ; MIPS32-LABEL: name: select_i32
86 ; MIPS32: liveins: $a0, $a1, $a2
88 ; MIPS32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
89 ; MIPS32-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
90 ; MIPS32-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
91 ; MIPS32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
92 ; MIPS32-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
93 ; MIPS32-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[COPY1]], [[COPY2]]
94 ; MIPS32-NEXT: $v0 = COPY [[SELECT]](s32)
95 ; MIPS32-NEXT: RetRA implicit $v0
97 %0:_(s1) = G_TRUNC %3(s32)
100 %4:_(s32) = G_SELECT %0(s1), %1, %2
108 tracksRegLiveness: true
111 liveins: $a0, $a1, $a2
113 ; MIPS32-LABEL: name: select_ptr
114 ; MIPS32: liveins: $a0, $a1, $a2
115 ; MIPS32-NEXT: {{ $}}
116 ; MIPS32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
117 ; MIPS32-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $a1
118 ; MIPS32-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY $a2
119 ; MIPS32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
120 ; MIPS32-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
121 ; MIPS32-NEXT: [[SELECT:%[0-9]+]]:_(p0) = G_SELECT [[AND]](s32), [[COPY1]], [[COPY2]]
122 ; MIPS32-NEXT: $v0 = COPY [[SELECT]](p0)
123 ; MIPS32-NEXT: RetRA implicit $v0
125 %0:_(s1) = G_TRUNC %3(s32)
128 %4:_(p0) = G_SELECT %0(s1), %1, %2
134 name: select_with_negation
136 tracksRegLiveness: true
139 liveins: $a0, $a1, $a2, $a3
141 ; MIPS32-LABEL: name: select_with_negation
142 ; MIPS32: liveins: $a0, $a1, $a2, $a3
143 ; MIPS32-NEXT: {{ $}}
144 ; MIPS32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
145 ; MIPS32-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
146 ; MIPS32-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
147 ; MIPS32-NEXT: [[COPY3:%[0-9]+]]:_(s32) = COPY $a3
148 ; MIPS32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
149 ; MIPS32-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(slt), [[COPY]](s32), [[COPY1]]
150 ; MIPS32-NEXT: [[XOR:%[0-9]+]]:_(s32) = G_XOR [[ICMP]], [[C]]
151 ; MIPS32-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[XOR]](s32), [[COPY2]], [[COPY3]]
152 ; MIPS32-NEXT: $v0 = COPY [[SELECT]](s32)
153 ; MIPS32-NEXT: RetRA implicit $v0
158 %5:_(s1) = G_CONSTANT i1 true
159 %4:_(s1) = G_ICMP intpred(slt), %0(s32), %1
160 %6:_(s1) = G_XOR %4, %5
161 %7:_(s32) = G_SELECT %6(s1), %2, %3
169 tracksRegLiveness: true
171 - { id: 0, offset: 20, size: 4, alignment: 4, isImmutable: true }
172 - { id: 1, offset: 16, size: 4, alignment: 8, isImmutable: true }
175 liveins: $a0, $a2, $a3
177 ; MIPS32-LABEL: name: select_i64
178 ; MIPS32: liveins: $a0, $a2, $a3
179 ; MIPS32-NEXT: {{ $}}
180 ; MIPS32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
181 ; MIPS32-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $a2
182 ; MIPS32-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $a3
183 ; MIPS32-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY1]](s32), [[COPY2]](s32)
184 ; MIPS32-NEXT: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
185 ; MIPS32-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0, align 8)
186 ; MIPS32-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
187 ; MIPS32-NEXT: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s32) from %fixed-stack.1)
188 ; MIPS32-NEXT: [[MV1:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[LOAD]](s32), [[LOAD1]](s32)
189 ; MIPS32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
190 ; MIPS32-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
191 ; MIPS32-NEXT: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND]](s32), [[MV]], [[MV1]]
192 ; MIPS32-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[SELECT]](s64)
193 ; MIPS32-NEXT: $v0 = COPY [[UV]](s32)
194 ; MIPS32-NEXT: $v1 = COPY [[UV1]](s32)
195 ; MIPS32-NEXT: RetRA implicit $v0, implicit $v1
197 %0:_(s1) = G_TRUNC %3(s32)
200 %1:_(s64) = G_MERGE_VALUES %4(s32), %5(s32)
201 %8:_(p0) = G_FRAME_INDEX %fixed-stack.1
202 %6:_(s32) = G_LOAD %8(p0) :: (load (s32) from %fixed-stack.1, align 8)
203 %9:_(p0) = G_FRAME_INDEX %fixed-stack.0
204 %7:_(s32) = G_LOAD %9(p0) :: (load (s32) from %fixed-stack.0)
205 %2:_(s64) = G_MERGE_VALUES %6(s32), %7(s32)
206 %10:_(s64) = G_SELECT %0(s1), %1, %2
207 %11:_(s32), %12:_(s32) = G_UNMERGE_VALUES %10(s64)
210 RetRA implicit $v0, implicit $v1
216 tracksRegLiveness: true
219 liveins: $a0, $a1, $a2
221 ; MIPS32-LABEL: name: select_float
222 ; MIPS32: liveins: $a0, $a1, $a2
223 ; MIPS32-NEXT: {{ $}}
224 ; MIPS32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
225 ; MIPS32-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
226 ; MIPS32-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
227 ; MIPS32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
228 ; MIPS32-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
229 ; MIPS32-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[COPY1]], [[COPY2]]
230 ; MIPS32-NEXT: $f0 = COPY [[SELECT]](s32)
231 ; MIPS32-NEXT: RetRA implicit $f0
233 %0:_(s1) = G_TRUNC %3(s32)
236 %4:_(s32) = G_SELECT %0(s1), %1, %2
244 tracksRegLiveness: true
246 - { id: 0, offset: 16, size: 4, alignment: 8, isImmutable: true }
251 ; MIPS32-LABEL: name: select_double
252 ; MIPS32: liveins: $d6, $d7
253 ; MIPS32-NEXT: {{ $}}
254 ; MIPS32-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $d6
255 ; MIPS32-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $d7
256 ; MIPS32-NEXT: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
257 ; MIPS32-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0, align 8)
258 ; MIPS32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
259 ; MIPS32-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[LOAD]], [[C]]
260 ; MIPS32-NEXT: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND]](s32), [[COPY]], [[COPY1]]
261 ; MIPS32-NEXT: $d0 = COPY [[SELECT]](s64)
262 ; MIPS32-NEXT: RetRA implicit $d0
265 %4:_(p0) = G_FRAME_INDEX %fixed-stack.0
266 %3:_(s32) = G_LOAD %4(p0) :: (load (s32) from %fixed-stack.0, align 8)
267 %2:_(s1) = G_TRUNC %3(s32)
268 %5:_(s64) = G_SELECT %2(s1), %0, %1