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
4 define i4 @parity_4(i4 %x) {
5 ; CHECK-LABEL: parity_4:
7 ; CHECK-NEXT: and w8, w0, #0xf
8 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
9 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
10 ; CHECK-NEXT: and w0, w8, #0x1
12 %1 = tail call i4 @llvm.ctpop.i4(i4 %x)
17 define i8 @parity_8(i8 %x) {
18 ; CHECK-LABEL: parity_8:
20 ; CHECK-NEXT: and w8, w0, #0xff
21 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
22 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
23 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
24 ; CHECK-NEXT: and w0, w8, #0x1
26 %1 = tail call i8 @llvm.ctpop.i8(i8 %x)
31 define i16 @parity_16(i16 %x) {
32 ; CHECK-LABEL: parity_16:
34 ; CHECK-NEXT: and w8, w0, #0xffff
35 ; CHECK-NEXT: eor w8, w8, w8, lsr #8
36 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
37 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
38 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
39 ; CHECK-NEXT: and w0, w8, #0x1
41 %1 = tail call i16 @llvm.ctpop.i16(i16 %x)
46 define i17 @parity_17(i17 %x) {
47 ; CHECK-LABEL: parity_17:
49 ; CHECK-NEXT: and w8, w0, #0x1ffff
50 ; CHECK-NEXT: eor w8, w8, w8, lsr #16
51 ; CHECK-NEXT: eor w8, w8, w8, lsr #8
52 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
53 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
54 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
55 ; CHECK-NEXT: and w0, w8, #0x1
57 %1 = tail call i17 @llvm.ctpop.i17(i17 %x)
62 define i32 @parity_32(i32 %x) {
63 ; CHECK-LABEL: parity_32:
65 ; CHECK-NEXT: eor w8, w0, w0, lsr #16
66 ; CHECK-NEXT: eor w8, w8, w8, lsr #8
67 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
68 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
69 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
70 ; CHECK-NEXT: and w0, w8, #0x1
72 %1 = tail call i32 @llvm.ctpop.i32(i32 %x)
77 define i64 @parity_64(i64 %x) {
78 ; CHECK-LABEL: parity_64:
80 ; CHECK-NEXT: eor x8, x0, x0, lsr #32
81 ; CHECK-NEXT: eor x8, x8, x8, lsr #16
82 ; CHECK-NEXT: eor x8, x8, x8, lsr #8
83 ; CHECK-NEXT: eor x8, x8, x8, lsr #4
84 ; CHECK-NEXT: eor x8, x8, x8, lsr #2
85 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
86 ; CHECK-NEXT: and x0, x8, #0x1
88 %1 = tail call i64 @llvm.ctpop.i64(i64 %x)
93 define i32 @parity_64_trunc(i64 %x) {
94 ; CHECK-LABEL: parity_64_trunc:
96 ; CHECK-NEXT: eor x8, x0, x0, lsr #32
97 ; CHECK-NEXT: eor x8, x8, x8, lsr #16
98 ; CHECK-NEXT: eor x8, x8, x8, lsr #8
99 ; CHECK-NEXT: eor x8, x8, x8, lsr #4
100 ; CHECK-NEXT: eor x8, x8, x8, lsr #2
101 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
102 ; CHECK-NEXT: and w0, w8, #0x1
104 %1 = tail call i64 @llvm.ctpop.i64(i64 %x)
105 %2 = trunc i64 %1 to i32
110 define i8 @parity_32_trunc(i32 %x) {
111 ; CHECK-LABEL: parity_32_trunc:
113 ; CHECK-NEXT: eor w8, w0, w0, lsr #16
114 ; CHECK-NEXT: eor w8, w8, w8, lsr #8
115 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
116 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
117 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
118 ; CHECK-NEXT: and w0, w8, #0x1
120 %1 = tail call i32 @llvm.ctpop.i32(i32 %x)
121 %2 = trunc i32 %1 to i8
126 define i32 @parity_8_zext(i8 %x) {
127 ; CHECK-LABEL: parity_8_zext:
129 ; CHECK-NEXT: and w8, w0, #0xff
130 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
131 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
132 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
133 ; CHECK-NEXT: and w0, w8, #0x1
135 %a = zext i8 %x to i32
136 %b = tail call i32 @llvm.ctpop.i32(i32 %a)
141 define i32 @parity_8_mask(i32 %x) {
142 ; CHECK-LABEL: parity_8_mask:
144 ; CHECK-NEXT: and w8, w0, #0xff
145 ; CHECK-NEXT: eor w8, w8, w8, lsr #4
146 ; CHECK-NEXT: eor w8, w8, w8, lsr #2
147 ; CHECK-NEXT: eor w8, w8, w8, lsr #1
148 ; CHECK-NEXT: and w0, w8, #0x1
151 %b = tail call i32 @llvm.ctpop.i32(i32 %a)
156 declare i4 @llvm.ctpop.i4(i4 %x)
157 declare i8 @llvm.ctpop.i8(i8 %x)
158 declare i16 @llvm.ctpop.i16(i16 %x)
159 declare i17 @llvm.ctpop.i17(i17 %x)
160 declare i32 @llvm.ctpop.i32(i32 %x)
161 declare i64 @llvm.ctpop.i64(i64 %x)