1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64-apple-ios -run-pass=aarch64-prelegalizer-combiner --aarch64prelegalizercombiner-only-enable-rule="not_cmp_fold" %s -o - -verify-machineinstrs | FileCheck %s
4 # Need asserts for the only-enable-rule to work.
7 # Check that we fold an compare result inverted into just inverting the condition code.
10 tracksRegLiveness: true
15 ; CHECK-LABEL: name: icmp
17 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
18 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
19 ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(sle), [[COPY]](s64), [[C]]
20 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[ICMP]](s1)
21 ; CHECK: $w0 = COPY [[ANYEXT]](s32)
22 ; CHECK: RET_ReallyLR implicit $w0
24 %1:_(s64) = G_CONSTANT i64 1
25 %2:_(s1) = G_CONSTANT i1 1
26 %3:_(s1) = G_ICMP intpred(sgt), %0(s64), %1
27 %4:_(s1) = G_XOR %3, %2
28 %5:_(s32) = G_ANYEXT %4
30 RET_ReallyLR implicit $w0
34 tracksRegLiveness: true
39 ; CHECK-LABEL: name: fcmp
41 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
42 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
43 ; CHECK: [[FCMP:%[0-9]+]]:_(s1) = G_FCMP floatpred(ule), [[COPY]](s64), [[C]]
44 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[FCMP]](s1)
45 ; CHECK: $w0 = COPY [[ANYEXT]](s32)
46 ; CHECK: RET_ReallyLR implicit $w0
48 %1:_(s64) = G_CONSTANT i64 1
49 %2:_(s1) = G_CONSTANT i1 1
50 %3:_(s1) = G_FCMP floatpred(ogt), %0(s64), %1
51 %4:_(s1) = G_XOR %3, %2
52 %5:_(s32) = G_ANYEXT %4
54 RET_ReallyLR implicit $w0
57 name: icmp_not_xor_with_1
58 tracksRegLiveness: true
63 ; CHECK-LABEL: name: icmp_not_xor_with_1
65 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
66 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
67 ; CHECK: [[C1:%[0-9]+]]:_(s1) = G_CONSTANT i1 false
68 ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(sgt), [[COPY]](s64), [[C]]
69 ; CHECK: [[XOR:%[0-9]+]]:_(s1) = G_XOR [[ICMP]], [[C1]]
70 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[XOR]](s1)
71 ; CHECK: $w0 = COPY [[ANYEXT]](s32)
72 ; CHECK: RET_ReallyLR implicit $w0
74 %1:_(s64) = G_CONSTANT i64 1
75 %2:_(s1) = G_CONSTANT i1 0
76 %3:_(s1) = G_ICMP intpred(sgt), %0(s64), %1
77 %4:_(s1) = G_XOR %3, %2
78 %5:_(s32) = G_ANYEXT %4
80 RET_ReallyLR implicit $w0
83 name: icmp_not_xor_with_wrong_bool_contents
84 tracksRegLiveness: true
89 ; Even though bit 0 of the constant is 1, we require zero in the upper bits
90 ; for our aarch64's zero-or-one boolean contents.
91 ; CHECK-LABEL: name: icmp_not_xor_with_wrong_bool_contents
93 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
94 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
95 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 7
96 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(sgt), [[COPY]](s64), [[C]]
97 ; CHECK: [[XOR:%[0-9]+]]:_(s32) = G_XOR [[ICMP]], [[C1]]
98 ; CHECK: $w0 = COPY [[XOR]](s32)
99 ; CHECK: RET_ReallyLR implicit $w0
101 %1:_(s64) = G_CONSTANT i64 1
102 %2:_(s32) = G_CONSTANT i32 7
103 %3:_(s32) = G_ICMP intpred(sgt), %0(s64), %1
104 %4:_(s32) = G_XOR %3, %2
106 RET_ReallyLR implicit $w0
109 name: icmp_multiple_use
110 tracksRegLiveness: true
115 ; CHECK-LABEL: name: icmp_multiple_use
116 ; CHECK: liveins: $x0
117 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
118 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
119 ; CHECK: [[C1:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
120 ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(sgt), [[COPY]](s64), [[C]]
121 ; CHECK: [[XOR:%[0-9]+]]:_(s1) = G_XOR [[ICMP]], [[C1]]
122 ; CHECK: %other_use:_(s1) = G_AND [[ICMP]], [[C1]]
123 ; CHECK: %other_use_ext:_(s32) = G_ANYEXT %other_use(s1)
124 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[XOR]](s1)
125 ; CHECK: $w0 = COPY [[ANYEXT]](s32)
126 ; CHECK: $w1 = COPY %other_use_ext(s32)
127 ; CHECK: RET_ReallyLR implicit $w0
129 %1:_(s64) = G_CONSTANT i64 1
130 %2:_(s1) = G_CONSTANT i1 1
131 %3:_(s1) = G_ICMP intpred(sgt), %0(s64), %1
132 %4:_(s1) = G_XOR %3, %2
133 %other_use:_(s1) = G_AND %3, %2
134 %other_use_ext:_(s32) = G_ANYEXT %other_use(s1)
135 %5:_(s32) = G_ANYEXT %4
137 $w1 = COPY %other_use_ext
138 RET_ReallyLR implicit $w0
142 tracksRegLiveness: true
147 ; CHECK-LABEL: name: icmp_vector
148 ; CHECK: liveins: $q0
149 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
150 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
151 ; CHECK: %splat_op2:_(<4 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C]](s32), [[C]](s32), [[C]](s32)
152 ; CHECK: [[ICMP:%[0-9]+]]:_(<4 x s1>) = G_ICMP intpred(sle), [[COPY]](<4 x s32>), %splat_op2
153 ; CHECK: [[ANYEXT:%[0-9]+]]:_(<4 x s32>) = G_ANYEXT [[ICMP]](<4 x s1>)
154 ; CHECK: $q0 = COPY [[ANYEXT]](<4 x s32>)
155 ; CHECK: RET_ReallyLR implicit $q0
156 %0:_(<4 x s32>) = COPY $q0
157 %1:_(s32) = G_CONSTANT i32 5
158 %splat_op2:_(<4 x s32>) = G_BUILD_VECTOR %1, %1, %1, %1
159 %2:_(s1) = G_CONSTANT i1 1
160 %splat_true:_(<4 x s1>) = G_BUILD_VECTOR %2, %2, %2, %2
161 %3:_(<4 x s1>) = G_ICMP intpred(sgt), %0(<4 x s32>), %splat_op2
162 %4:_(<4 x s1>) = G_XOR %3, %splat_true
163 %5:_(<4 x s32>) = G_ANYEXT %4
164 $q0 = COPY %5(<4 x s32>)
165 RET_ReallyLR implicit $q0
169 tracksRegLiveness: true
174 ; CHECK-LABEL: name: icmp_and_icmp
175 ; CHECK: liveins: $x0
176 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
177 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
178 ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(sle), [[COPY]](s64), [[C]]
179 ; CHECK: [[ICMP1:%[0-9]+]]:_(s1) = G_ICMP intpred(ule), [[COPY]](s64), [[C]]
180 ; CHECK: [[OR:%[0-9]+]]:_(s1) = G_OR [[ICMP]], [[ICMP1]]
181 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[OR]](s1)
182 ; CHECK: $w0 = COPY [[ANYEXT]](s32)
183 ; CHECK: RET_ReallyLR implicit $w0
185 %1:_(s64) = G_CONSTANT i64 1
186 %2:_(s1) = G_CONSTANT i1 1
187 %3:_(s1) = G_ICMP intpred(sgt), %0(s64), %1
188 %4:_(s1) = G_ICMP intpred(ugt), %0(s64), %1
189 %5:_(s1) = G_AND %3, %4
190 %6:_(s1) = G_XOR %5, %2
191 %7:_(s32) = G_ANYEXT %6
193 RET_ReallyLR implicit $w0
197 tracksRegLiveness: true
202 ; CHECK-LABEL: name: icmp_or_icmp
203 ; CHECK: liveins: $x0
204 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
205 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
206 ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(sle), [[COPY]](s64), [[C]]
207 ; CHECK: [[ICMP1:%[0-9]+]]:_(s1) = G_ICMP intpred(ule), [[COPY]](s64), [[C]]
208 ; CHECK: [[AND:%[0-9]+]]:_(s1) = G_AND [[ICMP]], [[ICMP1]]
209 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[AND]](s1)
210 ; CHECK: $w0 = COPY [[ANYEXT]](s32)
211 ; CHECK: RET_ReallyLR implicit $w0
213 %1:_(s64) = G_CONSTANT i64 1
214 %2:_(s1) = G_CONSTANT i1 1
215 %3:_(s1) = G_ICMP intpred(sgt), %0(s64), %1
216 %4:_(s1) = G_ICMP intpred(ugt), %0(s64), %1
217 %5:_(s1) = G_OR %3, %4
218 %6:_(s1) = G_XOR %5, %2
219 %7:_(s32) = G_ANYEXT %6
221 RET_ReallyLR implicit $w0
224 name: icmp_and_icmp_or_icmp
225 tracksRegLiveness: true
230 ; CHECK-LABEL: name: icmp_and_icmp_or_icmp
231 ; CHECK: liveins: $x0
232 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
233 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
234 ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(sle), [[COPY]](s64), [[C]]
235 ; CHECK: [[ICMP1:%[0-9]+]]:_(s1) = G_ICMP intpred(ule), [[COPY]](s64), [[C]]
236 ; CHECK: [[OR:%[0-9]+]]:_(s1) = G_OR [[ICMP]], [[ICMP1]]
237 ; CHECK: [[ICMP2:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[COPY]](s64), [[C]]
238 ; CHECK: [[AND:%[0-9]+]]:_(s1) = G_AND [[OR]], [[ICMP2]]
239 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[AND]](s1)
240 ; CHECK: $w0 = COPY [[ANYEXT]](s32)
241 ; CHECK: RET_ReallyLR implicit $w0
243 %1:_(s64) = G_CONSTANT i64 1
244 %2:_(s1) = G_CONSTANT i1 1
245 %3:_(s1) = G_ICMP intpred(sgt), %0(s64), %1
246 %4:_(s1) = G_ICMP intpred(ugt), %0(s64), %1
247 %5:_(s1) = G_AND %3, %4
248 %6:_(s1) = G_ICMP intpred(ne), %0(s64), %1
249 %7:_(s1) = G_OR %5, %6
250 %8:_(s1) = G_XOR %7, %2
251 %9:_(s32) = G_ANYEXT %8
253 RET_ReallyLR implicit $w0
257 tracksRegLiveness: true
262 ; CHECK-LABEL: name: icmp_and_trunc
263 ; CHECK: liveins: $x0
264 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
265 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
266 ; CHECK: [[C1:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
267 ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(sgt), [[COPY]](s64), [[C]]
268 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[COPY]](s64)
269 ; CHECK: [[AND:%[0-9]+]]:_(s1) = G_AND [[ICMP]], [[TRUNC]]
270 ; CHECK: [[XOR:%[0-9]+]]:_(s1) = G_XOR [[AND]], [[C1]]
271 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[XOR]](s1)
272 ; CHECK: $w0 = COPY [[ANYEXT]](s32)
273 ; CHECK: RET_ReallyLR implicit $w0
275 %1:_(s64) = G_CONSTANT i64 1
276 %2:_(s1) = G_CONSTANT i1 1
277 %3:_(s1) = G_ICMP intpred(sgt), %0(s64), %1
278 %4:_(s1) = G_TRUNC %0(s64)
279 %5:_(s1) = G_AND %3, %4
280 %6:_(s1) = G_XOR %5, %2
281 %7:_(s32) = G_ANYEXT %6
283 RET_ReallyLR implicit $w0