1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -o - %s -mtriple=aarch64-linux-gnu | FileCheck %s
3 ; RUN: llc -verify-machineinstrs -o - %s -mtriple=aarch64-linux-gnu -mattr=+cssc | FileCheck %s -check-prefix=CHECK-CSSC
5 define i4 @parity_4(i4 %x) {
6 ; CHECK-LABEL: parity_4:
8 ; CHECK-NEXT: and w8, w0, #0xf
9 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
10 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
11 ; CHECK-NEXT: and w0, w8, #0x1
14 ; CHECK-CSSC-LABEL: parity_4:
15 ; CHECK-CSSC: // %bb.0:
16 ; CHECK-CSSC-NEXT: and w8, w0, #0xf
17 ; CHECK-CSSC-NEXT: cnt w8, w8
18 ; CHECK-CSSC-NEXT: and w0, w8, #0x1
19 ; CHECK-CSSC-NEXT: ret
20 %1 = tail call i4 @llvm.ctpop.i4(i4 %x)
25 define i8 @parity_8(i8 %x) {
26 ; CHECK-LABEL: parity_8:
28 ; CHECK-NEXT: and w8, w0, #0xff
29 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
30 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
31 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
32 ; CHECK-NEXT: and w0, w8, #0x1
35 ; CHECK-CSSC-LABEL: parity_8:
36 ; CHECK-CSSC: // %bb.0:
37 ; CHECK-CSSC-NEXT: and w8, w0, #0xff
38 ; CHECK-CSSC-NEXT: cnt w8, w8
39 ; CHECK-CSSC-NEXT: and w0, w8, #0x1
40 ; CHECK-CSSC-NEXT: ret
41 %1 = tail call i8 @llvm.ctpop.i8(i8 %x)
46 define i16 @parity_16(i16 %x) {
47 ; CHECK-LABEL: parity_16:
49 ; CHECK-NEXT: and w8, w0, #0xffff
50 ; CHECK-NEXT: eor w8, w8, w8, lsr #8
51 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
52 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
53 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
54 ; CHECK-NEXT: and w0, w8, #0x1
57 ; CHECK-CSSC-LABEL: parity_16:
58 ; CHECK-CSSC: // %bb.0:
59 ; CHECK-CSSC-NEXT: and w8, w0, #0xffff
60 ; CHECK-CSSC-NEXT: cnt w8, w8
61 ; CHECK-CSSC-NEXT: and w0, w8, #0x1
62 ; CHECK-CSSC-NEXT: ret
63 %1 = tail call i16 @llvm.ctpop.i16(i16 %x)
68 define i17 @parity_17(i17 %x) {
69 ; CHECK-LABEL: parity_17:
71 ; CHECK-NEXT: and w8, w0, #0x1ffff
72 ; CHECK-NEXT: eor w9, w8, w8, lsr #16
73 ; CHECK-NEXT: eor w8, w9, w8, lsr #8
74 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
75 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
76 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
77 ; CHECK-NEXT: and w0, w8, #0x1
80 ; CHECK-CSSC-LABEL: parity_17:
81 ; CHECK-CSSC: // %bb.0:
82 ; CHECK-CSSC-NEXT: and w8, w0, #0x1ffff
83 ; CHECK-CSSC-NEXT: cnt w8, w8
84 ; CHECK-CSSC-NEXT: and w0, w8, #0x1
85 ; CHECK-CSSC-NEXT: ret
86 %1 = tail call i17 @llvm.ctpop.i17(i17 %x)
91 define i32 @parity_32(i32 %x) {
92 ; CHECK-LABEL: parity_32:
94 ; CHECK-NEXT: eor w8, w0, w0, lsr #16
95 ; CHECK-NEXT: eor w8, w8, w8, lsr #8
96 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
97 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
98 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
99 ; CHECK-NEXT: and w0, w8, #0x1
102 ; CHECK-CSSC-LABEL: parity_32:
103 ; CHECK-CSSC: // %bb.0:
104 ; CHECK-CSSC-NEXT: cnt w8, w0
105 ; CHECK-CSSC-NEXT: and w0, w8, #0x1
106 ; CHECK-CSSC-NEXT: ret
107 %1 = tail call i32 @llvm.ctpop.i32(i32 %x)
112 define i64 @parity_64(i64 %x) {
113 ; CHECK-LABEL: parity_64:
115 ; CHECK-NEXT: fmov d0, x0
116 ; CHECK-NEXT: cnt v0.8b, v0.8b
117 ; CHECK-NEXT: uaddlv h0, v0.8b
118 ; CHECK-NEXT: fmov w8, s0
119 ; CHECK-NEXT: and w0, w8, #0x1
122 ; CHECK-CSSC-LABEL: parity_64:
123 ; CHECK-CSSC: // %bb.0:
124 ; CHECK-CSSC-NEXT: cnt x8, x0
125 ; CHECK-CSSC-NEXT: and x0, x8, #0x1
126 ; CHECK-CSSC-NEXT: ret
127 %1 = tail call i64 @llvm.ctpop.i64(i64 %x)
132 define i128 @parity_128(i128 %x) {
133 ; CHECK-LABEL: parity_128:
135 ; CHECK-NEXT: fmov d0, x0
136 ; CHECK-NEXT: mov v0.d[1], x1
137 ; CHECK-NEXT: mov x1, xzr
138 ; CHECK-NEXT: cnt v0.16b, v0.16b
139 ; CHECK-NEXT: uaddlv h0, v0.16b
140 ; CHECK-NEXT: fmov w8, s0
141 ; CHECK-NEXT: and w0, w8, #0x1
144 ; CHECK-CSSC-LABEL: parity_128:
145 ; CHECK-CSSC: // %bb.0:
146 ; CHECK-CSSC-NEXT: eor x8, x0, x1
147 ; CHECK-CSSC-NEXT: mov x1, xzr
148 ; CHECK-CSSC-NEXT: cnt x8, x8
149 ; CHECK-CSSC-NEXT: and x0, x8, #0x1
150 ; CHECK-CSSC-NEXT: ret
151 %1 = tail call i128 @llvm.ctpop.i128(i128 %x)
156 define i32 @parity_64_trunc(i64 %x) {
157 ; CHECK-LABEL: parity_64_trunc:
159 ; CHECK-NEXT: fmov d0, x0
160 ; CHECK-NEXT: cnt v0.8b, v0.8b
161 ; CHECK-NEXT: uaddlv h0, v0.8b
162 ; CHECK-NEXT: fmov w8, s0
163 ; CHECK-NEXT: and w0, w8, #0x1
166 ; CHECK-CSSC-LABEL: parity_64_trunc:
167 ; CHECK-CSSC: // %bb.0:
168 ; CHECK-CSSC-NEXT: cnt x8, x0
169 ; CHECK-CSSC-NEXT: and w0, w8, #0x1
170 ; CHECK-CSSC-NEXT: ret
171 %1 = tail call i64 @llvm.ctpop.i64(i64 %x)
172 %2 = trunc i64 %1 to i32
177 define i8 @parity_32_trunc(i32 %x) {
178 ; CHECK-LABEL: parity_32_trunc:
180 ; CHECK-NEXT: eor w8, w0, w0, lsr #16
181 ; CHECK-NEXT: eor w8, w8, w8, lsr #8
182 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
183 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
184 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
185 ; CHECK-NEXT: and w0, w8, #0x1
188 ; CHECK-CSSC-LABEL: parity_32_trunc:
189 ; CHECK-CSSC: // %bb.0:
190 ; CHECK-CSSC-NEXT: cnt w8, w0
191 ; CHECK-CSSC-NEXT: and w0, w8, #0x1
192 ; CHECK-CSSC-NEXT: ret
193 %1 = tail call i32 @llvm.ctpop.i32(i32 %x)
194 %2 = trunc i32 %1 to i8
199 define i32 @parity_8_zext(i8 %x) {
200 ; CHECK-LABEL: parity_8_zext:
202 ; CHECK-NEXT: and w8, w0, #0xff
203 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
204 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
205 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
206 ; CHECK-NEXT: and w0, w8, #0x1
209 ; CHECK-CSSC-LABEL: parity_8_zext:
210 ; CHECK-CSSC: // %bb.0:
211 ; CHECK-CSSC-NEXT: and w8, w0, #0xff
212 ; CHECK-CSSC-NEXT: cnt w8, w8
213 ; CHECK-CSSC-NEXT: and w0, w8, #0x1
214 ; CHECK-CSSC-NEXT: ret
215 %a = zext i8 %x to i32
216 %b = tail call i32 @llvm.ctpop.i32(i32 %a)
221 define i32 @parity_8_mask(i32 %x) {
222 ; CHECK-LABEL: parity_8_mask:
224 ; CHECK-NEXT: and w8, w0, #0xff
225 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
226 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
227 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
228 ; CHECK-NEXT: and w0, w8, #0x1
231 ; CHECK-CSSC-LABEL: parity_8_mask:
232 ; CHECK-CSSC: // %bb.0:
233 ; CHECK-CSSC-NEXT: and w8, w0, #0xff
234 ; CHECK-CSSC-NEXT: cnt w8, w8
235 ; CHECK-CSSC-NEXT: and w0, w8, #0x1
236 ; CHECK-CSSC-NEXT: ret
238 %b = tail call i32 @llvm.ctpop.i32(i32 %a)
243 declare i4 @llvm.ctpop.i4(i4 %x)
244 declare i8 @llvm.ctpop.i8(i8 %x)
245 declare i16 @llvm.ctpop.i16(i16 %x)
246 declare i17 @llvm.ctpop.i17(i17 %x)
247 declare i32 @llvm.ctpop.i32(i32 %x)
248 declare i64 @llvm.ctpop.i64(i64 %x)
249 declare i128 @llvm.ctpop.i128(i128 %x)