• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 --aarch64prelegalizercombinerhelper-only-enable-rule="not_cmp_fold" %s -o - -verify-machineinstrs | FileCheck %s
3
4# Need asserts for the only-enable-rule to work.
5
6# REQUIRES: asserts
7# Check that we fold an compare result inverted into just inverting the condition code.
8---
9name: icmp
10tracksRegLiveness: true
11body:             |
12  bb.1:
13    liveins: $x0
14
15    ; CHECK-LABEL: name: icmp
16    ; CHECK: liveins: $x0
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
23    %0:_(s64) = COPY $x0
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
29    $w0 = COPY %5(s32)
30    RET_ReallyLR implicit $w0
31...
32---
33name: fcmp
34tracksRegLiveness: true
35body:             |
36  bb.1:
37    liveins: $x0
38
39    ; CHECK-LABEL: name: fcmp
40    ; CHECK: liveins: $x0
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
47    %0:_(s64) = COPY $x0
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
53    $w0 = COPY %5(s32)
54    RET_ReallyLR implicit $w0
55...
56---
57name: icmp_not_xor_with_1
58tracksRegLiveness: true
59body:             |
60  bb.1:
61    liveins: $x0
62
63    ; CHECK-LABEL: name: icmp_not_xor_with_1
64    ; CHECK: liveins: $x0
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
73    %0:_(s64) = COPY $x0
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
79    $w0 = COPY %5(s32)
80    RET_ReallyLR implicit $w0
81...
82---
83name: icmp_not_xor_with_wrong_bool_contents
84tracksRegLiveness: true
85body:             |
86  bb.1:
87    liveins: $x0
88
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
92    ; CHECK: liveins: $x0
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
100    %0:_(s64) = COPY $x0
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
105    $w0 = COPY %4(s32)
106    RET_ReallyLR implicit $w0
107...
108---
109name: icmp_multiple_use
110tracksRegLiveness: true
111body:             |
112  bb.1:
113    liveins: $x0
114
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
128    %0:_(s64) = COPY $x0
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
136    $w0 = COPY %5(s32)
137    $w1 = COPY %other_use_ext
138    RET_ReallyLR implicit $w0
139...
140---
141name: icmp_vector
142tracksRegLiveness: true
143body:             |
144  bb.1:
145    liveins: $q0
146
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
166...
167---
168name: icmp_and_icmp
169tracksRegLiveness: true
170body:             |
171  bb.1:
172    liveins: $x0
173
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
184    %0:_(s64) = COPY $x0
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
192    $w0 = COPY %7(s32)
193    RET_ReallyLR implicit $w0
194...
195---
196name: icmp_or_icmp
197tracksRegLiveness: true
198body:             |
199  bb.1:
200    liveins: $x0
201
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
212    %0:_(s64) = COPY $x0
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
220    $w0 = COPY %7(s32)
221    RET_ReallyLR implicit $w0
222...
223---
224name: icmp_and_icmp_or_icmp
225tracksRegLiveness: true
226body:             |
227  bb.1:
228    liveins: $x0
229
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
242    %0:_(s64) = COPY $x0
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
252    $w0 = COPY %9(s32)
253    RET_ReallyLR implicit $w0
254...
255---
256name: icmp_and_trunc
257tracksRegLiveness: true
258body:             |
259  bb.1:
260    liveins: $x0
261
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
274    %0:_(s64) = COPY $x0
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
282    $w0 = COPY %7(s32)
283    RET_ReallyLR implicit $w0
284...
285