1 ; RUN: llc < %s -march=x86-64 -mattr=+sse3,-avx | FileCheck %s -check-prefix=SSE3
2 ; RUN: llc < %s -march=x86-64 -mattr=-sse3,+avx | FileCheck %s -check-prefix=AVX
9 define <2 x double> @haddpd1(<2 x double> %x, <2 x double> %y) {
10 %a = shufflevector <2 x double> %x, <2 x double> %y, <2 x i32> <i32 0, i32 2>
11 %b = shufflevector <2 x double> %x, <2 x double> %y, <2 x i32> <i32 1, i32 3>
12 %r = fadd <2 x double> %a, %b
16 ; SSE3-LABEL: haddpd2:
21 define <2 x double> @haddpd2(<2 x double> %x, <2 x double> %y) {
22 %a = shufflevector <2 x double> %x, <2 x double> %y, <2 x i32> <i32 1, i32 2>
23 %b = shufflevector <2 x double> %y, <2 x double> %x, <2 x i32> <i32 2, i32 1>
24 %r = fadd <2 x double> %a, %b
28 ; SSE3-LABEL: haddpd3:
33 define <2 x double> @haddpd3(<2 x double> %x) {
34 %a = shufflevector <2 x double> %x, <2 x double> undef, <2 x i32> <i32 0, i32 undef>
35 %b = shufflevector <2 x double> %x, <2 x double> undef, <2 x i32> <i32 1, i32 undef>
36 %r = fadd <2 x double> %a, %b
40 ; SSE3-LABEL: haddps1:
45 define <4 x float> @haddps1(<4 x float> %x, <4 x float> %y) {
46 %a = shufflevector <4 x float> %x, <4 x float> %y, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
47 %b = shufflevector <4 x float> %x, <4 x float> %y, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
48 %r = fadd <4 x float> %a, %b
52 ; SSE3-LABEL: haddps2:
57 define <4 x float> @haddps2(<4 x float> %x, <4 x float> %y) {
58 %a = shufflevector <4 x float> %x, <4 x float> %y, <4 x i32> <i32 1, i32 2, i32 5, i32 6>
59 %b = shufflevector <4 x float> %y, <4 x float> %x, <4 x i32> <i32 4, i32 7, i32 0, i32 3>
60 %r = fadd <4 x float> %a, %b
64 ; SSE3-LABEL: haddps3:
69 define <4 x float> @haddps3(<4 x float> %x) {
70 %a = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 undef, i32 2, i32 4, i32 6>
71 %b = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 undef, i32 3, i32 5, i32 7>
72 %r = fadd <4 x float> %a, %b
76 ; SSE3-LABEL: haddps4:
81 define <4 x float> @haddps4(<4 x float> %x) {
82 %a = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef>
83 %b = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef>
84 %r = fadd <4 x float> %a, %b
88 ; SSE3-LABEL: haddps5:
93 define <4 x float> @haddps5(<4 x float> %x) {
94 %a = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 0, i32 3, i32 undef, i32 undef>
95 %b = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 1, i32 2, i32 undef, i32 undef>
96 %r = fadd <4 x float> %a, %b
100 ; SSE3-LABEL: haddps6:
103 ; AVX-LABEL: haddps6:
105 define <4 x float> @haddps6(<4 x float> %x) {
106 %a = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>
107 %b = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
108 %r = fadd <4 x float> %a, %b
112 ; SSE3-LABEL: haddps7:
115 ; AVX-LABEL: haddps7:
117 define <4 x float> @haddps7(<4 x float> %x) {
118 %a = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 undef, i32 3, i32 undef, i32 undef>
119 %b = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 undef, i32 2, i32 undef, i32 undef>
120 %r = fadd <4 x float> %a, %b
124 ; SSE3-LABEL: hsubpd1:
127 ; AVX-LABEL: hsubpd1:
129 define <2 x double> @hsubpd1(<2 x double> %x, <2 x double> %y) {
130 %a = shufflevector <2 x double> %x, <2 x double> %y, <2 x i32> <i32 0, i32 2>
131 %b = shufflevector <2 x double> %x, <2 x double> %y, <2 x i32> <i32 1, i32 3>
132 %r = fsub <2 x double> %a, %b
136 ; SSE3-LABEL: hsubpd2:
139 ; AVX-LABEL: hsubpd2:
141 define <2 x double> @hsubpd2(<2 x double> %x) {
142 %a = shufflevector <2 x double> %x, <2 x double> undef, <2 x i32> <i32 0, i32 undef>
143 %b = shufflevector <2 x double> %x, <2 x double> undef, <2 x i32> <i32 1, i32 undef>
144 %r = fsub <2 x double> %a, %b
148 ; SSE3-LABEL: hsubps1:
151 ; AVX-LABEL: hsubps1:
153 define <4 x float> @hsubps1(<4 x float> %x, <4 x float> %y) {
154 %a = shufflevector <4 x float> %x, <4 x float> %y, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
155 %b = shufflevector <4 x float> %x, <4 x float> %y, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
156 %r = fsub <4 x float> %a, %b
160 ; SSE3-LABEL: hsubps2:
163 ; AVX-LABEL: hsubps2:
165 define <4 x float> @hsubps2(<4 x float> %x) {
166 %a = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 undef, i32 2, i32 4, i32 6>
167 %b = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 undef, i32 3, i32 5, i32 7>
168 %r = fsub <4 x float> %a, %b
172 ; SSE3-LABEL: hsubps3:
175 ; AVX-LABEL: hsubps3:
177 define <4 x float> @hsubps3(<4 x float> %x) {
178 %a = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef>
179 %b = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef>
180 %r = fsub <4 x float> %a, %b
184 ; SSE3-LABEL: hsubps4:
187 ; AVX-LABEL: hsubps4:
189 define <4 x float> @hsubps4(<4 x float> %x) {
190 %a = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>
191 %b = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
192 %r = fsub <4 x float> %a, %b
196 ; SSE3-LABEL: vhaddps1:
200 ; AVX-LABEL: vhaddps1:
202 define <8 x float> @vhaddps1(<8 x float> %x, <8 x float> %y) {
203 %a = shufflevector <8 x float> %x, <8 x float> %y, <8 x i32> <i32 0, i32 2, i32 8, i32 10, i32 4, i32 6, i32 12, i32 14>
204 %b = shufflevector <8 x float> %x, <8 x float> %y, <8 x i32> <i32 1, i32 3, i32 9, i32 11, i32 5, i32 7, i32 13, i32 15>
205 %r = fadd <8 x float> %a, %b
209 ; SSE3-LABEL: vhaddps2:
213 ; AVX-LABEL: vhaddps2:
215 define <8 x float> @vhaddps2(<8 x float> %x, <8 x float> %y) {
216 %a = shufflevector <8 x float> %x, <8 x float> %y, <8 x i32> <i32 1, i32 2, i32 9, i32 10, i32 5, i32 6, i32 13, i32 14>
217 %b = shufflevector <8 x float> %y, <8 x float> %x, <8 x i32> <i32 8, i32 11, i32 0, i32 3, i32 12, i32 15, i32 4, i32 7>
218 %r = fadd <8 x float> %a, %b
222 ; SSE3-LABEL: vhaddps3:
226 ; AVX-LABEL: vhaddps3:
228 define <8 x float> @vhaddps3(<8 x float> %x) {
229 %a = shufflevector <8 x float> %x, <8 x float> undef, <8 x i32> <i32 undef, i32 2, i32 8, i32 10, i32 4, i32 6, i32 undef, i32 14>
230 %b = shufflevector <8 x float> %x, <8 x float> undef, <8 x i32> <i32 1, i32 3, i32 9, i32 undef, i32 5, i32 7, i32 13, i32 15>
231 %r = fadd <8 x float> %a, %b
235 ; SSE3-LABEL: vhsubps1:
239 ; AVX-LABEL: vhsubps1:
241 define <8 x float> @vhsubps1(<8 x float> %x, <8 x float> %y) {
242 %a = shufflevector <8 x float> %x, <8 x float> %y, <8 x i32> <i32 0, i32 2, i32 8, i32 10, i32 4, i32 6, i32 12, i32 14>
243 %b = shufflevector <8 x float> %x, <8 x float> %y, <8 x i32> <i32 1, i32 3, i32 9, i32 11, i32 5, i32 7, i32 13, i32 15>
244 %r = fsub <8 x float> %a, %b
248 ; SSE3-LABEL: vhsubps3:
252 ; AVX-LABEL: vhsubps3:
254 define <8 x float> @vhsubps3(<8 x float> %x) {
255 %a = shufflevector <8 x float> %x, <8 x float> undef, <8 x i32> <i32 undef, i32 2, i32 8, i32 10, i32 4, i32 6, i32 undef, i32 14>
256 %b = shufflevector <8 x float> %x, <8 x float> undef, <8 x i32> <i32 1, i32 3, i32 9, i32 undef, i32 5, i32 7, i32 13, i32 15>
257 %r = fsub <8 x float> %a, %b
261 ; SSE3-LABEL: vhaddpd1:
265 ; AVX-LABEL: vhaddpd1:
267 define <4 x double> @vhaddpd1(<4 x double> %x, <4 x double> %y) {
268 %a = shufflevector <4 x double> %x, <4 x double> %y, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
269 %b = shufflevector <4 x double> %x, <4 x double> %y, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
270 %r = fadd <4 x double> %a, %b
274 ; SSE3-LABEL: vhsubpd1:
278 ; AVX-LABEL: vhsubpd1:
280 define <4 x double> @vhsubpd1(<4 x double> %x, <4 x double> %y) {
281 %a = shufflevector <4 x double> %x, <4 x double> %y, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
282 %b = shufflevector <4 x double> %x, <4 x double> %y, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
283 %r = fsub <4 x double> %a, %b