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
132 ; CHECK: %x:_(<2 x s32>) = COPY $x0
133 ; CHECK: %one:_(s32) = G_CONSTANT i32 1
134 ; CHECK: %one_vec:_(<2 x s32>) = G_BUILD_VECTOR %one(s32), %one(s32)
135 ; CHECK: %vec_and:_(<2 x s32>) = G_AND %x, %one_vec
136 ; CHECK: %zero:_(s32) = G_CONSTANT i32 0
137 ; CHECK: %zero_vec:_(<2 x s32>) = G_BUILD_VECTOR %zero(s32), %zero(s32)
138 ; CHECK: %cmp:_(<2 x s1>) = G_ICMP intpred(ne), %vec_and(<2 x s32>), %zero_vec
139 ; CHECK: %elt:_(s1) = G_EXTRACT_VECTOR_ELT %cmp(<2 x s1>), %zero(s32)
140 ; CHECK: %ext:_(s32) = G_ZEXT %elt(s1)
141 ; CHECK: $w0 = COPY %ext(s32)
142 ; CHECK: RET_ReallyLR implicit $w0
143 %x:_(<2 x s32>) = COPY $x0
144 %one:_(s32) = G_CONSTANT i32 1
145 %one_vec:_(<2 x s32>) = G_BUILD_VECTOR %one, %one
146 %vec_and:_(<2 x s32>) = G_AND %x, %one_vec
147 %zero:_(s32) = G_CONSTANT i32 0
148 %zero_vec:_(<2 x s32>) = G_BUILD_VECTOR %zero, %zero
149 %cmp:_(<2 x s1>) = G_ICMP intpred(ne), %vec_and(<2 x s32>), %zero_vec
150 %elt:_(s1) = G_EXTRACT_VECTOR_ELT %cmp, %zero
151 %ext:_(s32) = G_ZEXT %elt(s1)
153 RET_ReallyLR implicit $w0
157 name: apply_no_zext_or_trunc
159 tracksRegLiveness: true
160 machineFunctionInfo: {}
164 ; CHECK-LABEL: name: apply_no_zext_or_trunc
165 ; CHECK: liveins: $w0
166 ; CHECK: %x:_(s32) = COPY $w0
167 ; CHECK: %one:_(s32) = G_CONSTANT i32 1
168 ; CHECK: %known_zero_or_one:_(s32) = G_AND %x, %one
169 ; CHECK: %cmp:_(s32) = COPY %known_zero_or_one(s32)
170 ; CHECK: $w0 = COPY %cmp(s32)
171 ; CHECK: RET_ReallyLR implicit $w0
173 %one:_(s32) = G_CONSTANT i32 1
174 %known_zero_or_one:_(s32) = G_AND %x, %one
175 %zero:_(s32) = G_CONSTANT i32 0
176 %cmp:_(s32) = G_ICMP intpred(ne), %known_zero_or_one(s32), %zero
178 RET_ReallyLR implicit $w0
184 tracksRegLiveness: true
185 machineFunctionInfo: {}
189 ; CHECK-LABEL: name: apply_wide_cmp
190 ; CHECK: liveins: $w0
191 ; CHECK: %x:_(s64) = COPY $x0
192 ; CHECK: %one:_(s64) = G_CONSTANT i64 1
193 ; CHECK: %known_zero_or_one:_(s64) = G_AND %x, %one
194 ; CHECK: %cmp:_(s64) = COPY %known_zero_or_one(s64)
195 ; CHECK: %trunc:_(s32) = G_TRUNC %cmp(s64)
196 ; CHECK: $w0 = COPY %trunc(s32)
197 ; CHECK: RET_ReallyLR implicit $w0
199 %one:_(s64) = G_CONSTANT i64 1
200 %known_zero_or_one:_(s64) = G_AND %x, %one
201 %zero:_(s64) = G_CONSTANT i64 0
202 %cmp:_(s64) = G_ICMP intpred(ne), %known_zero_or_one(s64), %zero
203 %trunc:_(s32) = G_TRUNC %cmp
204 $w0 = COPY %trunc(s32)
205 RET_ReallyLR implicit $w0
209 name: apply_narrow_lhs
211 tracksRegLiveness: true
212 machineFunctionInfo: {}
216 ; CHECK-LABEL: name: apply_narrow_lhs
217 ; CHECK: liveins: $w0
218 ; CHECK: %x:_(s32) = COPY $w0
219 ; CHECK: %one:_(s32) = G_CONSTANT i32 1
220 ; CHECK: %known_zero_or_one:_(s32) = G_AND %x, %one
221 ; CHECK: %cmp:_(s64) = G_ZEXT %known_zero_or_one(s32)
222 ; CHECK: $x0 = COPY %cmp(s64)
223 ; CHECK: RET_ReallyLR implicit $x0
225 %one:_(s32) = G_CONSTANT i32 1
226 %known_zero_or_one:_(s32) = G_AND %x, %one
227 %zero:_(s32) = G_CONSTANT i32 0
228 %cmp:_(s64) = G_ICMP intpred(ne), %known_zero_or_one(s32), %zero
230 RET_ReallyLR implicit $x0