blob: 0c43e0e9d27bf2ec9215a2d418fb96c06eb9e502 [file] [log] [blame]
Chandler Carruthbfc6b952014-09-03 19:39:10 +00001; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --check-prefix=SSE2
Chandler Carruthc1e8ebc2014-09-03 20:39:06 +00002; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=+sse4.1 -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --check-prefix=SSE41
Chandler Carruthbfc6b952014-09-03 19:39:10 +00003; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=+avx -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --check-prefix=AVX1
Chandler Carruth83860cf2014-06-27 11:23:44 +00004
5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-unknown-unknown"
7
8define <4 x i32> @shuffle_v4i32_0001(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +00009; ALL-LABEL: @shuffle_v4i32_0001
10; ALL: pshufd {{.*}} # xmm0 = xmm0[0,0,0,1]
11; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +000012 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
13 ret <4 x i32> %shuffle
14}
15define <4 x i32> @shuffle_v4i32_0020(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +000016; ALL-LABEL: @shuffle_v4i32_0020
17; ALL: pshufd {{.*}} # xmm0 = xmm0[0,0,2,0]
18; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +000019 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 0>
20 ret <4 x i32> %shuffle
21}
Chandler Carruth27046752014-08-07 08:11:31 +000022define <4 x i32> @shuffle_v4i32_0112(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +000023; ALL-LABEL: @shuffle_v4i32_0112
24; ALL: pshufd {{.*}} # xmm0 = xmm0[0,1,1,2]
25; ALL-NEXT: retq
Chandler Carruth27046752014-08-07 08:11:31 +000026 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 1, i32 2>
27 ret <4 x i32> %shuffle
28}
Chandler Carruth83860cf2014-06-27 11:23:44 +000029define <4 x i32> @shuffle_v4i32_0300(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +000030; ALL-LABEL: @shuffle_v4i32_0300
31; ALL: pshufd {{.*}} # xmm0 = xmm0[0,3,0,0]
32; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +000033 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 3, i32 0, i32 0>
34 ret <4 x i32> %shuffle
35}
36define <4 x i32> @shuffle_v4i32_1000(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +000037; ALL-LABEL: @shuffle_v4i32_1000
38; ALL: pshufd {{.*}} # xmm0 = xmm0[1,0,0,0]
39; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +000040 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 1, i32 0, i32 0, i32 0>
41 ret <4 x i32> %shuffle
42}
43define <4 x i32> @shuffle_v4i32_2200(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +000044; ALL-LABEL: @shuffle_v4i32_2200
45; ALL: pshufd {{.*}} # xmm0 = xmm0[2,2,0,0]
46; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +000047 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 2, i32 0, i32 0>
48 ret <4 x i32> %shuffle
49}
50define <4 x i32> @shuffle_v4i32_3330(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +000051; ALL-LABEL: @shuffle_v4i32_3330
52; ALL: pshufd {{.*}} # xmm0 = xmm0[3,3,3,0]
53; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +000054 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 3, i32 3, i32 3, i32 0>
55 ret <4 x i32> %shuffle
56}
57define <4 x i32> @shuffle_v4i32_3210(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +000058; ALL-LABEL: @shuffle_v4i32_3210
59; ALL: pshufd {{.*}} # xmm0 = xmm0[3,2,1,0]
60; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +000061 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
62 ret <4 x i32> %shuffle
63}
64
Chandler Carruth17fd8482014-08-15 03:54:49 +000065define <4 x i32> @shuffle_v4i32_2121(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +000066; ALL-LABEL: @shuffle_v4i32_2121
67; ALL: pshufd {{.*}} # xmm0 = xmm0[2,1,2,1]
68; ALL-NEXT: retq
Chandler Carruth17fd8482014-08-15 03:54:49 +000069 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 1, i32 2, i32 1>
70 ret <4 x i32> %shuffle
71}
72
Chandler Carruth83860cf2014-06-27 11:23:44 +000073define <4 x float> @shuffle_v4f32_0001(<4 x float> %a, <4 x float> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +000074; ALL-LABEL: @shuffle_v4f32_0001
75; ALL: shufps {{.*}} # xmm0 = xmm0[0,0,0,1]
76; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +000077 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
78 ret <4 x float> %shuffle
79}
80define <4 x float> @shuffle_v4f32_0020(<4 x float> %a, <4 x float> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +000081; ALL-LABEL: @shuffle_v4f32_0020
82; ALL: shufps {{.*}} # xmm0 = xmm0[0,0,2,0]
83; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +000084 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 0>
85 ret <4 x float> %shuffle
86}
87define <4 x float> @shuffle_v4f32_0300(<4 x float> %a, <4 x float> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +000088; ALL-LABEL: @shuffle_v4f32_0300
89; ALL: shufps {{.*}} # xmm0 = xmm0[0,3,0,0]
90; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +000091 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 3, i32 0, i32 0>
92 ret <4 x float> %shuffle
93}
94define <4 x float> @shuffle_v4f32_1000(<4 x float> %a, <4 x float> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +000095; ALL-LABEL: @shuffle_v4f32_1000
96; ALL: shufps {{.*}} # xmm0 = xmm0[1,0,0,0]
97; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +000098 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 1, i32 0, i32 0, i32 0>
99 ret <4 x float> %shuffle
100}
101define <4 x float> @shuffle_v4f32_2200(<4 x float> %a, <4 x float> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +0000102; ALL-LABEL: @shuffle_v4f32_2200
103; ALL: shufps {{.*}} # xmm0 = xmm0[2,2,0,0]
104; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +0000105 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 2, i32 2, i32 0, i32 0>
106 ret <4 x float> %shuffle
107}
108define <4 x float> @shuffle_v4f32_3330(<4 x float> %a, <4 x float> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +0000109; ALL-LABEL: @shuffle_v4f32_3330
110; ALL: shufps {{.*}} # xmm0 = xmm0[3,3,3,0]
111; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +0000112 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 3, i32 3, i32 3, i32 0>
113 ret <4 x float> %shuffle
114}
115define <4 x float> @shuffle_v4f32_3210(<4 x float> %a, <4 x float> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +0000116; ALL-LABEL: @shuffle_v4f32_3210
117; ALL: shufps {{.*}} # xmm0 = xmm0[3,2,1,0]
118; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +0000119 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
120 ret <4 x float> %shuffle
121}
122
123define <4 x i32> @shuffle_v4i32_0124(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthdad54002014-09-03 22:48:34 +0000124; SSE2-LABEL: @shuffle_v4i32_0124
125; SSE2: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
126; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[2,0]
127; SSE2-NEXT: retq
128;
129; SSE41-LABEL: @shuffle_v4i32_0124
130; SSE41: insertps {{.*}} # xmm0 = xmm0[0,1,2],xmm1[0]
131; SSE41-NEXT: retq
132;
133; AVX1-LABEL: @shuffle_v4i32_0124
134; AVX1: vinsertps {{.*}} # xmm0 = xmm0[0,1,2],xmm1[0]
135; AVX1-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +0000136 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
137 ret <4 x i32> %shuffle
138}
139define <4 x i32> @shuffle_v4i32_0142(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +0000140; ALL-LABEL: @shuffle_v4i32_0142
141; ALL: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
142; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,2]
143; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +0000144 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 2>
145 ret <4 x i32> %shuffle
146}
147define <4 x i32> @shuffle_v4i32_0412(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +0000148; SSE2-LABEL: @shuffle_v4i32_0412
149; SSE2: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
150; SSE2-NEXT: shufps {{.*}} # xmm1 = xmm1[2,0],xmm0[1,2]
151; SSE2-NEXT: movaps %xmm1, %xmm0
152; SSE2-NEXT: retq
153;
154; AVX1-LABEL: @shuffle_v4i32_0412
155; AVX1: vshufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
156; AVX1-NEXT: vshufps {{.*}} # xmm0 = xmm1[2,0],xmm0[1,2]
157; AVX1-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +0000158 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 1, i32 2>
159 ret <4 x i32> %shuffle
160}
161define <4 x i32> @shuffle_v4i32_4012(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +0000162; SSE2-LABEL: @shuffle_v4i32_4012
163; SSE2: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
164; SSE2-NEXT: shufps {{.*}} # xmm1 = xmm1[0,2],xmm0[1,2]
165; SSE2-NEXT: movaps %xmm1, %xmm0
166; SSE2-NEXT: retq
167;
168; AVX1-LABEL: @shuffle_v4i32_4012
169; AVX1: vshufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
170; AVX1-NEXT: vshufps {{.*}} # xmm0 = xmm1[0,2],xmm0[1,2]
171; AVX1-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +0000172 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 0, i32 1, i32 2>
173 ret <4 x i32> %shuffle
174}
175define <4 x i32> @shuffle_v4i32_0145(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +0000176; ALL-LABEL: @shuffle_v4i32_0145
177; ALL: punpcklqdq {{.*}} # xmm0 = xmm0[0],xmm1[0]
178; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +0000179 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
180 ret <4 x i32> %shuffle
181}
182define <4 x i32> @shuffle_v4i32_0451(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +0000183; ALL-LABEL: @shuffle_v4i32_0451
184; ALL: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,1]
185; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[0,2,3,1]
186; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +0000187 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 5, i32 1>
188 ret <4 x i32> %shuffle
189}
190define <4 x i32> @shuffle_v4i32_4501(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +0000191; SSE2-LABEL: @shuffle_v4i32_4501
192; SSE2: punpcklqdq {{.*}} # xmm1 = xmm1[0],xmm0[0]
193; SSE2-NEXT: movdqa %xmm1, %xmm0
194; SSE2-NEXT: retq
195;
196; AVX1-LABEL: @shuffle_v4i32_4501
197; AVX1: punpcklqdq {{.*}} # xmm0 = xmm1[0],xmm0[0]
198; AVX1-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +0000199 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 5, i32 0, i32 1>
200 ret <4 x i32> %shuffle
201}
202define <4 x i32> @shuffle_v4i32_4015(<4 x i32> %a, <4 x i32> %b) {
Chandler Carruthbfc6b952014-09-03 19:39:10 +0000203; ALL-LABEL: @shuffle_v4i32_4015
204; ALL: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,1]
205; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0,1,3]
206; ALL-NEXT: retq
Chandler Carruth83860cf2014-06-27 11:23:44 +0000207 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 0, i32 1, i32 5>
208 ret <4 x i32> %shuffle
209}