1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-- -mattr=+sse2 | FileCheck %s --check-prefixes=CHECK,X86
3 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse4.2 | FileCheck %s --check-prefixes=CHECK,X64
5 define i32 @freeze_sext(i8 %a0) nounwind {
6 ; X86-LABEL: freeze_sext:
8 ; X86-NEXT: movsbl {{[0-9]+}}(%esp), %eax
11 ; X64-LABEL: freeze_sext:
13 ; X64-NEXT: movsbl %dil, %eax
15 %x = sext i8 %a0 to i16
17 %z = sext i16 %y to i32
21 define <4 x i32> @freeze_sext_vec(<4 x i8> %a0) nounwind {
22 ; X86-LABEL: freeze_sext_vec:
24 ; X86-NEXT: punpcklbw {{.*#+}} xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
25 ; X86-NEXT: punpcklwd {{.*#+}} xmm0 = xmm0[0,0,1,1,2,2,3,3]
26 ; X86-NEXT: psrad $24, %xmm0
29 ; X64-LABEL: freeze_sext_vec:
31 ; X64-NEXT: pmovsxbd %xmm0, %xmm0
33 %x = sext <4 x i8> %a0 to <4 x i16>
34 %y = freeze <4 x i16> %x
35 %z = sext <4 x i16> %y to <4 x i32>
39 define i32 @freeze_zext(i8 %a0) nounwind {
40 ; X86-LABEL: freeze_zext:
42 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
45 ; X64-LABEL: freeze_zext:
47 ; X64-NEXT: movzbl %dil, %eax
49 %x = zext i8 %a0 to i16
51 %z = zext i16 %y to i32
55 define <2 x i64> @freeze_zext_vec(<2 x i16> %a0) nounwind {
56 ; X86-LABEL: freeze_zext_vec:
58 ; X86-NEXT: pxor %xmm1, %xmm1
59 ; X86-NEXT: punpcklwd {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
60 ; X86-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
63 ; X64-LABEL: freeze_zext_vec:
65 ; X64-NEXT: pmovzxwq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero
67 %x = zext <2 x i16> %a0 to <2 x i32>
68 %y = freeze <2 x i32> %x
69 %z = zext <2 x i32> %y to <2 x i64>
73 define i32 @freeze_bswap(i32 %a0) nounwind {
74 ; X86-LABEL: freeze_bswap:
76 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
79 ; X64-LABEL: freeze_bswap:
81 ; X64-NEXT: movl %edi, %eax
83 %x = call i32 @llvm.bswap.i32(i32 %a0)
85 %z = call i32 @llvm.bswap.i32(i32 %y)
88 declare i32 @llvm.bswap.i32(i32)
90 define <4 x i32> @freeze_bswap_vec(<4 x i32> %a0) nounwind {
91 ; CHECK-LABEL: freeze_bswap_vec:
93 ; CHECK-NEXT: ret{{[l|q]}}
94 %x = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a0)
95 %y = freeze <4 x i32> %x
96 %z = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %y)
99 declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>)
101 define i32 @freeze_bitreverse(i32 %a0) nounwind {
102 ; X86-LABEL: freeze_bitreverse:
104 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
107 ; X64-LABEL: freeze_bitreverse:
109 ; X64-NEXT: movl %edi, %eax
111 %x = call i32 @llvm.bitreverse.i32(i32 %a0)
113 %z = call i32 @llvm.bitreverse.i32(i32 %y)
116 declare i32 @llvm.bitreverse.i32(i32)
118 define <4 x i32> @freeze_bitreverse_vec(<4 x i32> %a0) nounwind {
119 ; CHECK-LABEL: freeze_bitreverse_vec:
121 ; CHECK-NEXT: ret{{[l|q]}}
122 %x = call <4 x i32> @llvm.bitreverse.v4i32(<4 x i32> %a0)
123 %y = freeze <4 x i32> %x
124 %z = call <4 x i32> @llvm.bitreverse.v4i32(<4 x i32> %y)
127 declare <4 x i32> @llvm.bitreverse.v4i32(<4 x i32>)
129 ; split parity pattern
130 define i8 @freeze_ctpop(i8 %a0) nounwind {
131 ; X86-LABEL: freeze_ctpop:
133 ; X86-NEXT: cmpb $0, {{[0-9]+}}(%esp)
134 ; X86-NEXT: setnp %al
137 ; X64-LABEL: freeze_ctpop:
139 ; X64-NEXT: testb %dil, %dil
140 ; X64-NEXT: setnp %al
142 %x = call i8 @llvm.ctpop.i8(i8 %a0)
147 declare i8 @llvm.ctpop.i8(i8)
149 define <16 x i8> @freeze_ctpop_vec(<16 x i8> %a0) nounwind {
150 ; X86-LABEL: freeze_ctpop_vec:
152 ; X86-NEXT: movdqa %xmm0, %xmm1
153 ; X86-NEXT: psrlw $1, %xmm1
154 ; X86-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
155 ; X86-NEXT: psubb %xmm1, %xmm0
156 ; X86-NEXT: movdqa {{.*#+}} xmm1 = [51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51]
157 ; X86-NEXT: movdqa %xmm0, %xmm2
158 ; X86-NEXT: pand %xmm1, %xmm2
159 ; X86-NEXT: psrlw $2, %xmm0
160 ; X86-NEXT: pand %xmm1, %xmm0
161 ; X86-NEXT: paddb %xmm2, %xmm0
162 ; X86-NEXT: movdqa %xmm0, %xmm1
163 ; X86-NEXT: psrlw $4, %xmm1
164 ; X86-NEXT: paddb %xmm1, %xmm0
165 ; X86-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
168 ; X64-LABEL: freeze_ctpop_vec:
170 ; X64-NEXT: movdqa {{.*#+}} xmm2 = [15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15]
171 ; X64-NEXT: movdqa %xmm0, %xmm3
172 ; X64-NEXT: pand %xmm2, %xmm3
173 ; X64-NEXT: movdqa {{.*#+}} xmm1 = [0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4]
174 ; X64-NEXT: movdqa %xmm1, %xmm4
175 ; X64-NEXT: pshufb %xmm3, %xmm4
176 ; X64-NEXT: psrlw $4, %xmm0
177 ; X64-NEXT: pand %xmm2, %xmm0
178 ; X64-NEXT: pshufb %xmm0, %xmm1
179 ; X64-NEXT: paddb %xmm4, %xmm1
180 ; X64-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
181 ; X64-NEXT: movdqa %xmm1, %xmm0
183 %x = call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %a0)
184 %y = freeze <16 x i8> %x
185 %z = and <16 x i8> %y, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
188 declare <16 x i8> @llvm.ctpop.v16i8(<16 x i8>)
190 ; parity knownbits pattern
191 define i8 @freeze_parity(i8 %a0) nounwind {
192 ; X86-LABEL: freeze_parity:
194 ; X86-NEXT: cmpb $0, {{[0-9]+}}(%esp)
195 ; X86-NEXT: setnp %al
198 ; X64-LABEL: freeze_parity:
200 ; X64-NEXT: testb %dil, %dil
201 ; X64-NEXT: setnp %al
203 %x = call i8 @llvm.ctpop.i8(i8 %a0)
210 define <16 x i8> @freeze_parity_vec(<16 x i8> %a0) nounwind {
211 ; X86-LABEL: freeze_parity_vec:
213 ; X86-NEXT: movdqa %xmm0, %xmm1
214 ; X86-NEXT: psrlw $1, %xmm1
215 ; X86-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
216 ; X86-NEXT: psubb %xmm1, %xmm0
217 ; X86-NEXT: movdqa {{.*#+}} xmm1 = [51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51]
218 ; X86-NEXT: movdqa %xmm0, %xmm2
219 ; X86-NEXT: pand %xmm1, %xmm2
220 ; X86-NEXT: psrlw $2, %xmm0
221 ; X86-NEXT: pand %xmm1, %xmm0
222 ; X86-NEXT: paddb %xmm2, %xmm0
223 ; X86-NEXT: movdqa %xmm0, %xmm1
224 ; X86-NEXT: psrlw $4, %xmm1
225 ; X86-NEXT: paddb %xmm1, %xmm0
226 ; X86-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
229 ; X64-LABEL: freeze_parity_vec:
231 ; X64-NEXT: movdqa {{.*#+}} xmm2 = [15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15]
232 ; X64-NEXT: movdqa %xmm0, %xmm3
233 ; X64-NEXT: pand %xmm2, %xmm3
234 ; X64-NEXT: movdqa {{.*#+}} xmm1 = [0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4]
235 ; X64-NEXT: movdqa %xmm1, %xmm4
236 ; X64-NEXT: pshufb %xmm3, %xmm4
237 ; X64-NEXT: psrlw $4, %xmm0
238 ; X64-NEXT: pand %xmm2, %xmm0
239 ; X64-NEXT: pshufb %xmm0, %xmm1
240 ; X64-NEXT: paddb %xmm4, %xmm1
241 ; X64-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
242 ; X64-NEXT: movdqa %xmm1, %xmm0
244 %x = call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %a0)
245 %y = and <16 x i8> %x, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
246 %z = freeze <16 x i8> %y
247 %w = and <16 x i8> %z, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>