1 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-apple-darwin -mcpu=knl | FileCheck --check-prefix=KNL --check-prefix=CHECK %s
2 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-apple-darwin -mcpu=skx | FileCheck --check-prefix=SKX --check-prefix=CHECK %s
8 define <16 x float> @test1(<16 x float> %x, float* %br, float %y) nounwind {
9 %rrr = load float, float* %br
10 %rrr2 = insertelement <16 x float> %x, float %rrr, i32 1
11 %rrr3 = insertelement <16 x float> %rrr2, float %y, i32 14
12 ret <16 x float> %rrr3
15 define <8 x double> @test2(<8 x double> %x, double* %br, double %y) nounwind {
18 ; KNL-NEXT: vmovhpd (%rdi), %xmm0, %xmm2
19 ; KNL-NEXT: vinsertf32x4 $0, %xmm2, %zmm0, %zmm0
20 ; KNL-NEXT: vextractf32x4 $3, %zmm0, %xmm2
21 ; KNL-NEXT: vmovsd %xmm1, %xmm2, %xmm1
22 ; KNL-NEXT: vinsertf32x4 $3, %xmm1, %zmm0, %zmm0
27 ; SKX-NEXT: vmovhpd (%rdi), %xmm0, %xmm2
28 ; SKX-NEXT: vinsertf64x2 $0, %xmm2, %zmm0, %zmm0
29 ; SKX-NEXT: vextractf64x2 $3, %zmm0, %xmm2
30 ; SKX-NEXT: vmovsd %xmm1, %xmm2, %xmm1
31 ; SKX-NEXT: vinsertf64x2 $3, %xmm1, %zmm0, %zmm0
33 %rrr = load double, double* %br
34 %rrr2 = insertelement <8 x double> %x, double %rrr, i32 1
35 %rrr3 = insertelement <8 x double> %rrr2, double %y, i32 6
36 ret <8 x double> %rrr3
40 ;CHECK: vextractf32x4 $1
41 ;CHECK: vinsertf32x4 $0
43 define <16 x float> @test3(<16 x float> %x) nounwind {
44 %eee = extractelement <16 x float> %x, i32 4
45 %rrr2 = insertelement <16 x float> %x, float %eee, i32 1
46 ret <16 x float> %rrr2
49 define <8 x i64> @test4(<8 x i64> %x) nounwind {
52 ; KNL-NEXT: vextracti32x4 $2, %zmm0, %xmm1
53 ; KNL-NEXT: vmovq %xmm1, %rax
54 ; KNL-NEXT: vpinsrq $1, %rax, %xmm0, %xmm1
55 ; KNL-NEXT: vinserti32x4 $0, %xmm1, %zmm0, %zmm0
60 ; SKX-NEXT: vextracti64x2 $2, %zmm0, %xmm1
61 ; SKX-NEXT: vmovq %xmm1, %rax
62 ; SKX-NEXT: vpinsrq $1, %rax, %xmm0, %xmm1
63 ; SKX-NEXT: vinserti64x2 $0, %xmm1, %zmm0, %zmm0
65 %eee = extractelement <8 x i64> %x, i32 4
66 %rrr2 = insertelement <8 x i64> %x, i64 %eee, i32 1
73 define i32 @test5(<4 x float> %x) nounwind {
74 %ef = extractelement <4 x float> %x, i32 3
75 %ei = bitcast float %ef to i32
80 ;CHECK: vextractps {{.*}}, (%rdi)
82 define void @test6(<4 x float> %x, float* %out) nounwind {
83 %ef = extractelement <4 x float> %x, i32 3
84 store float %ef, float* %out, align 4
92 define float @test7(<16 x float> %x, i32 %ind) nounwind {
93 %e = extractelement <16 x float> %x, i32 %ind
101 define double @test8(<8 x double> %x, i32 %ind) nounwind {
102 %e = extractelement <8 x double> %x, i32 %ind
110 define float @test9(<8 x float> %x, i32 %ind) nounwind {
111 %e = extractelement <8 x float> %x, i32 %ind
118 ;CHECK: vmovd %xmm0, %eax
120 define i32 @test10(<16 x i32> %x, i32 %ind) nounwind {
121 %e = extractelement <16 x i32> %x, i32 %ind
133 define <16 x i32> @test11(<16 x i32>%a, <16 x i32>%b) {
134 %cmp_res = icmp ult <16 x i32> %a, %b
135 %ia = extractelement <16 x i1> %cmp_res, i32 4
136 br i1 %ia, label %A, label %B
140 %c = add <16 x i32>%b, %a
151 define i64 @test12(<16 x i64>%a, <16 x i64>%b, i64 %a1, i64 %b1) {
153 %cmpvector_func.i = icmp slt <16 x i64> %a, %b
154 %extract24vector_func.i = extractelement <16 x i1> %cmpvector_func.i, i32 0
155 %res = select i1 %extract24vector_func.i, i64 %a1, i64 %b1
160 ;CHECK: cmpl %esi, %edi
162 ;CHECK: andl $1, %eax
163 ;CHECK: kmovw %eax, %k0
166 define i16 @test13(i32 %a, i32 %b) {
167 %cmp_res = icmp ult i32 %a, %b
168 %maskv = insertelement <16 x i1> <i1 true, i1 false, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, i1 %cmp_res, i32 0
169 %res = bitcast <16 x i1> %maskv to i16
183 define i64 @test14(<8 x i64>%a, <8 x i64>%b, i64 %a1, i64 %b1) {
185 %cmpvector_func.i = icmp slt <8 x i64> %a, %b
186 %extract24vector_func.i = extractelement <8 x i1> %cmpvector_func.i, i32 4
187 %res = select i1 %extract24vector_func.i, i64 %a1, i64 %b1
192 ;CHECK: movb (%rdi), %al
194 ;CHECK: movw $-1, %ax
196 define i16 @test15(i1 *%addr) {
197 %x = load i1 , i1 * %addr, align 1
198 %x1 = insertelement <16 x i1> undef, i1 %x, i32 10
199 %x2 = bitcast <16 x i1>%x1 to i16
204 ;CHECK: movb (%rdi), %al
210 define i16 @test16(i1 *%addr, i16 %a) {
211 %x = load i1 , i1 * %addr, align 128
212 %a1 = bitcast i16 %a to <16 x i1>
213 %x1 = insertelement <16 x i1> %a1, i1 %x, i32 10
214 %x2 = bitcast <16 x i1>%x1 to i16
219 ;KNL: movb (%rdi), %al
226 define i8 @test17(i1 *%addr, i8 %a) {
227 %x = load i1 , i1 * %addr, align 128
228 %a1 = bitcast i8 %a to <8 x i1>
229 %x1 = insertelement <8 x i1> %a1, i1 %x, i32 4
230 %x2 = bitcast <8 x i1>%x1 to i8