1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s -check-prefix=CHECK -check-prefix=AVX
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s -check-prefix=CHECK -check-prefix=AVX2
6 ; testz(~X,Y) -> testc(X,Y)
9 define i32 @testpdz_128_invert0(<2 x double> %c, <2 x double> %d, i32 %a, i32 %b) {
10 ; CHECK-LABEL: testpdz_128_invert0:
12 ; CHECK-NEXT: movl %edi, %eax
13 ; CHECK-NEXT: vtestpd %xmm1, %xmm0
14 ; CHECK-NEXT: cmovael %esi, %eax
16 %t0 = bitcast <2 x double> %c to <2 x i64>
17 %t1 = xor <2 x i64> %t0, <i64 -1, i64 -1>
18 %t2 = bitcast <2 x i64> %t1 to <2 x double>
19 %t3 = call i32 @llvm.x86.avx.vtestz.pd(<2 x double> %t2, <2 x double> %d)
20 %t4 = icmp ne i32 %t3, 0
21 %t5 = select i1 %t4, i32 %a, i32 %b
25 define i32 @testpdz_256_invert0(<4 x double> %c, <4 x double> %d, i32 %a, i32 %b) {
26 ; CHECK-LABEL: testpdz_256_invert0:
28 ; CHECK-NEXT: movl %edi, %eax
29 ; CHECK-NEXT: vtestpd %ymm1, %ymm0
30 ; CHECK-NEXT: cmovael %esi, %eax
31 ; CHECK-NEXT: vzeroupper
33 %t0 = bitcast <4 x double> %c to <4 x i64>
34 %t1 = xor <4 x i64> %t0, <i64 -1, i64 -1, i64 -1, i64 -1>
35 %t2 = bitcast <4 x i64> %t1 to <4 x double>
36 %t3 = call i32 @llvm.x86.avx.vtestz.pd.256(<4 x double> %t2, <4 x double> %d)
37 %t4 = icmp ne i32 %t3, 0
38 %t5 = select i1 %t4, i32 %a, i32 %b
43 ; testz(X,~Y) -> testc(Y,X)
46 define i32 @testpdz_128_invert1(<2 x double> %c, <2 x double> %d, i32 %a, i32 %b) {
47 ; CHECK-LABEL: testpdz_128_invert1:
49 ; CHECK-NEXT: movl %edi, %eax
50 ; CHECK-NEXT: vtestpd %xmm0, %xmm1
51 ; CHECK-NEXT: cmovael %esi, %eax
53 %t0 = bitcast <2 x double> %d to <2 x i64>
54 %t1 = xor <2 x i64> %t0, <i64 -1, i64 -1>
55 %t2 = bitcast <2 x i64> %t1 to <2 x double>
56 %t3 = call i32 @llvm.x86.avx.vtestz.pd(<2 x double> %c, <2 x double> %t2)
57 %t4 = icmp ne i32 %t3, 0
58 %t5 = select i1 %t4, i32 %a, i32 %b
62 define i32 @testpdz_256_invert1(<4 x double> %c, <4 x double> %d, i32 %a, i32 %b) {
63 ; CHECK-LABEL: testpdz_256_invert1:
65 ; CHECK-NEXT: movl %edi, %eax
66 ; CHECK-NEXT: vtestpd %ymm0, %ymm1
67 ; CHECK-NEXT: cmovael %esi, %eax
68 ; CHECK-NEXT: vzeroupper
70 %t0 = bitcast <4 x double> %d to <4 x i64>
71 %t1 = xor <4 x i64> %t0, <i64 -1, i64 -1, i64 -1, i64 -1>
72 %t2 = bitcast <4 x i64> %t1 to <4 x double>
73 %t3 = call i32 @llvm.x86.avx.vtestz.pd.256(<4 x double> %c, <4 x double> %t2)
74 %t4 = icmp ne i32 %t3, 0
75 %t5 = select i1 %t4, i32 %a, i32 %b
80 ; testc(~X,Y) -> testz(X,Y)
83 define i32 @testpdc_128_invert0(<2 x double> %c, <2 x double> %d, i32 %a, i32 %b) {
84 ; CHECK-LABEL: testpdc_128_invert0:
86 ; CHECK-NEXT: movl %edi, %eax
87 ; CHECK-NEXT: vtestpd %xmm1, %xmm0
88 ; CHECK-NEXT: cmovnel %esi, %eax
90 %t0 = bitcast <2 x double> %c to <2 x i64>
91 %t1 = xor <2 x i64> %t0, <i64 -1, i64 -1>
92 %t2 = bitcast <2 x i64> %t1 to <2 x double>
93 %t3 = call i32 @llvm.x86.avx.vtestc.pd(<2 x double> %t2, <2 x double> %d)
94 %t4 = icmp ne i32 %t3, 0
95 %t5 = select i1 %t4, i32 %a, i32 %b
99 define i32 @testpdc_256_invert0(<4 x double> %c, <4 x double> %d, i32 %a, i32 %b) {
100 ; CHECK-LABEL: testpdc_256_invert0:
102 ; CHECK-NEXT: movl %edi, %eax
103 ; CHECK-NEXT: vtestpd %ymm1, %ymm0
104 ; CHECK-NEXT: cmovnel %esi, %eax
105 ; CHECK-NEXT: vzeroupper
107 %t0 = bitcast <4 x double> %c to <4 x i64>
108 %t1 = xor <4 x i64> %t0, <i64 -1, i64 -1, i64 -1, i64 -1>
109 %t2 = bitcast <4 x i64> %t1 to <4 x double>
110 %t3 = call i32 @llvm.x86.avx.vtestc.pd.256(<4 x double> %t2, <4 x double> %d)
111 %t4 = icmp ne i32 %t3, 0
112 %t5 = select i1 %t4, i32 %a, i32 %b
117 ; testnzc(~X,Y) -> testnzc(X,Y)
120 define i32 @testpdnzc_128_invert0(<2 x double> %c, <2 x double> %d, i32 %a, i32 %b) {
121 ; CHECK-LABEL: testpdnzc_128_invert0:
123 ; CHECK-NEXT: movl %edi, %eax
124 ; CHECK-NEXT: vtestpd %xmm1, %xmm0
125 ; CHECK-NEXT: cmovbel %esi, %eax
127 %t0 = bitcast <2 x double> %c to <2 x i64>
128 %t1 = xor <2 x i64> %t0, <i64 -1, i64 -1>
129 %t2 = bitcast <2 x i64> %t1 to <2 x double>
130 %t3 = call i32 @llvm.x86.avx.vtestnzc.pd(<2 x double> %t2, <2 x double> %d)
131 %t4 = icmp ne i32 %t3, 0
132 %t5 = select i1 %t4, i32 %a, i32 %b
136 define i32 @testpdnzc_256_invert0(<4 x double> %c, <4 x double> %d, i32 %a, i32 %b) {
137 ; CHECK-LABEL: testpdnzc_256_invert0:
139 ; CHECK-NEXT: movl %edi, %eax
140 ; CHECK-NEXT: vtestpd %ymm1, %ymm0
141 ; CHECK-NEXT: cmovbel %esi, %eax
142 ; CHECK-NEXT: vzeroupper
144 %t0 = bitcast <4 x double> %c to <4 x i64>
145 %t1 = xor <4 x i64> %t0, <i64 -1, i64 -1, i64 -1, i64 -1>
146 %t2 = bitcast <4 x i64> %t1 to <4 x double>
147 %t3 = call i32 @llvm.x86.avx.vtestnzc.pd.256(<4 x double> %t2, <4 x double> %d)
148 %t4 = icmp ne i32 %t3, 0
149 %t5 = select i1 %t4, i32 %a, i32 %b
154 ; SimplifyDemandedBits - only the sign bit is required
157 define i32 @testpdc_128_signbit(<2 x double> %c, <2 x double> %d, i32 %a, i32 %b) {
158 ; CHECK-LABEL: testpdc_128_signbit:
160 ; CHECK-NEXT: movl %edi, %eax
161 ; CHECK-NEXT: vtestpd %xmm1, %xmm0
162 ; CHECK-NEXT: cmovael %esi, %eax
164 %t0 = bitcast <2 x double> %c to <2 x i64>
165 %t1 = ashr <2 x i64> %t0, <i64 63, i64 63>
166 %t2 = bitcast <2 x i64> %t1 to <2 x double>
167 %t3 = call i32 @llvm.x86.avx.vtestc.pd(<2 x double> %t2, <2 x double> %d)
168 %t4 = icmp ne i32 %t3, 0
169 %t5 = select i1 %t4, i32 %a, i32 %b
173 define i32 @testpdz_256_signbit(<4 x double> %c, <4 x double> %d, i32 %a, i32 %b) {
174 ; CHECK-LABEL: testpdz_256_signbit:
176 ; CHECK-NEXT: movl %edi, %eax
177 ; CHECK-NEXT: vtestpd %ymm1, %ymm0
178 ; CHECK-NEXT: cmovnel %esi, %eax
179 ; CHECK-NEXT: vzeroupper
181 %t0 = bitcast <4 x double> %c to <4 x i64>
182 %t1 = icmp sgt <4 x i64> zeroinitializer, %t0
183 %t2 = sext <4 x i1> %t1 to <4 x i64>
184 %t3 = bitcast <4 x i64> %t2 to <4 x double>
185 %t4 = call i32 @llvm.x86.avx.vtestz.pd.256(<4 x double> %t3, <4 x double> %d)
186 %t5 = icmp ne i32 %t4, 0
187 %t6 = select i1 %t5, i32 %a, i32 %b
191 define i32 @testpdnzc_256_signbit_multiuse(<4 x double> %c, i32 %a, i32 %b) {
192 ; CHECK-LABEL: testpdnzc_256_signbit_multiuse:
194 ; CHECK-NEXT: movl %edi, %eax
195 ; CHECK-NEXT: vtestpd %ymm0, %ymm0
196 ; CHECK-NEXT: cmovnel %esi, %eax
197 ; CHECK-NEXT: vzeroupper
199 %t0 = bitcast <4 x double> %c to <4 x i64>
200 %t1 = icmp sgt <4 x i64> zeroinitializer, %t0
201 %t2 = sext <4 x i1> %t1 to <4 x i64>
202 %t3 = bitcast <4 x i64> %t2 to <4 x double>
203 %t4 = call i32 @llvm.x86.avx.vtestz.pd.256(<4 x double> %t3, <4 x double> %t3)
204 %t5 = icmp ne i32 %t4, 0
205 %t6 = select i1 %t5, i32 %a, i32 %b
209 define i1 @PR62171(<4 x double> %a0, <4 x double> %a1) {
210 ; CHECK-LABEL: PR62171:
212 ; CHECK-NEXT: vcmpeqpd %ymm1, %ymm0, %ymm0
213 ; CHECK-NEXT: vtestpd %ymm0, %ymm0
214 ; CHECK-NEXT: sete %al
215 ; CHECK-NEXT: vzeroupper
217 %cmp = fcmp oeq <4 x double> %a0, %a1
218 %sext = sext <4 x i1> %cmp to <4 x i64>
219 %extract = shufflevector <4 x i64> %sext, <4 x i64> poison, <2 x i32> <i32 0, i32 1>
220 %extract1 = shufflevector <4 x i64> %sext, <4 x i64> poison, <2 x i32> <i32 2, i32 3>
221 %or = or <2 x i64> %extract, %extract1
222 %or1 = bitcast <2 x i64> %or to <16 x i8>
223 %msk = icmp slt <16 x i8> %or1, zeroinitializer
224 %msk1 = bitcast <16 x i1> %msk to i16
225 %not = icmp eq i16 %msk1, 0
229 define void @combine_testp_v4f64(<4 x i64> %x){
230 ; AVX-LABEL: combine_testp_v4f64:
231 ; AVX: # %bb.0: # %entry
232 ; AVX-NEXT: vxorps %xmm1, %xmm1, %xmm1
233 ; AVX-NEXT: vcmptrueps %ymm1, %ymm1, %ymm1
234 ; AVX-NEXT: vtestpd %ymm1, %ymm0
235 ; AVX-NEXT: vzeroupper
238 ; AVX2-LABEL: combine_testp_v4f64:
239 ; AVX2: # %bb.0: # %entry
240 ; AVX2-NEXT: vpcmpeqd %ymm1, %ymm1, %ymm1
241 ; AVX2-NEXT: vtestpd %ymm1, %ymm0
242 ; AVX2-NEXT: vzeroupper
245 %xor.i.i.i.i.i.i.i.i.i = xor <4 x i64> %x, <i64 -1, i64 -1, i64 -1, i64 -1>
246 %.cast.i.i.i.i.i.i = bitcast <4 x i64> %xor.i.i.i.i.i.i.i.i.i to <4 x double>
247 %0 = call i32 @llvm.x86.avx.vtestz.pd.256(<4 x double> %.cast.i.i.i.i.i.i, <4 x double> %.cast.i.i.i.i.i.i)
248 %cmp.i.not.i.i.i.i.i.i = icmp eq i32 %0, 0
249 br i1 %cmp.i.not.i.i.i.i.i.i, label %if.end3.i.i.i.i.i.i, label %end
251 if.end3.i.i.i.i.i.i: ; preds = %entry
254 end: ; preds = %entry
258 declare i32 @llvm.x86.avx.vtestz.pd(<2 x double>, <2 x double>) nounwind readnone
259 declare i32 @llvm.x86.avx.vtestc.pd(<2 x double>, <2 x double>) nounwind readnone
260 declare i32 @llvm.x86.avx.vtestnzc.pd(<2 x double>, <2 x double>) nounwind readnone
262 declare i32 @llvm.x86.avx.vtestz.pd.256(<4 x double>, <4 x double>) nounwind readnone
263 declare i32 @llvm.x86.avx.vtestc.pd.256(<4 x double>, <4 x double>) nounwind readnone
264 declare i32 @llvm.x86.avx.vtestnzc.pd.256(<4 x double>, <4 x double>) nounwind readnone