1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple arm-eabi -mattr=+v6t2 | FileCheck %s
4 define i4 @parity_4(i4 %x) {
5 ; CHECK-LABEL: parity_4:
7 ; CHECK-NEXT: and r0, r0, #15
8 ; CHECK-NEXT: eor r0, r0, r0, lsr #2
9 ; CHECK-NEXT: eor r0, r0, r0, lsr #1
10 ; CHECK-NEXT: and r0, r0, #1
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: uxtb r0, r0
21 ; CHECK-NEXT: eor r0, r0, r0, lsr #4
22 ; CHECK-NEXT: eor r0, r0, r0, lsr #2
23 ; CHECK-NEXT: eor r0, r0, r0, lsr #1
24 ; CHECK-NEXT: and r0, r0, #1
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: uxth r0, r0
35 ; CHECK-NEXT: eor r0, r0, r0, lsr #8
36 ; CHECK-NEXT: eor r0, r0, r0, lsr #4
37 ; CHECK-NEXT: eor r0, r0, r0, lsr #2
38 ; CHECK-NEXT: eor r0, r0, r0, lsr #1
39 ; CHECK-NEXT: and r0, r0, #1
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: bfc r0, #17, #15
50 ; CHECK-NEXT: eor r1, r0, r0, lsr #16
51 ; CHECK-NEXT: eor r0, r1, r0, lsr #8
52 ; CHECK-NEXT: eor r0, r0, r0, lsr #4
53 ; CHECK-NEXT: eor r0, r0, r0, lsr #2
54 ; CHECK-NEXT: eor r0, r0, r0, lsr #1
55 ; CHECK-NEXT: and r0, r0, #1
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 r0, r0, r0, lsr #16
66 ; CHECK-NEXT: eor r0, r0, r0, lsr #8
67 ; CHECK-NEXT: eor r0, r0, r0, lsr #4
68 ; CHECK-NEXT: eor r0, r0, r0, lsr #2
69 ; CHECK-NEXT: eor r0, r0, r0, lsr #1
70 ; CHECK-NEXT: and r0, r0, #1
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 r0, r0, r1
81 ; CHECK-NEXT: mov r1, #0
82 ; CHECK-NEXT: eor r0, r0, r0, lsr #16
83 ; CHECK-NEXT: eor r0, r0, r0, lsr #8
84 ; CHECK-NEXT: eor r0, r0, r0, lsr #4
85 ; CHECK-NEXT: eor r0, r0, r0, lsr #2
86 ; CHECK-NEXT: eor r0, r0, r0, lsr #1
87 ; CHECK-NEXT: and r0, r0, #1
89 %1 = tail call i64 @llvm.ctpop.i64(i64 %x)
94 define i32 @parity_64_trunc(i64 %x) {
95 ; CHECK-LABEL: parity_64_trunc:
97 ; CHECK-NEXT: eor r0, r0, r1
98 ; CHECK-NEXT: eor r0, r0, r0, lsr #16
99 ; CHECK-NEXT: eor r0, r0, r0, lsr #8
100 ; CHECK-NEXT: eor r0, r0, r0, lsr #4
101 ; CHECK-NEXT: eor r0, r0, r0, lsr #2
102 ; CHECK-NEXT: eor r0, r0, r0, lsr #1
103 ; CHECK-NEXT: and r0, r0, #1
105 %1 = tail call i64 @llvm.ctpop.i64(i64 %x)
106 %2 = trunc i64 %1 to i32
111 define i8 @parity_32_trunc(i32 %x) {
112 ; CHECK-LABEL: parity_32_trunc:
114 ; CHECK-NEXT: eor r0, r0, r0, lsr #16
115 ; CHECK-NEXT: eor r0, r0, r0, lsr #8
116 ; CHECK-NEXT: eor r0, r0, r0, lsr #4
117 ; CHECK-NEXT: eor r0, r0, r0, lsr #2
118 ; CHECK-NEXT: eor r0, r0, r0, lsr #1
119 ; CHECK-NEXT: and r0, r0, #1
121 %1 = tail call i32 @llvm.ctpop.i32(i32 %x)
122 %2 = trunc i32 %1 to i8
127 define i32 @parity_8_zext(i8 %x) {
128 ; CHECK-LABEL: parity_8_zext:
130 ; CHECK-NEXT: uxtb r0, r0
131 ; CHECK-NEXT: eor r0, r0, r0, lsr #4
132 ; CHECK-NEXT: eor r0, r0, r0, lsr #2
133 ; CHECK-NEXT: eor r0, r0, r0, lsr #1
134 ; CHECK-NEXT: and r0, r0, #1
136 %a = zext i8 %x to i32
137 %b = tail call i32 @llvm.ctpop.i32(i32 %a)
142 define i32 @parity_8_mask(i32 %x) {
143 ; CHECK-LABEL: parity_8_mask:
145 ; CHECK-NEXT: uxtb r0, r0
146 ; CHECK-NEXT: eor r0, r0, r0, lsr #4
147 ; CHECK-NEXT: eor r0, r0, r0, lsr #2
148 ; CHECK-NEXT: eor r0, r0, r0, lsr #1
149 ; CHECK-NEXT: and r0, r0, #1
152 %b = tail call i32 @llvm.ctpop.i32(i32 %a)
157 declare i4 @llvm.ctpop.i4(i4 %x)
158 declare i8 @llvm.ctpop.i8(i8 %x)
159 declare i16 @llvm.ctpop.i16(i16 %x)
160 declare i17 @llvm.ctpop.i17(i17 %x)
161 declare i32 @llvm.ctpop.i32(i32 %x)
162 declare i64 @llvm.ctpop.i64(i64 %x)