blob: 51d987bfdbdaf11bd0ef41be1b1e1e539c066697 [file] [log] [blame]
Simon Pilgrim569106f2016-01-03 17:14:15 +00001; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=+sse4.1 | FileCheck %s --check-prefix=ALL --check-prefix=SSE --check-prefix=SSE41
3; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=+avx | FileCheck %s --check-prefix=ALL --check-prefix=AVX --check-prefix=AVX1
4; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=+avx2 | FileCheck %s --check-prefix=ALL --check-prefix=AVX --check-prefix=AVX2
5
6define <4 x float> @shuffle_v4f32_0z27(<4 x float> %x, <4 x float> %a) {
7; SSE-LABEL: shuffle_v4f32_0z27:
8; SSE: # BB#0:
Simon Pilgrime74653b2016-01-19 22:24:12 +00009; SSE-NEXT: insertps {{.*#+}} xmm0 = xmm0[0],zero,xmm0[2],xmm1[2]
Simon Pilgrim569106f2016-01-03 17:14:15 +000010; SSE-NEXT: retq
11;
12; AVX-LABEL: shuffle_v4f32_0z27:
13; AVX: # BB#0:
Simon Pilgrime74653b2016-01-19 22:24:12 +000014; AVX-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0],zero,xmm0[2],xmm1[2]
Simon Pilgrim569106f2016-01-03 17:14:15 +000015; AVX-NEXT: retq
16 %vecext = extractelement <4 x float> %x, i32 0
17 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
18 %vecinit1 = insertelement <4 x float> %vecinit, float 0.0, i32 1
19 %vecinit3 = shufflevector <4 x float> %vecinit1, <4 x float> %x, <4 x i32> <i32 0, i32 1, i32 6, i32 undef>
20 %vecinit5 = shufflevector <4 x float> %vecinit3, <4 x float> %a, <4 x i32> <i32 0, i32 1, i32 2, i32 6>
21 ret <4 x float> %vecinit5
22}
23
24define <4 x float> @shuffle_v4f32_0zz4(<4 x float> %xyzw, <4 x float> %abcd) {
25; SSE-LABEL: shuffle_v4f32_0zz4:
26; SSE: # BB#0:
Simon Pilgrim4b919b22016-01-19 23:04:56 +000027; SSE-NEXT: insertps {{.*#+}} xmm0 = xmm0[0],zero,zero,xmm1[0]
Simon Pilgrim569106f2016-01-03 17:14:15 +000028; SSE-NEXT: retq
29;
30; AVX-LABEL: shuffle_v4f32_0zz4:
31; AVX: # BB#0:
Simon Pilgrim4b919b22016-01-19 23:04:56 +000032; AVX-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0],zero,zero,xmm1[0]
Simon Pilgrim569106f2016-01-03 17:14:15 +000033; AVX-NEXT: retq
34 %vecext = extractelement <4 x float> %xyzw, i32 0
35 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
36 %vecinit1 = insertelement <4 x float> %vecinit, float 0.000000e+00, i32 1
37 %vecinit2 = insertelement <4 x float> %vecinit1, float 0.000000e+00, i32 2
38 %vecinit4 = shufflevector <4 x float> %vecinit2, <4 x float> %abcd, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
39 ret <4 x float> %vecinit4
40}
41
42define <4 x float> @shuffle_v4f32_0z24(<4 x float> %xyzw, <4 x float> %abcd) {
43; SSE-LABEL: shuffle_v4f32_0z24:
44; SSE: # BB#0:
Simon Pilgrime74653b2016-01-19 22:24:12 +000045; SSE-NEXT: insertps {{.*#+}} xmm0 = xmm0[0],zero,xmm0[2],xmm1[0]
Simon Pilgrim569106f2016-01-03 17:14:15 +000046; SSE-NEXT: retq
47;
48; AVX-LABEL: shuffle_v4f32_0z24:
49; AVX: # BB#0:
Simon Pilgrime74653b2016-01-19 22:24:12 +000050; AVX-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0],zero,xmm0[2],xmm1[0]
Simon Pilgrim569106f2016-01-03 17:14:15 +000051; AVX-NEXT: retq
52 %vecext = extractelement <4 x float> %xyzw, i32 0
53 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
54 %vecinit1 = insertelement <4 x float> %vecinit, float 0.000000e+00, i32 1
55 %vecinit3 = shufflevector <4 x float> %vecinit1, <4 x float> %xyzw, <4 x i32> <i32 0, i32 1, i32 6, i32 undef>
56 %vecinit5 = shufflevector <4 x float> %vecinit3, <4 x float> %abcd, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
57 ret <4 x float> %vecinit5
58}
59
60define <4 x float> @shuffle_v4f32_0zz0(float %a) {
61; SSE-LABEL: shuffle_v4f32_0zz0:
62; SSE: # BB#0:
63; SSE-NEXT: xorps %xmm1, %xmm1
64; SSE-NEXT: blendps {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
65; SSE-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,1,1,0]
66; SSE-NEXT: movaps %xmm1, %xmm0
67; SSE-NEXT: retq
68;
69; AVX-LABEL: shuffle_v4f32_0zz0:
70; AVX: # BB#0:
71; AVX-NEXT: vxorps %xmm1, %xmm1, %xmm1
72; AVX-NEXT: vmovss {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
73; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,1,1,0]
74; AVX-NEXT: retq
75 %vecinit = insertelement <4 x float> undef, float %a, i32 0
76 %vecinit1 = insertelement <4 x float> %vecinit, float 0.000000e+00, i32 1
77 %vecinit2 = insertelement <4 x float> %vecinit1, float 0.000000e+00, i32 2
78 %vecinit3 = insertelement <4 x float> %vecinit2, float %a, i32 3
79 ret <4 x float> %vecinit3
80}
81
82define <4 x float> @shuffle_v4f32_0z6z(<4 x float> %A, <4 x float> %B) {
83; SSE-LABEL: shuffle_v4f32_0z6z:
84; SSE: # BB#0:
85; SSE-NEXT: insertps {{.*#+}} xmm0 = xmm0[0],zero,xmm1[2],zero
86; SSE-NEXT: retq
87;
88; AVX-LABEL: shuffle_v4f32_0z6z:
89; AVX: # BB#0:
90; AVX-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0],zero,xmm1[2],zero
91; AVX-NEXT: retq
92 %vecext = extractelement <4 x float> %A, i32 0
93 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
94 %vecinit1 = insertelement <4 x float> %vecinit, float 0.000000e+00, i32 1
95 %vecext2 = extractelement <4 x float> %B, i32 2
96 %vecinit3 = insertelement <4 x float> %vecinit1, float %vecext2, i32 2
97 %vecinit4 = insertelement <4 x float> %vecinit3, float 0.000000e+00, i32 3
98 ret <4 x float> %vecinit4
99}
Simon Pilgrim83e44c62016-01-07 10:24:19 +0000100
Simon Pilgrimfd661692016-01-23 13:37:07 +0000101define <4 x float> @insertps_undef_input0(<4 x float> %a0, <4 x float> %a1) {
102; SSE-LABEL: insertps_undef_input0:
103; SSE: # BB#0:
104; SSE-NEXT: insertps {{.*#+}} xmm0 = zero,xmm1[0],zero,zero
105; SSE-NEXT: retq
106;
107; AVX-LABEL: insertps_undef_input0:
108; AVX: # BB#0:
109; AVX-NEXT: vinsertps {{.*#+}} xmm0 = zero,xmm1[0],zero,zero
110; AVX-NEXT: retq
111 %res0 = fadd <4 x float> %a0, <float 1.0, float 1.0, float 1.0, float 1.0>
112 %res1 = call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %res0, <4 x float> %a1, i8 21)
113 %res2 = shufflevector <4 x float> %res1, <4 x float> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
114 ret <4 x float> %res2
115}
116
117define <4 x float> @insertps_undef_input1(<4 x float> %a0, <4 x float> %a1) {
118; SSE-LABEL: insertps_undef_input1:
119; SSE: # BB#0:
120; SSE-NEXT: insertps {{.*#+}} xmm0 = zero,zero,zero,xmm0[3]
121; SSE-NEXT: retq
122;
123; AVX-LABEL: insertps_undef_input1:
124; AVX: # BB#0:
125; AVX-NEXT: vinsertps {{.*#+}} xmm0 = zero,zero,zero,xmm0[3]
126; AVX-NEXT: retq
127 %res0 = fadd <4 x float> %a1, <float 1.0, float 1.0, float 1.0, float 1.0>
128 %res1 = call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a0, <4 x float> %res0, i8 21)
129 %res2 = shufflevector <4 x float> %res1, <4 x float> zeroinitializer, <4 x i32> <i32 0, i32 5, i32 2, i32 3>
130 ret <4 x float> %res2
131}
132
Simon Pilgrim00adc1e2016-01-26 21:39:25 +0000133define <4 x float> @consecutive_load_insertps_04zz(float* %p) {
134; SSE-LABEL: consecutive_load_insertps_04zz:
135; SSE: # BB#0:
Simon Pilgrim7823fd22016-02-04 19:27:51 +0000136; SSE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
Simon Pilgrim00adc1e2016-01-26 21:39:25 +0000137; SSE-NEXT: retq
138;
139; AVX-LABEL: consecutive_load_insertps_04zz:
140; AVX: # BB#0:
Simon Pilgrim7823fd22016-02-04 19:27:51 +0000141; AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
Simon Pilgrim00adc1e2016-01-26 21:39:25 +0000142; AVX-NEXT: retq
143 %p0 = getelementptr inbounds float, float* %p, i64 1
144 %p1 = getelementptr inbounds float, float* %p, i64 2
145 %s0 = load float, float* %p0
146 %s1 = load float, float* %p1
147 %v0 = insertelement <4 x float> undef, float %s0, i32 0
148 %v1 = insertelement <4 x float> undef, float %s1, i32 0
149 %res = call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %v0, <4 x float> %v1, i8 28)
150 ret <4 x float> %res
151}
152
Simon Pilgrim83e44c62016-01-07 10:24:19 +0000153define float @extract_zero_insertps_z0z7(<4 x float> %a0, <4 x float> %a1) {
154; SSE-LABEL: extract_zero_insertps_z0z7:
155; SSE: # BB#0:
156; SSE-NEXT: xorps %xmm0, %xmm0
157; SSE-NEXT: retq
158;
159; AVX-LABEL: extract_zero_insertps_z0z7:
160; AVX: # BB#0:
161; AVX-NEXT: vxorps %xmm0, %xmm0, %xmm0
162; AVX-NEXT: retq
163 %res = call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a0, <4 x float> %a1, i8 21)
164 %ext = extractelement <4 x float> %res, i32 0
165 ret float %ext
166}
167
168define float @extract_lane_insertps_5123(<4 x float> %a0, <4 x float> *%p1) {
169; SSE-LABEL: extract_lane_insertps_5123:
170; SSE: # BB#0:
171; SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
172; SSE-NEXT: retq
173;
174; AVX-LABEL: extract_lane_insertps_5123:
175; AVX: # BB#0:
176; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
177; AVX-NEXT: retq
178 %a1 = load <4 x float>, <4 x float> *%p1
179 %res = call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a0, <4 x float> %a1, i8 128)
180 %ext = extractelement <4 x float> %res, i32 0
181 ret float %ext
182}
183
184declare <4 x float> @llvm.x86.sse41.insertps(<4 x float>, <4 x float>, i8) nounwind readnone