1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
3 # RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner --aarch64prelegalizercombiner-only-enable-rule="icmp_to_lhs_known_bits" -global-isel -verify-machineinstrs %s -o - | FileCheck %s
10 tracksRegLiveness: true
11 machineFunctionInfo: {}
15 ; CHECK-LABEL: name: apply_ne
17 ; CHECK: %x:_(s32) = COPY $w0
18 ; CHECK: %one:_(s32) = G_CONSTANT i32 1
19 ; CHECK: %known_zero_or_one:_(s32) = G_AND %x, %one
20 ; CHECK: %cmp:_(s1) = G_TRUNC %known_zero_or_one(s32)
21 ; CHECK: %ext:_(s32) = G_ZEXT %cmp(s1)
22 ; CHECK: $w0 = COPY %ext(s32)
23 ; CHECK: RET_ReallyLR implicit $w0
25 %one:_(s32) = G_CONSTANT i32 1
26 %known_zero_or_one:_(s32) = G_AND %x, %one
27 %zero:_(s32) = G_CONSTANT i32 0
28 %cmp:_(s1) = G_ICMP intpred(ne), %known_zero_or_one(s32), %zero
29 %ext:_(s32) = G_ZEXT %cmp(s1)
31 RET_ReallyLR implicit $w0
37 tracksRegLiveness: true
38 machineFunctionInfo: {}
42 ; CHECK-LABEL: name: apply_eq
44 ; CHECK: %x:_(s32) = COPY $w0
45 ; CHECK: %one:_(s32) = G_CONSTANT i32 1
46 ; CHECK: %known_zero_or_one:_(s32) = G_AND %x, %one
47 ; CHECK: %cmp:_(s1) = G_TRUNC %known_zero_or_one(s32)
48 ; CHECK: %ext:_(s32) = G_ZEXT %cmp(s1)
49 ; CHECK: $w0 = COPY %ext(s32)
50 ; CHECK: RET_ReallyLR implicit $w0
52 %one:_(s32) = G_CONSTANT i32 1
53 %known_zero_or_one:_(s32) = G_AND %x, %one
54 %cmp:_(s1) = G_ICMP intpred(eq), %known_zero_or_one(s32), %one
55 %ext:_(s32) = G_ZEXT %cmp(s1)
57 RET_ReallyLR implicit $w0
61 name: dont_apply_wrong_cst_eq
63 tracksRegLiveness: true
64 machineFunctionInfo: {}
68 ; Wrong constant on the RHS of the compare.
70 ; CHECK-LABEL: name: dont_apply_wrong_cst_eq
72 ; CHECK: %x:_(s32) = COPY $w0
73 ; CHECK: %one:_(s32) = G_CONSTANT i32 1
74 ; CHECK: %known_zero_or_one:_(s32) = G_AND %x, %one
75 ; CHECK: %wrong_cst:_(s32) = G_CONSTANT i32 10
76 ; CHECK: %cmp:_(s1) = G_ICMP intpred(eq), %known_zero_or_one(s32), %wrong_cst
77 ; CHECK: %ext:_(s32) = G_ZEXT %cmp(s1)
78 ; CHECK: $w0 = COPY %ext(s32)
79 ; CHECK: RET_ReallyLR implicit $w0
81 %one:_(s32) = G_CONSTANT i32 1
82 %known_zero_or_one:_(s32) = G_AND %x, %one
83 %wrong_cst:_(s32) = G_CONSTANT i32 10
84 %cmp:_(s1) = G_ICMP intpred(eq), %known_zero_or_one(s32), %wrong_cst
85 %ext:_(s32) = G_ZEXT %cmp(s1)
87 RET_ReallyLR implicit $w0
91 name: dont_apply_wrong_cst_ne
93 tracksRegLiveness: true
94 machineFunctionInfo: {}
98 ; Wrong constant on the RHS of the compare.
100 ; CHECK-LABEL: name: dont_apply_wrong_cst_ne
101 ; CHECK: liveins: $w0
102 ; CHECK: %x:_(s32) = COPY $w0
103 ; CHECK: %one:_(s32) = G_CONSTANT i32 1
104 ; CHECK: %known_zero_or_one:_(s32) = G_AND %x, %one
105 ; CHECK: %wrong_cst:_(s32) = G_CONSTANT i32 10
106 ; CHECK: %cmp:_(s1) = G_ICMP intpred(ne), %known_zero_or_one(s32), %wrong_cst
107 ; CHECK: %ext:_(s32) = G_ZEXT %cmp(s1)
108 ; CHECK: $w0 = COPY %ext(s32)
109 ; CHECK: RET_ReallyLR implicit $w0
111 %one:_(s32) = G_CONSTANT i32 1
112 %known_zero_or_one:_(s32) = G_AND %x, %one
113 %wrong_cst:_(s32) = G_CONSTANT i32 10
114 %cmp:_(s1) = G_ICMP intpred(ne), %known_zero_or_one(s32), %wrong_cst
115 %ext:_(s32) = G_ZEXT %cmp(s1)
117 RET_ReallyLR implicit $w0
121 name: dont_apply_vector
123 tracksRegLiveness: true
124 machineFunctionInfo: {}
128 ; True is -1 for vectors on AArch64 so we don't want to combine.
130 ; CHECK-LABEL: name: dont_apply_vector
131 ; CHECK: liveins: $x0
133 ; CHECK-NEXT: %x:_(<2 x s32>) = COPY $x0
134 ; CHECK-NEXT: %one:_(s32) = G_CONSTANT i32 1
135 ; CHECK-NEXT: %one_vec:_(<2 x s32>) = G_BUILD_VECTOR %one(s32), %one(s32)
136 ; CHECK-NEXT: %vec_and:_(<2 x s32>) = G_AND %x, %one_vec
137 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
138 ; CHECK-NEXT: %zero64:_(s64) = G_CONSTANT i64 0
139 ; CHECK-NEXT: %zero_vec:_(<2 x s32>) = G_BUILD_VECTOR %zero(s32), %zero(s32)
140 ; CHECK-NEXT: %cmp:_(<2 x s1>) = G_ICMP intpred(ne), %vec_and(<2 x s32>), %zero_vec
141 ; CHECK-NEXT: %elt:_(s1) = G_EXTRACT_VECTOR_ELT %cmp(<2 x s1>), %zero64(s64)
142 ; CHECK-NEXT: %ext:_(s32) = G_ZEXT %elt(s1)
143 ; CHECK-NEXT: $w0 = COPY %ext(s32)
144 ; CHECK-NEXT: RET_ReallyLR implicit $w0
145 %x:_(<2 x s32>) = COPY $x0
146 %one:_(s32) = G_CONSTANT i32 1
147 %one_vec:_(<2 x s32>) = G_BUILD_VECTOR %one, %one
148 %vec_and:_(<2 x s32>) = G_AND %x, %one_vec
149 %zero:_(s32) = G_CONSTANT i32 0
150 %zero64:_(s64) = G_CONSTANT i64 0
151 %zero_vec:_(<2 x s32>) = G_BUILD_VECTOR %zero, %zero
152 %cmp:_(<2 x s1>) = G_ICMP intpred(ne), %vec_and(<2 x s32>), %zero_vec
153 %elt:_(s1) = G_EXTRACT_VECTOR_ELT %cmp, %zero64
154 %ext:_(s32) = G_ZEXT %elt(s1)
156 RET_ReallyLR implicit $w0
160 name: apply_no_zext_or_trunc
162 tracksRegLiveness: true
163 machineFunctionInfo: {}
167 ; CHECK-LABEL: name: apply_no_zext_or_trunc
168 ; CHECK: liveins: $w0
169 ; CHECK: %x:_(s32) = COPY $w0
170 ; CHECK: %one:_(s32) = G_CONSTANT i32 1
171 ; CHECK: %known_zero_or_one:_(s32) = G_AND %x, %one
172 ; CHECK: %cmp:_(s32) = COPY %known_zero_or_one(s32)
173 ; CHECK: $w0 = COPY %cmp(s32)
174 ; CHECK: RET_ReallyLR implicit $w0
176 %one:_(s32) = G_CONSTANT i32 1
177 %known_zero_or_one:_(s32) = G_AND %x, %one
178 %zero:_(s32) = G_CONSTANT i32 0
179 %cmp:_(s32) = G_ICMP intpred(ne), %known_zero_or_one(s32), %zero
181 RET_ReallyLR implicit $w0
187 tracksRegLiveness: true
188 machineFunctionInfo: {}
192 ; CHECK-LABEL: name: apply_wide_cmp
193 ; CHECK: liveins: $w0
194 ; CHECK: %x:_(s64) = COPY $x0
195 ; CHECK: %one:_(s64) = G_CONSTANT i64 1
196 ; CHECK: %known_zero_or_one:_(s64) = G_AND %x, %one
197 ; CHECK: %cmp:_(s64) = COPY %known_zero_or_one(s64)
198 ; CHECK: %trunc:_(s32) = G_TRUNC %cmp(s64)
199 ; CHECK: $w0 = COPY %trunc(s32)
200 ; CHECK: RET_ReallyLR implicit $w0
202 %one:_(s64) = G_CONSTANT i64 1
203 %known_zero_or_one:_(s64) = G_AND %x, %one
204 %zero:_(s64) = G_CONSTANT i64 0
205 %cmp:_(s64) = G_ICMP intpred(ne), %known_zero_or_one(s64), %zero
206 %trunc:_(s32) = G_TRUNC %cmp
207 $w0 = COPY %trunc(s32)
208 RET_ReallyLR implicit $w0
212 name: apply_narrow_lhs
214 tracksRegLiveness: true
215 machineFunctionInfo: {}
219 ; CHECK-LABEL: name: apply_narrow_lhs
220 ; CHECK: liveins: $w0
221 ; CHECK: %x:_(s32) = COPY $w0
222 ; CHECK: %one:_(s32) = G_CONSTANT i32 1
223 ; CHECK: %known_zero_or_one:_(s32) = G_AND %x, %one
224 ; CHECK: %cmp:_(s64) = G_ZEXT %known_zero_or_one(s32)
225 ; CHECK: $x0 = COPY %cmp(s64)
226 ; CHECK: RET_ReallyLR implicit $x0
228 %one:_(s32) = G_CONSTANT i32 1
229 %known_zero_or_one:_(s32) = G_AND %x, %one
230 %zero:_(s32) = G_CONSTANT i32 0
231 %cmp:_(s64) = G_ICMP intpred(ne), %known_zero_or_one(s32), %zero
233 RET_ReallyLR implicit $x0