1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs -mtriple aarch64-unknown- --aarch64postlegalizercombiner-only-enable-rule="select_to_logical" %s -o - | FileCheck %s
3 # RUN: llc -debugify-and-strip-all-safe -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs -mtriple aarch64-unknown-unknown %s -o - | FileCheck %s
6 # select (c, x, x) -> x
7 name: test_combine_select_same_res
11 ; CHECK-LABEL: name: test_combine_select_same_res
12 ; CHECK: liveins: $x0, $x1
14 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
15 ; CHECK-NEXT: $x0 = COPY [[COPY]](s64)
18 %2:_(s64) = G_SELECT %1, %0, %0
22 # select (undef, x, y) -> y
23 name: test_combine_select_undef_res0_res1
27 ; CHECK-LABEL: name: test_combine_select_undef_res0_res1
28 ; CHECK: liveins: $x0, $x1
30 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x1
31 ; CHECK-NEXT: $x0 = COPY [[COPY]](s64)
34 %2:_(s1) = G_IMPLICIT_DEF
35 %3:_(s64) = G_SELECT %2, %0, %1
39 # select (false, x, y) -> y
40 name: test_combine_select_false_res0_res1
44 ; CHECK-LABEL: name: test_combine_select_false_res0_res1
45 ; CHECK: liveins: $x0, $x1
47 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x1
48 ; CHECK-NEXT: $x0 = COPY [[COPY]](s64)
51 %2:_(s1) = G_CONSTANT i1 false
52 %3:_(s64) = G_SELECT %2, %0, %1
56 # vector select (false, x, y) -> y
57 name: test_combine_vector_select_false_res0_res1
61 ; CHECK-LABEL: name: test_combine_vector_select_false_res0_res1
62 ; CHECK: liveins: $q0, $q1
64 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q1
65 ; CHECK-NEXT: $q0 = COPY [[COPY]](<4 x s32>)
66 %0:_(<4 x s32>) = COPY $q0
67 %1:_(<4 x s32>) = COPY $q1
68 %2:_(s1) = G_CONSTANT i1 false
69 %condvec:_(<4 x s1>) = G_BUILD_VECTOR %2, %2, %2, %2
70 %3:_(<4 x s32>) = G_SELECT %condvec, %0, %1
71 $q0 = COPY %3(<4 x s32>)
74 # select (true, x, y) -> x
75 name: test_combine_select_true_res0_res1
79 ; CHECK-LABEL: name: test_combine_select_true_res0_res1
80 ; CHECK: liveins: $x0, $x1
82 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
83 ; CHECK-NEXT: $x0 = COPY [[COPY]](s64)
86 %2:_(s1) = G_CONSTANT i1 true
87 %3:_(s64) = G_SELECT %2, %0, %1
91 # vector select (true, x, y) -> x
92 name: test_combine_vector_select_true_res0_res1
96 ; CHECK-LABEL: name: test_combine_vector_select_true_res0_res1
97 ; CHECK: liveins: $q0, $q1
99 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
100 ; CHECK-NEXT: $q0 = COPY [[COPY]](<4 x s32>)
101 %0:_(<4 x s32>) = COPY $q0
102 %1:_(<4 x s32>) = COPY $q1
103 %2:_(s1) = G_CONSTANT i1 true
104 %condvec:_(<4 x s1>) = G_BUILD_VECTOR %2, %2, %2, %2
105 %3:_(<4 x s32>) = G_SELECT %condvec, %0, %1
106 $q0 = COPY %3(<4 x s32>)
109 # select Cond, Cond, F --> or Cond, F
110 name: bool_cond_cond_false
113 liveins: $x0, $x1, $x2
114 ; CHECK-LABEL: name: bool_cond_cond_false
115 ; CHECK: liveins: $x0, $x1, $x2
117 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
118 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x2
119 ; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
120 ; CHECK-NEXT: %f:_(s1) = G_TRUNC [[COPY1]](s64)
121 ; CHECK-NEXT: %sel:_(s1) = G_OR %c, %f
122 ; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s1)
123 ; CHECK-NEXT: $w0 = COPY %ext(s32)
127 %c:_(s1) = G_TRUNC %0
128 %t:_(s1) = G_TRUNC %1
129 %f:_(s1) = G_TRUNC %2
130 %sel:_(s1) = G_SELECT %c, %c, %f
131 %ext:_(s32) = G_ANYEXT %sel
135 # select Cond, 1, F --> or Cond, F
136 name: bool_cond_one_false
139 liveins: $x0, $x1, $x2
140 ; CHECK-LABEL: name: bool_cond_one_false
141 ; CHECK: liveins: $x0, $x1, $x2
143 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
144 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x2
145 ; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
146 ; CHECK-NEXT: %f:_(s1) = G_TRUNC [[COPY1]](s64)
147 ; CHECK-NEXT: %sel:_(s1) = G_OR %c, %f
148 ; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s1)
149 ; CHECK-NEXT: $w0 = COPY %ext(s32)
153 %c:_(s1) = G_TRUNC %0
154 %t:_(s1) = G_TRUNC %1
155 %f:_(s1) = G_TRUNC %2
156 %one:_(s1) = G_CONSTANT i1 1
157 %sel:_(s1) = G_SELECT %c, %one, %f
158 %ext:_(s32) = G_ANYEXT %sel
162 # select Cond, 1, F --> or Cond, F
163 name: bool_cond_one_false_vector
166 liveins: $d0, $d1, $d2
167 ; CHECK-LABEL: name: bool_cond_one_false_vector
168 ; CHECK: liveins: $d0, $d1, $d2
170 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
171 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d2
172 ; CHECK-NEXT: %c:_(<2 x s1>) = G_TRUNC [[COPY]](<2 x s32>)
173 ; CHECK-NEXT: %f:_(<2 x s1>) = G_TRUNC [[COPY1]](<2 x s32>)
174 ; CHECK-NEXT: %sel:_(<2 x s1>) = G_OR %c, %f
175 ; CHECK-NEXT: %ext:_(<2 x s32>) = G_ANYEXT %sel(<2 x s1>)
176 ; CHECK-NEXT: $d0 = COPY %ext(<2 x s32>)
177 %0:_(<2 x s32>) = COPY $d0
178 %1:_(<2 x s32>) = COPY $d1
179 %2:_(<2 x s32>) = COPY $d2
180 %c:_(<2 x s1>) = G_TRUNC %0
181 %t:_(<2 x s1>) = G_TRUNC %1
182 %f:_(<2 x s1>) = G_TRUNC %2
183 %one:_(s1) = G_CONSTANT i1 1
184 %one_vec:_(<2 x s1>) = G_BUILD_VECTOR %one, %one
185 %sel:_(<2 x s1>) = G_SELECT %c, %one_vec, %f
186 %ext:_(<2 x s32>) = G_ANYEXT %sel
187 $d0 = COPY %ext(<2 x s32>)
190 # select Cond, T, Cond --> and Cond, T
191 name: bool_cond_true_cond
194 liveins: $x0, $x1, $x2
195 ; CHECK-LABEL: name: bool_cond_true_cond
196 ; CHECK: liveins: $x0, $x1, $x2
198 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
199 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
200 ; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
201 ; CHECK-NEXT: %t:_(s1) = G_TRUNC [[COPY1]](s64)
202 ; CHECK-NEXT: %sel:_(s1) = G_AND %c, %t
203 ; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s1)
204 ; CHECK-NEXT: $w0 = COPY %ext(s32)
208 %c:_(s1) = G_TRUNC %0
209 %t:_(s1) = G_TRUNC %1
210 %f:_(s1) = G_TRUNC %2
211 %one:_(s1) = G_CONSTANT i1 1
212 %sel:_(s1) = G_SELECT %c, %t, %c
213 %ext:_(s32) = G_ANYEXT %sel
217 # select Cond, T, 0 --> and Cond, T
218 name: bool_cond_true_zero
221 liveins: $x0, $x1, $x2
222 ; CHECK-LABEL: name: bool_cond_true_zero
223 ; CHECK: liveins: $x0, $x1, $x2
225 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
226 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
227 ; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
228 ; CHECK-NEXT: %t:_(s1) = G_TRUNC [[COPY1]](s64)
229 ; CHECK-NEXT: %sel:_(s1) = G_AND %c, %t
230 ; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s1)
231 ; CHECK-NEXT: $w0 = COPY %ext(s32)
235 %c:_(s1) = G_TRUNC %0
236 %t:_(s1) = G_TRUNC %1
237 %f:_(s1) = G_TRUNC %2
238 %zero:_(s1) = G_CONSTANT i1 0
239 %sel:_(s1) = G_SELECT %c, %t, %zero
240 %ext:_(s32) = G_ANYEXT %sel
244 # select Cond, T, 1 --> or (not Cond), T
245 name: bool_cond_true_one
248 liveins: $x0, $x1, $x2
249 ; CHECK-LABEL: name: bool_cond_true_one
250 ; CHECK: liveins: $x0, $x1, $x2
252 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
253 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
254 ; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
255 ; CHECK-NEXT: %t:_(s1) = G_TRUNC [[COPY1]](s64)
256 ; CHECK-NEXT: %one:_(s1) = G_CONSTANT i1 true
257 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s1) = G_XOR %c, %one
258 ; CHECK-NEXT: %sel:_(s1) = G_OR [[XOR]], %t
259 ; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s1)
260 ; CHECK-NEXT: $w0 = COPY %ext(s32)
264 %c:_(s1) = G_TRUNC %0
265 %t:_(s1) = G_TRUNC %1
266 %f:_(s1) = G_TRUNC %2
267 %one:_(s1) = G_CONSTANT i1 1
268 %sel:_(s1) = G_SELECT %c, %t, %one
269 %ext:_(s32) = G_ANYEXT %sel
273 # select Cond, 0, F --> and (not Cond), F
274 name: bool_cond_zero_false
277 liveins: $x0, $x1, $x2
278 ; CHECK-LABEL: name: bool_cond_zero_false
279 ; CHECK: liveins: $x0, $x1, $x2
281 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
282 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x2
283 ; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
284 ; CHECK-NEXT: %f:_(s1) = G_TRUNC [[COPY1]](s64)
285 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
286 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s1) = G_XOR %c, [[C]]
287 ; CHECK-NEXT: %sel:_(s1) = G_AND [[XOR]], %f
288 ; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s1)
289 ; CHECK-NEXT: $w0 = COPY %ext(s32)
293 %c:_(s1) = G_TRUNC %0
294 %t:_(s1) = G_TRUNC %1
295 %f:_(s1) = G_TRUNC %2
296 %zero:_(s1) = G_CONSTANT i1 0
297 %sel:_(s1) = G_SELECT %c, %zero, %f
298 %ext:_(s32) = G_ANYEXT %sel