[Demangle] Add a few more options to the microsoft demangler
[llvm-complete.git] / test / CodeGen / X86 / bswap-vector.ll
blob4bb2b764ccc9780e8404ef73becb21f9c055057d
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefix=CHECK-ALL --check-prefix=CHECK-SSE --check-prefix=CHECK-NOSSSE3
3 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+ssse3 | FileCheck %s --check-prefix=CHECK-ALL --check-prefix=CHECK-SSE --check-prefix=CHECK-SSSE3
4 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 | FileCheck %s --check-prefix=CHECK-ALL --check-prefix=CHECK-AVX --check-prefix=CHECK-AVX2
6 declare <8 x i16> @llvm.bswap.v8i16(<8 x i16>)
7 declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>)
8 declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
10 define <8 x i16> @test1(<8 x i16> %v) {
11 ; CHECK-NOSSSE3-LABEL: test1:
12 ; CHECK-NOSSSE3:       # %bb.0: # %entry
13 ; CHECK-NOSSSE3-NEXT:    pxor %xmm1, %xmm1
14 ; CHECK-NOSSSE3-NEXT:    movdqa %xmm0, %xmm2
15 ; CHECK-NOSSSE3-NEXT:    punpckhbw {{.*#+}} xmm2 = xmm2[8],xmm1[8],xmm2[9],xmm1[9],xmm2[10],xmm1[10],xmm2[11],xmm1[11],xmm2[12],xmm1[12],xmm2[13],xmm1[13],xmm2[14],xmm1[14],xmm2[15],xmm1[15]
16 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm2 = xmm2[1,0,3,2,4,5,6,7]
17 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm2 = xmm2[0,1,2,3,5,4,7,6]
18 ; CHECK-NOSSSE3-NEXT:    punpcklbw {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
19 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm0 = xmm0[1,0,3,2,4,5,6,7]
20 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,5,4,7,6]
21 ; CHECK-NOSSSE3-NEXT:    packuswb %xmm2, %xmm0
22 ; CHECK-NOSSSE3-NEXT:    retq
24 ; CHECK-SSSE3-LABEL: test1:
25 ; CHECK-SSSE3:       # %bb.0: # %entry
26 ; CHECK-SSSE3-NEXT:    pshufb {{.*#+}} xmm0 = xmm0[1,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14]
27 ; CHECK-SSSE3-NEXT:    retq
29 ; CHECK-AVX-LABEL: test1:
30 ; CHECK-AVX:       # %bb.0: # %entry
31 ; CHECK-AVX-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[1,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14]
32 ; CHECK-AVX-NEXT:    retq
33 entry:
34   %r = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %v)
35   ret <8 x i16> %r
38 define <4 x i32> @test2(<4 x i32> %v) {
39 ; CHECK-NOSSSE3-LABEL: test2:
40 ; CHECK-NOSSSE3:       # %bb.0:
41 ; CHECK-NOSSSE3-NEXT:    pxor %xmm1, %xmm1
42 ; CHECK-NOSSSE3-NEXT:    movdqa %xmm0, %xmm2
43 ; CHECK-NOSSSE3-NEXT:    punpckhbw {{.*#+}} xmm2 = xmm2[8],xmm1[8],xmm2[9],xmm1[9],xmm2[10],xmm1[10],xmm2[11],xmm1[11],xmm2[12],xmm1[12],xmm2[13],xmm1[13],xmm2[14],xmm1[14],xmm2[15],xmm1[15]
44 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm2 = xmm2[3,2,1,0,4,5,6,7]
45 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm2 = xmm2[0,1,2,3,7,6,5,4]
46 ; CHECK-NOSSSE3-NEXT:    punpcklbw {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
47 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7]
48 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4]
49 ; CHECK-NOSSSE3-NEXT:    packuswb %xmm2, %xmm0
50 ; CHECK-NOSSSE3-NEXT:    retq
52 ; CHECK-SSSE3-LABEL: test2:
53 ; CHECK-SSSE3:       # %bb.0:
54 ; CHECK-SSSE3-NEXT:    pshufb {{.*#+}} xmm0 = xmm0[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12]
55 ; CHECK-SSSE3-NEXT:    retq
57 ; CHECK-AVX-LABEL: test2:
58 ; CHECK-AVX:       # %bb.0:
59 ; CHECK-AVX-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12]
60 ; CHECK-AVX-NEXT:    retq
61   %r = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %v)
62   ret <4 x i32> %r
65 define <4 x i32> @or_bswap(<4 x i32> %x, <4 x i32> %y, <4 x i32>* %p1, <4 x i32>* %p2) {
66 ; CHECK-NOSSSE3-LABEL: or_bswap:
67 ; CHECK-NOSSSE3:       # %bb.0:
68 ; CHECK-NOSSSE3-NEXT:    por %xmm1, %xmm0
69 ; CHECK-NOSSSE3-NEXT:    pxor %xmm1, %xmm1
70 ; CHECK-NOSSSE3-NEXT:    movdqa %xmm0, %xmm2
71 ; CHECK-NOSSSE3-NEXT:    punpckhbw {{.*#+}} xmm2 = xmm2[8],xmm1[8],xmm2[9],xmm1[9],xmm2[10],xmm1[10],xmm2[11],xmm1[11],xmm2[12],xmm1[12],xmm2[13],xmm1[13],xmm2[14],xmm1[14],xmm2[15],xmm1[15]
72 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm2 = xmm2[3,2,1,0,4,5,6,7]
73 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm2 = xmm2[0,1,2,3,7,6,5,4]
74 ; CHECK-NOSSSE3-NEXT:    punpcklbw {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
75 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7]
76 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4]
77 ; CHECK-NOSSSE3-NEXT:    packuswb %xmm2, %xmm0
78 ; CHECK-NOSSSE3-NEXT:    retq
80 ; CHECK-SSSE3-LABEL: or_bswap:
81 ; CHECK-SSSE3:       # %bb.0:
82 ; CHECK-SSSE3-NEXT:    por %xmm1, %xmm0
83 ; CHECK-SSSE3-NEXT:    pshufb {{.*#+}} xmm0 = xmm0[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12]
84 ; CHECK-SSSE3-NEXT:    retq
86 ; CHECK-AVX-LABEL: or_bswap:
87 ; CHECK-AVX:       # %bb.0:
88 ; CHECK-AVX-NEXT:    vpor %xmm1, %xmm0, %xmm0
89 ; CHECK-AVX-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12]
90 ; CHECK-AVX-NEXT:    retq
91   %xt = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %x)
92   %yt = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %y)
93   %r = or <4 x i32> %xt, %yt
94   ret <4 x i32> %r
97 define <2 x i64> @test3(<2 x i64> %v) {
98 ; CHECK-NOSSSE3-LABEL: test3:
99 ; CHECK-NOSSSE3:       # %bb.0: # %entry
100 ; CHECK-NOSSSE3-NEXT:    pxor %xmm1, %xmm1
101 ; CHECK-NOSSSE3-NEXT:    movdqa %xmm0, %xmm2
102 ; CHECK-NOSSSE3-NEXT:    punpckhbw {{.*#+}} xmm2 = xmm2[8],xmm1[8],xmm2[9],xmm1[9],xmm2[10],xmm1[10],xmm2[11],xmm1[11],xmm2[12],xmm1[12],xmm2[13],xmm1[13],xmm2[14],xmm1[14],xmm2[15],xmm1[15]
103 ; CHECK-NOSSSE3-NEXT:    pshufd {{.*#+}} xmm2 = xmm2[2,3,0,1]
104 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm2 = xmm2[3,2,1,0,4,5,6,7]
105 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm2 = xmm2[0,1,2,3,7,6,5,4]
106 ; CHECK-NOSSSE3-NEXT:    punpcklbw {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
107 ; CHECK-NOSSSE3-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[2,3,0,1]
108 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7]
109 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4]
110 ; CHECK-NOSSSE3-NEXT:    packuswb %xmm2, %xmm0
111 ; CHECK-NOSSSE3-NEXT:    retq
113 ; CHECK-SSSE3-LABEL: test3:
114 ; CHECK-SSSE3:       # %bb.0: # %entry
115 ; CHECK-SSSE3-NEXT:    pshufb {{.*#+}} xmm0 = xmm0[7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8]
116 ; CHECK-SSSE3-NEXT:    retq
118 ; CHECK-AVX-LABEL: test3:
119 ; CHECK-AVX:       # %bb.0: # %entry
120 ; CHECK-AVX-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8]
121 ; CHECK-AVX-NEXT:    retq
122 entry:
123   %r = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %v)
124   ret <2 x i64> %r
127 declare <16 x i16> @llvm.bswap.v16i16(<16 x i16>)
128 declare <8 x i32> @llvm.bswap.v8i32(<8 x i32>)
129 declare <4 x i64> @llvm.bswap.v4i64(<4 x i64>)
131 define <16 x i16> @test4(<16 x i16> %v) {
132 ; CHECK-NOSSSE3-LABEL: test4:
133 ; CHECK-NOSSSE3:       # %bb.0: # %entry
134 ; CHECK-NOSSSE3-NEXT:    pxor %xmm2, %xmm2
135 ; CHECK-NOSSSE3-NEXT:    movdqa %xmm0, %xmm3
136 ; CHECK-NOSSSE3-NEXT:    punpckhbw {{.*#+}} xmm3 = xmm3[8],xmm2[8],xmm3[9],xmm2[9],xmm3[10],xmm2[10],xmm3[11],xmm2[11],xmm3[12],xmm2[12],xmm3[13],xmm2[13],xmm3[14],xmm2[14],xmm3[15],xmm2[15]
137 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm3 = xmm3[1,0,3,2,4,5,6,7]
138 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm3 = xmm3[0,1,2,3,5,4,7,6]
139 ; CHECK-NOSSSE3-NEXT:    punpcklbw {{.*#+}} xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1],xmm0[2],xmm2[2],xmm0[3],xmm2[3],xmm0[4],xmm2[4],xmm0[5],xmm2[5],xmm0[6],xmm2[6],xmm0[7],xmm2[7]
140 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm0 = xmm0[1,0,3,2,4,5,6,7]
141 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,5,4,7,6]
142 ; CHECK-NOSSSE3-NEXT:    packuswb %xmm3, %xmm0
143 ; CHECK-NOSSSE3-NEXT:    movdqa %xmm1, %xmm3
144 ; CHECK-NOSSSE3-NEXT:    punpckhbw {{.*#+}} xmm3 = xmm3[8],xmm2[8],xmm3[9],xmm2[9],xmm3[10],xmm2[10],xmm3[11],xmm2[11],xmm3[12],xmm2[12],xmm3[13],xmm2[13],xmm3[14],xmm2[14],xmm3[15],xmm2[15]
145 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm3 = xmm3[1,0,3,2,4,5,6,7]
146 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm3 = xmm3[0,1,2,3,5,4,7,6]
147 ; CHECK-NOSSSE3-NEXT:    punpcklbw {{.*#+}} xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1],xmm1[2],xmm2[2],xmm1[3],xmm2[3],xmm1[4],xmm2[4],xmm1[5],xmm2[5],xmm1[6],xmm2[6],xmm1[7],xmm2[7]
148 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm1 = xmm1[1,0,3,2,4,5,6,7]
149 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm1 = xmm1[0,1,2,3,5,4,7,6]
150 ; CHECK-NOSSSE3-NEXT:    packuswb %xmm3, %xmm1
151 ; CHECK-NOSSSE3-NEXT:    retq
153 ; CHECK-SSSE3-LABEL: test4:
154 ; CHECK-SSSE3:       # %bb.0: # %entry
155 ; CHECK-SSSE3-NEXT:    movdqa {{.*#+}} xmm2 = [1,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14]
156 ; CHECK-SSSE3-NEXT:    pshufb %xmm2, %xmm0
157 ; CHECK-SSSE3-NEXT:    pshufb %xmm2, %xmm1
158 ; CHECK-SSSE3-NEXT:    retq
160 ; CHECK-AVX-LABEL: test4:
161 ; CHECK-AVX:       # %bb.0: # %entry
162 ; CHECK-AVX-NEXT:    vpshufb {{.*#+}} ymm0 = ymm0[1,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14,17,16,19,18,21,20,23,22,25,24,27,26,29,28,31,30]
163 ; CHECK-AVX-NEXT:    retq
164 entry:
165   %r = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %v)
166   ret <16 x i16> %r
169 define <8 x i32> @test5(<8 x i32> %v) {
170 ; CHECK-NOSSSE3-LABEL: test5:
171 ; CHECK-NOSSSE3:       # %bb.0: # %entry
172 ; CHECK-NOSSSE3-NEXT:    pxor %xmm2, %xmm2
173 ; CHECK-NOSSSE3-NEXT:    movdqa %xmm0, %xmm3
174 ; CHECK-NOSSSE3-NEXT:    punpckhbw {{.*#+}} xmm3 = xmm3[8],xmm2[8],xmm3[9],xmm2[9],xmm3[10],xmm2[10],xmm3[11],xmm2[11],xmm3[12],xmm2[12],xmm3[13],xmm2[13],xmm3[14],xmm2[14],xmm3[15],xmm2[15]
175 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm3 = xmm3[3,2,1,0,4,5,6,7]
176 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm3 = xmm3[0,1,2,3,7,6,5,4]
177 ; CHECK-NOSSSE3-NEXT:    punpcklbw {{.*#+}} xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1],xmm0[2],xmm2[2],xmm0[3],xmm2[3],xmm0[4],xmm2[4],xmm0[5],xmm2[5],xmm0[6],xmm2[6],xmm0[7],xmm2[7]
178 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7]
179 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4]
180 ; CHECK-NOSSSE3-NEXT:    packuswb %xmm3, %xmm0
181 ; CHECK-NOSSSE3-NEXT:    movdqa %xmm1, %xmm3
182 ; CHECK-NOSSSE3-NEXT:    punpckhbw {{.*#+}} xmm3 = xmm3[8],xmm2[8],xmm3[9],xmm2[9],xmm3[10],xmm2[10],xmm3[11],xmm2[11],xmm3[12],xmm2[12],xmm3[13],xmm2[13],xmm3[14],xmm2[14],xmm3[15],xmm2[15]
183 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm3 = xmm3[3,2,1,0,4,5,6,7]
184 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm3 = xmm3[0,1,2,3,7,6,5,4]
185 ; CHECK-NOSSSE3-NEXT:    punpcklbw {{.*#+}} xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1],xmm1[2],xmm2[2],xmm1[3],xmm2[3],xmm1[4],xmm2[4],xmm1[5],xmm2[5],xmm1[6],xmm2[6],xmm1[7],xmm2[7]
186 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm1 = xmm1[3,2,1,0,4,5,6,7]
187 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm1 = xmm1[0,1,2,3,7,6,5,4]
188 ; CHECK-NOSSSE3-NEXT:    packuswb %xmm3, %xmm1
189 ; CHECK-NOSSSE3-NEXT:    retq
191 ; CHECK-SSSE3-LABEL: test5:
192 ; CHECK-SSSE3:       # %bb.0: # %entry
193 ; CHECK-SSSE3-NEXT:    movdqa {{.*#+}} xmm2 = [3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12]
194 ; CHECK-SSSE3-NEXT:    pshufb %xmm2, %xmm0
195 ; CHECK-SSSE3-NEXT:    pshufb %xmm2, %xmm1
196 ; CHECK-SSSE3-NEXT:    retq
198 ; CHECK-AVX-LABEL: test5:
199 ; CHECK-AVX:       # %bb.0: # %entry
200 ; CHECK-AVX-NEXT:    vpshufb {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12,19,18,17,16,23,22,21,20,27,26,25,24,31,30,29,28]
201 ; CHECK-AVX-NEXT:    retq
202 entry:
203   %r = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %v)
204   ret <8 x i32> %r
207 define <4 x i64> @test6(<4 x i64> %v) {
208 ; CHECK-NOSSSE3-LABEL: test6:
209 ; CHECK-NOSSSE3:       # %bb.0: # %entry
210 ; CHECK-NOSSSE3-NEXT:    pxor %xmm2, %xmm2
211 ; CHECK-NOSSSE3-NEXT:    movdqa %xmm0, %xmm3
212 ; CHECK-NOSSSE3-NEXT:    punpckhbw {{.*#+}} xmm3 = xmm3[8],xmm2[8],xmm3[9],xmm2[9],xmm3[10],xmm2[10],xmm3[11],xmm2[11],xmm3[12],xmm2[12],xmm3[13],xmm2[13],xmm3[14],xmm2[14],xmm3[15],xmm2[15]
213 ; CHECK-NOSSSE3-NEXT:    pshufd {{.*#+}} xmm3 = xmm3[2,3,0,1]
214 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm3 = xmm3[3,2,1,0,4,5,6,7]
215 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm3 = xmm3[0,1,2,3,7,6,5,4]
216 ; CHECK-NOSSSE3-NEXT:    punpcklbw {{.*#+}} xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1],xmm0[2],xmm2[2],xmm0[3],xmm2[3],xmm0[4],xmm2[4],xmm0[5],xmm2[5],xmm0[6],xmm2[6],xmm0[7],xmm2[7]
217 ; CHECK-NOSSSE3-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[2,3,0,1]
218 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7]
219 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4]
220 ; CHECK-NOSSSE3-NEXT:    packuswb %xmm3, %xmm0
221 ; CHECK-NOSSSE3-NEXT:    movdqa %xmm1, %xmm3
222 ; CHECK-NOSSSE3-NEXT:    punpckhbw {{.*#+}} xmm3 = xmm3[8],xmm2[8],xmm3[9],xmm2[9],xmm3[10],xmm2[10],xmm3[11],xmm2[11],xmm3[12],xmm2[12],xmm3[13],xmm2[13],xmm3[14],xmm2[14],xmm3[15],xmm2[15]
223 ; CHECK-NOSSSE3-NEXT:    pshufd {{.*#+}} xmm3 = xmm3[2,3,0,1]
224 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm3 = xmm3[3,2,1,0,4,5,6,7]
225 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm3 = xmm3[0,1,2,3,7,6,5,4]
226 ; CHECK-NOSSSE3-NEXT:    punpcklbw {{.*#+}} xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1],xmm1[2],xmm2[2],xmm1[3],xmm2[3],xmm1[4],xmm2[4],xmm1[5],xmm2[5],xmm1[6],xmm2[6],xmm1[7],xmm2[7]
227 ; CHECK-NOSSSE3-NEXT:    pshufd {{.*#+}} xmm1 = xmm1[2,3,0,1]
228 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm1 = xmm1[3,2,1,0,4,5,6,7]
229 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm1 = xmm1[0,1,2,3,7,6,5,4]
230 ; CHECK-NOSSSE3-NEXT:    packuswb %xmm3, %xmm1
231 ; CHECK-NOSSSE3-NEXT:    retq
233 ; CHECK-SSSE3-LABEL: test6:
234 ; CHECK-SSSE3:       # %bb.0: # %entry
235 ; CHECK-SSSE3-NEXT:    movdqa {{.*#+}} xmm2 = [7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8]
236 ; CHECK-SSSE3-NEXT:    pshufb %xmm2, %xmm0
237 ; CHECK-SSSE3-NEXT:    pshufb %xmm2, %xmm1
238 ; CHECK-SSSE3-NEXT:    retq
240 ; CHECK-AVX-LABEL: test6:
241 ; CHECK-AVX:       # %bb.0: # %entry
242 ; CHECK-AVX-NEXT:    vpshufb {{.*#+}} ymm0 = ymm0[7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24]
243 ; CHECK-AVX-NEXT:    retq
244 entry:
245   %r = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %v)
246   ret <4 x i64> %r
249 declare <4 x i16> @llvm.bswap.v4i16(<4 x i16>)
251 define <4 x i16> @test7(<4 x i16> %v) {
252 ; CHECK-NOSSSE3-LABEL: test7:
253 ; CHECK-NOSSSE3:       # %bb.0: # %entry
254 ; CHECK-NOSSSE3-NEXT:    pxor %xmm1, %xmm1
255 ; CHECK-NOSSSE3-NEXT:    movdqa %xmm0, %xmm2
256 ; CHECK-NOSSSE3-NEXT:    punpckhbw {{.*#+}} xmm2 = xmm2[8],xmm1[8],xmm2[9],xmm1[9],xmm2[10],xmm1[10],xmm2[11],xmm1[11],xmm2[12],xmm1[12],xmm2[13],xmm1[13],xmm2[14],xmm1[14],xmm2[15],xmm1[15]
257 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm2 = xmm2[1,0,3,2,4,5,6,7]
258 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm2 = xmm2[0,1,2,3,5,4,7,6]
259 ; CHECK-NOSSSE3-NEXT:    punpcklbw {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
260 ; CHECK-NOSSSE3-NEXT:    pshuflw {{.*#+}} xmm0 = xmm0[1,0,3,2,4,5,6,7]
261 ; CHECK-NOSSSE3-NEXT:    pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,5,4,7,6]
262 ; CHECK-NOSSSE3-NEXT:    packuswb %xmm2, %xmm0
263 ; CHECK-NOSSSE3-NEXT:    retq
265 ; CHECK-SSSE3-LABEL: test7:
266 ; CHECK-SSSE3:       # %bb.0: # %entry
267 ; CHECK-SSSE3-NEXT:    pshufb {{.*#+}} xmm0 = xmm0[1,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14]
268 ; CHECK-SSSE3-NEXT:    retq
270 ; CHECK-AVX-LABEL: test7:
271 ; CHECK-AVX:       # %bb.0: # %entry
272 ; CHECK-AVX-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[1,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14]
273 ; CHECK-AVX-NEXT:    retq
274 entry:
275   %r = call <4 x i16> @llvm.bswap.v4i16(<4 x i16> %v)
276   ret <4 x i16> %r
280 ; Double BSWAP -> Identity
283 define <8 x i16> @identity_v8i16(<8 x i16> %v) {
284 ; CHECK-ALL-LABEL: identity_v8i16:
285 ; CHECK-ALL:       # %bb.0: # %entry
286 ; CHECK-ALL-NEXT:    retq
287 entry:
288   %bs1 = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %v)
289   %bs2 = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %bs1)
290   ret <8 x i16> %bs2
293 define <4 x i32> @identity_v4i32(<4 x i32> %v) {
294 ; CHECK-ALL-LABEL: identity_v4i32:
295 ; CHECK-ALL:       # %bb.0: # %entry
296 ; CHECK-ALL-NEXT:    retq
297 entry:
298   %bs1 = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %v)
299   %bs2 = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %bs1)
300   ret <4 x i32> %bs2
303 define <2 x i64> @identity_v2i64(<2 x i64> %v) {
304 ; CHECK-ALL-LABEL: identity_v2i64:
305 ; CHECK-ALL:       # %bb.0: # %entry
306 ; CHECK-ALL-NEXT:    retq
307 entry:
308   %bs1 = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %v)
309   %bs2 = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %bs1)
310   ret <2 x i64> %bs2
313 define <16 x i16> @identity_v16i16(<16 x i16> %v) {
314 ; CHECK-ALL-LABEL: identity_v16i16:
315 ; CHECK-ALL:       # %bb.0: # %entry
316 ; CHECK-ALL-NEXT:    retq
317 entry:
318   %bs1 = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %v)
319   %bs2 = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %bs1)
320   ret <16 x i16> %bs2
323 define <8 x i32> @identity_v8i32(<8 x i32> %v) {
324 ; CHECK-ALL-LABEL: identity_v8i32:
325 ; CHECK-ALL:       # %bb.0: # %entry
326 ; CHECK-ALL-NEXT:    retq
327 entry:
328   %bs1 = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %v)
329   %bs2 = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %bs1)
330   ret <8 x i32> %bs2
333 define <4 x i64> @identity_v4i64(<4 x i64> %v) {
334 ; CHECK-ALL-LABEL: identity_v4i64:
335 ; CHECK-ALL:       # %bb.0: # %entry
336 ; CHECK-ALL-NEXT:    retq
337 entry:
338   %bs1 = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %v)
339   %bs2 = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %bs1)
340   ret <4 x i64> %bs2
343 define <4 x i16> @identity_v4i16(<4 x i16> %v) {
344 ; CHECK-ALL-LABEL: identity_v4i16:
345 ; CHECK-ALL:       # %bb.0: # %entry
346 ; CHECK-ALL-NEXT:    retq
347 entry:
348   %bs1 = call <4 x i16> @llvm.bswap.v4i16(<4 x i16> %v)
349   %bs2 = call <4 x i16> @llvm.bswap.v4i16(<4 x i16> %bs1)
350   ret <4 x i16> %bs2
354 ; Constant Folding
357 define <8 x i16> @fold_v8i16() {
358 ; CHECK-SSE-LABEL: fold_v8i16:
359 ; CHECK-SSE:       # %bb.0: # %entry
360 ; CHECK-SSE-NEXT:    movaps {{.*#+}} xmm0 = [0,256,65535,512,65023,1024,64511,1536]
361 ; CHECK-SSE-NEXT:    retq
363 ; CHECK-AVX-LABEL: fold_v8i16:
364 ; CHECK-AVX:       # %bb.0: # %entry
365 ; CHECK-AVX-NEXT:    vmovaps {{.*#+}} xmm0 = [0,256,65535,512,65023,1024,64511,1536]
366 ; CHECK-AVX-NEXT:    retq
367 entry:
368   %r = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> <i16 0, i16 1, i16 -1, i16 2, i16 -3, i16 4, i16 -5, i16 6>)
369   ret <8 x i16> %r
372 define <4 x i32> @fold_v4i32() {
373 ; CHECK-SSE-LABEL: fold_v4i32:
374 ; CHECK-SSE:       # %bb.0: # %entry
375 ; CHECK-SSE-NEXT:    movaps {{.*#+}} xmm0 = [0,4294967295,33554432,4261412863]
376 ; CHECK-SSE-NEXT:    retq
378 ; CHECK-AVX-LABEL: fold_v4i32:
379 ; CHECK-AVX:       # %bb.0: # %entry
380 ; CHECK-AVX-NEXT:    vmovaps {{.*#+}} xmm0 = [0,4294967295,33554432,4261412863]
381 ; CHECK-AVX-NEXT:    retq
382 entry:
383   %r = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> <i32 0, i32 -1, i32 2, i32 -3>)
384   ret <4 x i32> %r
387 define <2 x i64> @fold_v2i64() {
388 ; CHECK-SSE-LABEL: fold_v2i64:
389 ; CHECK-SSE:       # %bb.0: # %entry
390 ; CHECK-SSE-NEXT:    movaps {{.*#+}} xmm0 = [18374686479671623680,18446744073709551615]
391 ; CHECK-SSE-NEXT:    retq
393 ; CHECK-AVX-LABEL: fold_v2i64:
394 ; CHECK-AVX:       # %bb.0: # %entry
395 ; CHECK-AVX-NEXT:    vmovaps {{.*#+}} xmm0 = [18374686479671623680,18446744073709551615]
396 ; CHECK-AVX-NEXT:    retq
397 entry:
398   %r = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> <i64 255, i64 -1>)
399   ret <2 x i64> %r
402 define <16 x i16> @fold_v16i16() {
403 ; CHECK-SSE-LABEL: fold_v16i16:
404 ; CHECK-SSE:       # %bb.0: # %entry
405 ; CHECK-SSE-NEXT:    movaps {{.*#+}} xmm0 = [0,256,65535,512,65023,1024,64511,1536]
406 ; CHECK-SSE-NEXT:    movaps {{.*#+}} xmm1 = [63999,2048,63487,2560,62975,3072,62463,3584]
407 ; CHECK-SSE-NEXT:    retq
409 ; CHECK-AVX-LABEL: fold_v16i16:
410 ; CHECK-AVX:       # %bb.0: # %entry
411 ; CHECK-AVX-NEXT:    vmovaps {{.*#+}} ymm0 = [0,256,65535,512,65023,1024,64511,1536,63999,2048,63487,2560,62975,3072,62463,3584]
412 ; CHECK-AVX-NEXT:    retq
413 entry:
414   %r = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> <i16 0, i16 1, i16 -1, i16 2, i16 -3, i16 4, i16 -5, i16 6, i16 -7, i16 8, i16 -9, i16 10, i16 -11, i16 12, i16 -13, i16 14>)
415   ret <16 x i16> %r
418 define <8 x i32> @fold_v8i32() {
419 ; CHECK-SSE-LABEL: fold_v8i32:
420 ; CHECK-SSE:       # %bb.0: # %entry
421 ; CHECK-SSE-NEXT:    movaps {{.*#+}} xmm0 = [0,16777216,4294967295,33554432]
422 ; CHECK-SSE-NEXT:    movaps {{.*#+}} xmm1 = [4261412863,67108864,4227858431,100663296]
423 ; CHECK-SSE-NEXT:    retq
425 ; CHECK-AVX-LABEL: fold_v8i32:
426 ; CHECK-AVX:       # %bb.0: # %entry
427 ; CHECK-AVX-NEXT:    vmovaps {{.*#+}} ymm0 = [0,16777216,4294967295,33554432,4261412863,67108864,4227858431,100663296]
428 ; CHECK-AVX-NEXT:    retq
429 entry:
430   %r = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> <i32 0, i32 1, i32 -1, i32 2, i32 -3, i32 4, i32 -5, i32 6>)
431   ret <8 x i32> %r
434 define <4 x i64> @fold_v4i64() {
435 ; CHECK-SSE-LABEL: fold_v4i64:
436 ; CHECK-SSE:       # %bb.0: # %entry
437 ; CHECK-SSE-NEXT:    movaps {{.*#+}} xmm0 = [18374686479671623680,18446744073709551615]
438 ; CHECK-SSE-NEXT:    movaps {{.*#+}} xmm1 = [18446462598732840960,72056494526300160]
439 ; CHECK-SSE-NEXT:    retq
441 ; CHECK-AVX-LABEL: fold_v4i64:
442 ; CHECK-AVX:       # %bb.0: # %entry
443 ; CHECK-AVX-NEXT:    vmovaps {{.*#+}} ymm0 = [18374686479671623680,18446744073709551615,18446462598732840960,72056494526300160]
444 ; CHECK-AVX-NEXT:    retq
445 entry:
446   %r = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> <i64 255, i64 -1, i64 65535, i64 16776960>)
447   ret <4 x i64> %r