llvm.org GIT mirror llvm / ab694ed
[NFC] Added tests for D63004 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362801 91177308-0d34-0410-b5e6-96231b3b80d8 David Bolvansky 4 months ago
2 changed file(s) with 274 addition(s) and 57 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
1 ; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple | FileCheck %s
12 ; RUN: llc < %s -mtriple=aarch64-eabi -mattr -neon -aarch64-neon-syntax=apple | FileCheck -check-prefix=CHECK-NONEON %s
23
34 define i32 @cnt32_advsimd(i32 %x) nounwind readnone {
5 ; CHECK-LABEL: cnt32_advsimd:
6 ; CHECK: // %bb.0:
7 ; CHECK-NEXT: mov w8, w0
8 ; CHECK-NEXT: fmov d0, x8
9 ; CHECK-NEXT: cnt.8b v0, v0
10 ; CHECK-NEXT: uaddlv.8b h0, v0
11 ; CHECK-NEXT: fmov w0, s0
12 ; CHECK-NEXT: ret
13 ;
14 ; CHECK-NONEON-LABEL: cnt32_advsimd:
15 ; CHECK-NONEON: // %bb.0:
16 ; CHECK-NONEON-NEXT: lsr w8, w0, #1
17 ; CHECK-NONEON-NEXT: and w8, w8, #0x55555555
18 ; CHECK-NONEON-NEXT: sub w8, w0, w8
19 ; CHECK-NONEON-NEXT: and w9, w8, #0x33333333
20 ; CHECK-NONEON-NEXT: lsr w8, w8, #2
21 ; CHECK-NONEON-NEXT: and w8, w8, #0x33333333
22 ; CHECK-NONEON-NEXT: add w8, w9, w8
23 ; CHECK-NONEON-NEXT: add w8, w8, w8, lsr #4
24 ; CHECK-NONEON-NEXT: and w8, w8, #0xf0f0f0f
25 ; CHECK-NONEON-NEXT: mov w9, #16843009
26 ; CHECK-NONEON-NEXT: mul w8, w8, w9
27 ; CHECK-NONEON-NEXT: lsr w0, w8, #24
28 ; CHECK-NONEON-NEXT: ret
429 %cnt = tail call i32 @llvm.ctpop.i32(i32 %x)
530 ret i32 %cnt
6 ; CHECK: mov w[[IN64:[0-9]+]], w0
7 ; CHECK: fmov d0, x[[IN64]]
8 ; CHECK: cnt.8b v0, v0
9 ; CHECK: uaddlv.8b h0, v0
10 ; CHECK: fmov w0, s0
11 ; CHECK: ret
12 ; CHECK-NONEON-LABEL: cnt32_advsimd
13 ; CHECK-NONEON-NOT: 8b
14 ; CHECK-NONEON: and w{{[0-9]+}}, w{{[0-9]+}}, #0x55555555
15 ; CHECK-NONEON: and w{{[0-9]+}}, w{{[0-9]+}}, #0x33333333
16 ; CHECK-NONEON: and w{{[0-9]+}}, w{{[0-9]+}}, #0xf0f0f0f
17 ; CHECK-NONEON: mul
1831 }
1932
2033 define i32 @cnt32_advsimd_2(<2 x i32> %x) {
34 ; CHECK-LABEL: cnt32_advsimd_2:
35 ; CHECK: // %bb.0:
36 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
37 ; CHECK-NEXT: fmov w0, s0
38 ; CHECK-NEXT: fmov d0, x0
39 ; CHECK-NEXT: cnt.8b v0, v0
40 ; CHECK-NEXT: uaddlv.8b h0, v0
41 ; CHECK-NEXT: fmov w0, s0
42 ; CHECK-NEXT: ret
43 ;
44 ; CHECK-NONEON-LABEL: cnt32_advsimd_2:
45 ; CHECK-NONEON: // %bb.0:
46 ; CHECK-NONEON-NEXT: lsr w8, w0, #1
47 ; CHECK-NONEON-NEXT: and w8, w8, #0x55555555
48 ; CHECK-NONEON-NEXT: sub w8, w0, w8
49 ; CHECK-NONEON-NEXT: and w9, w8, #0x33333333
50 ; CHECK-NONEON-NEXT: lsr w8, w8, #2
51 ; CHECK-NONEON-NEXT: and w8, w8, #0x33333333
52 ; CHECK-NONEON-NEXT: add w8, w9, w8
53 ; CHECK-NONEON-NEXT: add w8, w8, w8, lsr #4
54 ; CHECK-NONEON-NEXT: and w8, w8, #0xf0f0f0f
55 ; CHECK-NONEON-NEXT: mov w9, #16843009
56 ; CHECK-NONEON-NEXT: mul w8, w8, w9
57 ; CHECK-NONEON-NEXT: lsr w0, w8, #24
58 ; CHECK-NONEON-NEXT: ret
2159 %1 = extractelement <2 x i32> %x, i64 0
2260 %2 = tail call i32 @llvm.ctpop.i32(i32 %1)
2361 ret i32 %2
24 ; CHECK: fmov w0, s0
25 ; CHECK: fmov d0, x0
26 ; CHECK: cnt.8b v0, v0
27 ; CHECK: uaddlv.8b h0, v0
28 ; CHECK: fmov w0, s0
29 ; CHECK: ret
30 ; CHECK-NONEON-LABEL: cnt32_advsimd_2
31 ; CHECK-NONEON-NOT: 8b
32 ; CHECK-NONEON: and w{{[0-9]+}}, w{{[0-9]+}}, #0x55555555
33 ; CHECK-NONEON: and w{{[0-9]+}}, w{{[0-9]+}}, #0x33333333
34 ; CHECK-NONEON: and w{{[0-9]+}}, w{{[0-9]+}}, #0xf0f0f0f
35 ; CHECK-NONEON: mul
3662 }
3763
3864 define i64 @cnt64_advsimd(i64 %x) nounwind readnone {
65 ; CHECK-LABEL: cnt64_advsimd:
66 ; CHECK: // %bb.0:
67 ; CHECK-NEXT: fmov d0, x0
68 ; CHECK-NEXT: cnt.8b v0, v0
69 ; CHECK-NEXT: uaddlv.8b h0, v0
70 ; CHECK-NEXT: fmov w0, s0
71 ; CHECK-NEXT: ret
72 ;
73 ; CHECK-NONEON-LABEL: cnt64_advsimd:
74 ; CHECK-NONEON: // %bb.0:
75 ; CHECK-NONEON-NEXT: lsr x8, x0, #1
76 ; CHECK-NONEON-NEXT: and x8, x8, #0x5555555555555555
77 ; CHECK-NONEON-NEXT: sub x8, x0, x8
78 ; CHECK-NONEON-NEXT: and x9, x8, #0x3333333333333333
79 ; CHECK-NONEON-NEXT: lsr x8, x8, #2
80 ; CHECK-NONEON-NEXT: and x8, x8, #0x3333333333333333
81 ; CHECK-NONEON-NEXT: add x8, x9, x8
82 ; CHECK-NONEON-NEXT: add x8, x8, x8, lsr #4
83 ; CHECK-NONEON-NEXT: and x8, x8, #0xf0f0f0f0f0f0f0f
84 ; CHECK-NONEON-NEXT: mov x9, #72340172838076673
85 ; CHECK-NONEON-NEXT: mul x8, x8, x9
86 ; CHECK-NONEON-NEXT: lsr x0, x8, #56
87 ; CHECK-NONEON-NEXT: ret
3988 %cnt = tail call i64 @llvm.ctpop.i64(i64 %x)
4089 ret i64 %cnt
41 ; CHECK: fmov d0, x0
42 ; CHECK: cnt.8b v0, v0
43 ; CHECK: uaddlv.8b h0, v0
44 ; CHECK: fmov w0, s0
45 ; CHECK: ret
46 ; CHECK-NONEON-LABEL: cnt64_advsimd
47 ; CHECK-NONEON-NOT: 8b
48 ; CHECK-NONEON: and x{{[0-9]+}}, x{{[0-9]+}}, #0x5555555555555555
49 ; CHECK-NONEON: and x{{[0-9]+}}, x{{[0-9]+}}, #0x3333333333333333
50 ; CHECK-NONEON: and x{{[0-9]+}}, x{{[0-9]+}}, #0xf0f0f0f0f0f0f0f
51 ; CHECK-NONEON: mul
5290 }
5391
5492 ; Do not use AdvSIMD when -mno-implicit-float is specified.
5593 ; rdar://9473858
5694
5795 define i32 @cnt32(i32 %x) nounwind readnone noimplicitfloat {
96 ; CHECK-LABEL: cnt32:
97 ; CHECK: // %bb.0:
98 ; CHECK-NEXT: lsr w8, w0, #1
99 ; CHECK-NEXT: and w8, w8, #0x55555555
100 ; CHECK-NEXT: sub w8, w0, w8
101 ; CHECK-NEXT: and w9, w8, #0x33333333
102 ; CHECK-NEXT: lsr w8, w8, #2
103 ; CHECK-NEXT: and w8, w8, #0x33333333
104 ; CHECK-NEXT: add w8, w9, w8
105 ; CHECK-NEXT: add w8, w8, w8, lsr #4
106 ; CHECK-NEXT: and w8, w8, #0xf0f0f0f
107 ; CHECK-NEXT: mov w9, #16843009
108 ; CHECK-NEXT: mul w8, w8, w9
109 ; CHECK-NEXT: lsr w0, w8, #24
110 ; CHECK-NEXT: ret
111 ;
112 ; CHECK-NONEON-LABEL: cnt32:
113 ; CHECK-NONEON: // %bb.0:
114 ; CHECK-NONEON-NEXT: lsr w8, w0, #1
115 ; CHECK-NONEON-NEXT: and w8, w8, #0x55555555
116 ; CHECK-NONEON-NEXT: sub w8, w0, w8
117 ; CHECK-NONEON-NEXT: and w9, w8, #0x33333333
118 ; CHECK-NONEON-NEXT: lsr w8, w8, #2
119 ; CHECK-NONEON-NEXT: and w8, w8, #0x33333333
120 ; CHECK-NONEON-NEXT: add w8, w9, w8
121 ; CHECK-NONEON-NEXT: add w8, w8, w8, lsr #4
122 ; CHECK-NONEON-NEXT: and w8, w8, #0xf0f0f0f
123 ; CHECK-NONEON-NEXT: mov w9, #16843009
124 ; CHECK-NONEON-NEXT: mul w8, w8, w9
125 ; CHECK-NONEON-NEXT: lsr w0, w8, #24
126 ; CHECK-NONEON-NEXT: ret
58127 %cnt = tail call i32 @llvm.ctpop.i32(i32 %x)
59128 ret i32 %cnt
60 ; CHECK-LABEL: cnt32:
61 ; CHECK-NOT: 16b
62 ; CHECK: ret
63129 }
64130
65131 define i64 @cnt64(i64 %x) nounwind readnone noimplicitfloat {
132 ; CHECK-LABEL: cnt64:
133 ; CHECK: // %bb.0:
134 ; CHECK-NEXT: lsr x8, x0, #1
135 ; CHECK-NEXT: and x8, x8, #0x5555555555555555
136 ; CHECK-NEXT: sub x8, x0, x8
137 ; CHECK-NEXT: and x9, x8, #0x3333333333333333
138 ; CHECK-NEXT: lsr x8, x8, #2
139 ; CHECK-NEXT: and x8, x8, #0x3333333333333333
140 ; CHECK-NEXT: add x8, x9, x8
141 ; CHECK-NEXT: add x8, x8, x8, lsr #4
142 ; CHECK-NEXT: and x8, x8, #0xf0f0f0f0f0f0f0f
143 ; CHECK-NEXT: mov x9, #72340172838076673
144 ; CHECK-NEXT: mul x8, x8, x9
145 ; CHECK-NEXT: lsr x0, x8, #56
146 ; CHECK-NEXT: ret
147 ;
148 ; CHECK-NONEON-LABEL: cnt64:
149 ; CHECK-NONEON: // %bb.0:
150 ; CHECK-NONEON-NEXT: lsr x8, x0, #1
151 ; CHECK-NONEON-NEXT: and x8, x8, #0x5555555555555555
152 ; CHECK-NONEON-NEXT: sub x8, x0, x8
153 ; CHECK-NONEON-NEXT: and x9, x8, #0x3333333333333333
154 ; CHECK-NONEON-NEXT: lsr x8, x8, #2
155 ; CHECK-NONEON-NEXT: and x8, x8, #0x3333333333333333
156 ; CHECK-NONEON-NEXT: add x8, x9, x8
157 ; CHECK-NONEON-NEXT: add x8, x8, x8, lsr #4
158 ; CHECK-NONEON-NEXT: and x8, x8, #0xf0f0f0f0f0f0f0f
159 ; CHECK-NONEON-NEXT: mov x9, #72340172838076673
160 ; CHECK-NONEON-NEXT: mul x8, x8, x9
161 ; CHECK-NONEON-NEXT: lsr x0, x8, #56
162 ; CHECK-NONEON-NEXT: ret
66163 %cnt = tail call i64 @llvm.ctpop.i64(i64 %x)
67164 ret i64 %cnt
68 ; CHECK-LABEL: cnt64:
69 ; CHECK-NOT: 16b
70 ; CHECK: ret
71 }
165 }
166
167 define i32 @ctpop_eq_one(i64 %x) nounwind readnone {
168 ; CHECK-LABEL: ctpop_eq_one:
169 ; CHECK: // %bb.0:
170 ; CHECK-NEXT: fmov d0, x0
171 ; CHECK-NEXT: cnt.8b v0, v0
172 ; CHECK-NEXT: uaddlv.8b h0, v0
173 ; CHECK-NEXT: fmov w8, s0
174 ; CHECK-NEXT: cmp x8, #1 // =1
175 ; CHECK-NEXT: cset w0, eq
176 ; CHECK-NEXT: ret
177 ;
178 ; CHECK-NONEON-LABEL: ctpop_eq_one:
179 ; CHECK-NONEON: // %bb.0:
180 ; CHECK-NONEON-NEXT: lsr x8, x0, #1
181 ; CHECK-NONEON-NEXT: and x8, x8, #0x5555555555555555
182 ; CHECK-NONEON-NEXT: sub x8, x0, x8
183 ; CHECK-NONEON-NEXT: and x9, x8, #0x3333333333333333
184 ; CHECK-NONEON-NEXT: lsr x8, x8, #2
185 ; CHECK-NONEON-NEXT: and x8, x8, #0x3333333333333333
186 ; CHECK-NONEON-NEXT: add x8, x9, x8
187 ; CHECK-NONEON-NEXT: add x8, x8, x8, lsr #4
188 ; CHECK-NONEON-NEXT: and x8, x8, #0xf0f0f0f0f0f0f0f
189 ; CHECK-NONEON-NEXT: mov x9, #72340172838076673
190 ; CHECK-NONEON-NEXT: mul x8, x8, x9
191 ; CHECK-NONEON-NEXT: lsr x8, x8, #56
192 ; CHECK-NONEON-NEXT: cmp x8, #1 // =1
193 ; CHECK-NONEON-NEXT: cset w0, eq
194 ; CHECK-NONEON-NEXT: ret
195 %count = tail call i64 @llvm.ctpop.i64(i64 %x)
196 %cmp = icmp eq i64 %count, 1
197 %conv = zext i1 %cmp to i32
198 ret i32 %conv
199 }
200
72201
73202 declare i32 @llvm.ctpop.i32(i32) nounwind readnone
74203 declare i64 @llvm.ctpop.i64(i64) nounwind readnone
0 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
1 ; RUN: llc < %s -mtriple=x86_64-unknown -mcpu=corei7 | FileCheck %s
1 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+popcnt | FileCheck %s -check-prefixes=CHECK,POPCOUNT
2 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=-popcnt | FileCheck %s -check-prefixes=CHECK,NO-POPCOUNT
23
34 declare i8 @llvm.ctpop.i8(i8) nounwind readnone
45 declare i64 @llvm.ctpop.i64(i64) nounwind readnone
3435 }
3536
3637 define i32 @test3(i64 %x) nounwind readnone {
37 ; CHECK-LABEL: test3:
38 ; CHECK: # %bb.0:
39 ; CHECK-NEXT: popcntq %rdi, %rcx
40 ; CHECK-NEXT: andb $63, %cl
41 ; CHECK-NEXT: xorl %eax, %eax
42 ; CHECK-NEXT: cmpb $2, %cl
43 ; CHECK-NEXT: setb %al
44 ; CHECK-NEXT: retq
38 ; POPCOUNT-LABEL: test3:
39 ; POPCOUNT: # %bb.0:
40 ; POPCOUNT-NEXT: popcntq %rdi, %rcx
41 ; POPCOUNT-NEXT: andb $63, %cl
42 ; POPCOUNT-NEXT: xorl %eax, %eax
43 ; POPCOUNT-NEXT: cmpb $2, %cl
44 ; POPCOUNT-NEXT: setb %al
45 ; POPCOUNT-NEXT: retq
46 ;
47 ; NO-POPCOUNT-LABEL: test3:
48 ; NO-POPCOUNT: # %bb.0:
49 ; NO-POPCOUNT-NEXT: movq %rdi, %rax
50 ; NO-POPCOUNT-NEXT: shrq %rax
51 ; NO-POPCOUNT-NEXT: movabsq $6148914691236517205, %rcx # imm = 0x5555555555555555
52 ; NO-POPCOUNT-NEXT: andq %rax, %rcx
53 ; NO-POPCOUNT-NEXT: subq %rcx, %rdi
54 ; NO-POPCOUNT-NEXT: movabsq $3689348814741910323, %rax # imm = 0x3333333333333333
55 ; NO-POPCOUNT-NEXT: movq %rdi, %rcx
56 ; NO-POPCOUNT-NEXT: andq %rax, %rcx
57 ; NO-POPCOUNT-NEXT: shrq $2, %rdi
58 ; NO-POPCOUNT-NEXT: andq %rax, %rdi
59 ; NO-POPCOUNT-NEXT: addq %rcx, %rdi
60 ; NO-POPCOUNT-NEXT: movq %rdi, %rax
61 ; NO-POPCOUNT-NEXT: shrq $4, %rax
62 ; NO-POPCOUNT-NEXT: addq %rdi, %rax
63 ; NO-POPCOUNT-NEXT: movabsq $1085102592571150095, %rcx # imm = 0xF0F0F0F0F0F0F0F
64 ; NO-POPCOUNT-NEXT: andq %rax, %rcx
65 ; NO-POPCOUNT-NEXT: movabsq $72340172838076673, %rdx # imm = 0x101010101010101
66 ; NO-POPCOUNT-NEXT: imulq %rcx, %rdx
67 ; NO-POPCOUNT-NEXT: shrq $56, %rdx
68 ; NO-POPCOUNT-NEXT: andb $63, %dl
69 ; NO-POPCOUNT-NEXT: xorl %eax, %eax
70 ; NO-POPCOUNT-NEXT: cmpb $2, %dl
71 ; NO-POPCOUNT-NEXT: setb %al
72 ; NO-POPCOUNT-NEXT: retq
4573 %count = tail call i64 @llvm.ctpop.i64(i64 %x)
4674 %cast = trunc i64 %count to i6 ; Too small for 0-64
4775 %cmp = icmp ult i6 %cast, 2
5078 }
5179
5280 define i8 @test4(i8 %x) nounwind readnone {
53 ; CHECK-LABEL: test4:
54 ; CHECK: # %bb.0:
55 ; CHECK-NEXT: andl $127, %edi
56 ; CHECK-NEXT: popcntl %edi, %eax
57 ; CHECK-NEXT: # kill: def $al killed $al killed $eax
58 ; CHECK-NEXT: retq
81 ; POPCOUNT-LABEL: test4:
82 ; POPCOUNT: # %bb.0:
83 ; POPCOUNT-NEXT: andl $127, %edi
84 ; POPCOUNT-NEXT: popcntl %edi, %eax
85 ; POPCOUNT-NEXT: # kill: def $al killed $al killed $eax
86 ; POPCOUNT-NEXT: retq
87 ;
88 ; NO-POPCOUNT-LABEL: test4:
89 ; NO-POPCOUNT: # %bb.0:
90 ; NO-POPCOUNT-NEXT: # kill: def $edi killed $edi def $rdi
91 ; NO-POPCOUNT-NEXT: andb $127, %dil
92 ; NO-POPCOUNT-NEXT: movl %edi, %eax
93 ; NO-POPCOUNT-NEXT: shrb %al
94 ; NO-POPCOUNT-NEXT: andb $21, %al
95 ; NO-POPCOUNT-NEXT: subb %al, %dil
96 ; NO-POPCOUNT-NEXT: movl %edi, %eax
97 ; NO-POPCOUNT-NEXT: andb $51, %al
98 ; NO-POPCOUNT-NEXT: shrb $2, %dil
99 ; NO-POPCOUNT-NEXT: andb $51, %dil
100 ; NO-POPCOUNT-NEXT: addb %al, %dil
101 ; NO-POPCOUNT-NEXT: movl %edi, %eax
102 ; NO-POPCOUNT-NEXT: shrb $4, %al
103 ; NO-POPCOUNT-NEXT: addl %edi, %eax
104 ; NO-POPCOUNT-NEXT: andb $15, %al
105 ; NO-POPCOUNT-NEXT: # kill: def $al killed $al killed $eax
106 ; NO-POPCOUNT-NEXT: retq
59107 %x2 = and i8 %x, 127
60108 %count = tail call i8 @llvm.ctpop.i8(i8 %x2)
61109 %and = and i8 %count, 7
62110 ret i8 %and
63111 }
112
113 define i32 @ctpop_eq_one(i64 %x) nounwind readnone {
114 ; POPCOUNT-LABEL: ctpop_eq_one:
115 ; POPCOUNT: # %bb.0:
116 ; POPCOUNT-NEXT: popcntq %rdi, %rcx
117 ; POPCOUNT-NEXT: xorl %eax, %eax
118 ; POPCOUNT-NEXT: cmpq $1, %rcx
119 ; POPCOUNT-NEXT: sete %al
120 ; POPCOUNT-NEXT: retq
121 ;
122 ; NO-POPCOUNT-LABEL: ctpop_eq_one:
123 ; NO-POPCOUNT: # %bb.0:
124 ; NO-POPCOUNT-NEXT: movq %rdi, %rax
125 ; NO-POPCOUNT-NEXT: shrq %rax
126 ; NO-POPCOUNT-NEXT: movabsq $6148914691236517205, %rcx # imm = 0x5555555555555555
127 ; NO-POPCOUNT-NEXT: andq %rax, %rcx
128 ; NO-POPCOUNT-NEXT: subq %rcx, %rdi
129 ; NO-POPCOUNT-NEXT: movabsq $3689348814741910323, %rax # imm = 0x3333333333333333
130 ; NO-POPCOUNT-NEXT: movq %rdi, %rcx
131 ; NO-POPCOUNT-NEXT: andq %rax, %rcx
132 ; NO-POPCOUNT-NEXT: shrq $2, %rdi
133 ; NO-POPCOUNT-NEXT: andq %rax, %rdi
134 ; NO-POPCOUNT-NEXT: addq %rcx, %rdi
135 ; NO-POPCOUNT-NEXT: movq %rdi, %rax
136 ; NO-POPCOUNT-NEXT: shrq $4, %rax
137 ; NO-POPCOUNT-NEXT: addq %rdi, %rax
138 ; NO-POPCOUNT-NEXT: movabsq $1085102592571150095, %rcx # imm = 0xF0F0F0F0F0F0F0F
139 ; NO-POPCOUNT-NEXT: andq %rax, %rcx
140 ; NO-POPCOUNT-NEXT: movabsq $72340172838076673, %rdx # imm = 0x101010101010101
141 ; NO-POPCOUNT-NEXT: imulq %rcx, %rdx
142 ; NO-POPCOUNT-NEXT: shrq $56, %rdx
143 ; NO-POPCOUNT-NEXT: xorl %eax, %eax
144 ; NO-POPCOUNT-NEXT: cmpq $1, %rdx
145 ; NO-POPCOUNT-NEXT: sete %al
146 ; NO-POPCOUNT-NEXT: retq
147 %count = tail call i64 @llvm.ctpop.i64(i64 %x)
148 %cmp = icmp eq i64 %count, 1
149 %conv = zext i1 %cmp to i32
150 ret i32 %conv
151 }