1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --check-prefix=SSE2
2 ; 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
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-unknown"
7 define <4 x i32> @shuffle_v4i32_0001(<4 x i32> %a, <4 x i32> %b) {
8 ; ALL-LABEL: @shuffle_v4i32_0001
9 ; ALL: pshufd {{.*}} # xmm0 = xmm0[0,0,0,1]
11 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
12 ret <4 x i32> %shuffle
14 define <4 x i32> @shuffle_v4i32_0020(<4 x i32> %a, <4 x i32> %b) {
15 ; ALL-LABEL: @shuffle_v4i32_0020
16 ; ALL: pshufd {{.*}} # xmm0 = xmm0[0,0,2,0]
18 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 0>
19 ret <4 x i32> %shuffle
21 define <4 x i32> @shuffle_v4i32_0112(<4 x i32> %a, <4 x i32> %b) {
22 ; ALL-LABEL: @shuffle_v4i32_0112
23 ; ALL: pshufd {{.*}} # xmm0 = xmm0[0,1,1,2]
25 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 1, i32 2>
26 ret <4 x i32> %shuffle
28 define <4 x i32> @shuffle_v4i32_0300(<4 x i32> %a, <4 x i32> %b) {
29 ; ALL-LABEL: @shuffle_v4i32_0300
30 ; ALL: pshufd {{.*}} # xmm0 = xmm0[0,3,0,0]
32 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 3, i32 0, i32 0>
33 ret <4 x i32> %shuffle
35 define <4 x i32> @shuffle_v4i32_1000(<4 x i32> %a, <4 x i32> %b) {
36 ; ALL-LABEL: @shuffle_v4i32_1000
37 ; ALL: pshufd {{.*}} # xmm0 = xmm0[1,0,0,0]
39 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 1, i32 0, i32 0, i32 0>
40 ret <4 x i32> %shuffle
42 define <4 x i32> @shuffle_v4i32_2200(<4 x i32> %a, <4 x i32> %b) {
43 ; ALL-LABEL: @shuffle_v4i32_2200
44 ; ALL: pshufd {{.*}} # xmm0 = xmm0[2,2,0,0]
46 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 2, i32 0, i32 0>
47 ret <4 x i32> %shuffle
49 define <4 x i32> @shuffle_v4i32_3330(<4 x i32> %a, <4 x i32> %b) {
50 ; ALL-LABEL: @shuffle_v4i32_3330
51 ; ALL: pshufd {{.*}} # xmm0 = xmm0[3,3,3,0]
53 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 3, i32 3, i32 3, i32 0>
54 ret <4 x i32> %shuffle
56 define <4 x i32> @shuffle_v4i32_3210(<4 x i32> %a, <4 x i32> %b) {
57 ; ALL-LABEL: @shuffle_v4i32_3210
58 ; ALL: pshufd {{.*}} # xmm0 = xmm0[3,2,1,0]
60 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
61 ret <4 x i32> %shuffle
64 define <4 x i32> @shuffle_v4i32_2121(<4 x i32> %a, <4 x i32> %b) {
65 ; ALL-LABEL: @shuffle_v4i32_2121
66 ; ALL: pshufd {{.*}} # xmm0 = xmm0[2,1,2,1]
68 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 1, i32 2, i32 1>
69 ret <4 x i32> %shuffle
72 define <4 x float> @shuffle_v4f32_0001(<4 x float> %a, <4 x float> %b) {
73 ; ALL-LABEL: @shuffle_v4f32_0001
74 ; ALL: shufps {{.*}} # xmm0 = xmm0[0,0,0,1]
76 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
77 ret <4 x float> %shuffle
79 define <4 x float> @shuffle_v4f32_0020(<4 x float> %a, <4 x float> %b) {
80 ; ALL-LABEL: @shuffle_v4f32_0020
81 ; ALL: shufps {{.*}} # xmm0 = xmm0[0,0,2,0]
83 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 0>
84 ret <4 x float> %shuffle
86 define <4 x float> @shuffle_v4f32_0300(<4 x float> %a, <4 x float> %b) {
87 ; ALL-LABEL: @shuffle_v4f32_0300
88 ; ALL: shufps {{.*}} # xmm0 = xmm0[0,3,0,0]
90 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 3, i32 0, i32 0>
91 ret <4 x float> %shuffle
93 define <4 x float> @shuffle_v4f32_1000(<4 x float> %a, <4 x float> %b) {
94 ; ALL-LABEL: @shuffle_v4f32_1000
95 ; ALL: shufps {{.*}} # xmm0 = xmm0[1,0,0,0]
97 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 1, i32 0, i32 0, i32 0>
98 ret <4 x float> %shuffle
100 define <4 x float> @shuffle_v4f32_2200(<4 x float> %a, <4 x float> %b) {
101 ; ALL-LABEL: @shuffle_v4f32_2200
102 ; ALL: shufps {{.*}} # xmm0 = xmm0[2,2,0,0]
104 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 2, i32 2, i32 0, i32 0>
105 ret <4 x float> %shuffle
107 define <4 x float> @shuffle_v4f32_3330(<4 x float> %a, <4 x float> %b) {
108 ; ALL-LABEL: @shuffle_v4f32_3330
109 ; ALL: shufps {{.*}} # xmm0 = xmm0[3,3,3,0]
111 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 3, i32 3, i32 3, i32 0>
112 ret <4 x float> %shuffle
114 define <4 x float> @shuffle_v4f32_3210(<4 x float> %a, <4 x float> %b) {
115 ; ALL-LABEL: @shuffle_v4f32_3210
116 ; ALL: shufps {{.*}} # xmm0 = xmm0[3,2,1,0]
118 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
119 ret <4 x float> %shuffle
122 define <4 x i32> @shuffle_v4i32_0124(<4 x i32> %a, <4 x i32> %b) {
123 ; ALL-LABEL: @shuffle_v4i32_0124
124 ; ALL: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
125 ; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[2,0]
127 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
128 ret <4 x i32> %shuffle
130 define <4 x i32> @shuffle_v4i32_0142(<4 x i32> %a, <4 x i32> %b) {
131 ; ALL-LABEL: @shuffle_v4i32_0142
132 ; ALL: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
133 ; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,2]
135 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 2>
136 ret <4 x i32> %shuffle
138 define <4 x i32> @shuffle_v4i32_0412(<4 x i32> %a, <4 x i32> %b) {
139 ; SSE2-LABEL: @shuffle_v4i32_0412
140 ; SSE2: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
141 ; SSE2-NEXT: shufps {{.*}} # xmm1 = xmm1[2,0],xmm0[1,2]
142 ; SSE2-NEXT: movaps %xmm1, %xmm0
145 ; AVX1-LABEL: @shuffle_v4i32_0412
146 ; AVX1: vshufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
147 ; AVX1-NEXT: vshufps {{.*}} # xmm0 = xmm1[2,0],xmm0[1,2]
149 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 1, i32 2>
150 ret <4 x i32> %shuffle
152 define <4 x i32> @shuffle_v4i32_4012(<4 x i32> %a, <4 x i32> %b) {
153 ; SSE2-LABEL: @shuffle_v4i32_4012
154 ; SSE2: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
155 ; SSE2-NEXT: shufps {{.*}} # xmm1 = xmm1[0,2],xmm0[1,2]
156 ; SSE2-NEXT: movaps %xmm1, %xmm0
159 ; AVX1-LABEL: @shuffle_v4i32_4012
160 ; AVX1: vshufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
161 ; AVX1-NEXT: vshufps {{.*}} # xmm0 = xmm1[0,2],xmm0[1,2]
163 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 0, i32 1, i32 2>
164 ret <4 x i32> %shuffle
166 define <4 x i32> @shuffle_v4i32_0145(<4 x i32> %a, <4 x i32> %b) {
167 ; ALL-LABEL: @shuffle_v4i32_0145
168 ; ALL: punpcklqdq {{.*}} # xmm0 = xmm0[0],xmm1[0]
170 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
171 ret <4 x i32> %shuffle
173 define <4 x i32> @shuffle_v4i32_0451(<4 x i32> %a, <4 x i32> %b) {
174 ; ALL-LABEL: @shuffle_v4i32_0451
175 ; ALL: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,1]
176 ; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[0,2,3,1]
178 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 5, i32 1>
179 ret <4 x i32> %shuffle
181 define <4 x i32> @shuffle_v4i32_4501(<4 x i32> %a, <4 x i32> %b) {
182 ; SSE2-LABEL: @shuffle_v4i32_4501
183 ; SSE2: punpcklqdq {{.*}} # xmm1 = xmm1[0],xmm0[0]
184 ; SSE2-NEXT: movdqa %xmm1, %xmm0
187 ; AVX1-LABEL: @shuffle_v4i32_4501
188 ; AVX1: punpcklqdq {{.*}} # xmm0 = xmm1[0],xmm0[0]
190 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 5, i32 0, i32 1>
191 ret <4 x i32> %shuffle
193 define <4 x i32> @shuffle_v4i32_4015(<4 x i32> %a, <4 x i32> %b) {
194 ; ALL-LABEL: @shuffle_v4i32_4015
195 ; ALL: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,1]
196 ; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0,1,3]
198 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 0, i32 1, i32 5>
199 ret <4 x i32> %shuffle