blob: 37597c415d6ddc0285f56ad31b5b5cadac829075 [file] [log] [blame]
Sanjay Patel841acbb2017-08-31 20:59:25 +00001; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+ssse3 | FileCheck %s --check-prefix=SSSE3
3; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx | FileCheck %s --check-prefix=AVX
4
5; The next 8 tests check for matching the horizontal op and eliminating the shuffle.
6; PR34111 - https://bugs.llvm.org/show_bug.cgi?id=34111
7
8define <4 x float> @hadd_v4f32(<4 x float> %a) {
9; SSSE3-LABEL: hadd_v4f32:
10; SSSE3: # BB#0:
11; SSSE3-NEXT: haddps %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +000012; SSSE3-NEXT: retq
13;
14; AVX-LABEL: hadd_v4f32:
15; AVX: # BB#0:
16; AVX-NEXT: vhaddps %xmm0, %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +000017; AVX-NEXT: retq
18 %a02 = shufflevector <4 x float> %a, <4 x float> undef, <2 x i32> <i32 0, i32 2>
19 %a13 = shufflevector <4 x float> %a, <4 x float> undef, <2 x i32> <i32 1, i32 3>
20 %hop = fadd <2 x float> %a02, %a13
21 %shuf = shufflevector <2 x float> %hop, <2 x float> undef, <4 x i32> <i32 undef, i32 undef, i32 0, i32 1>
22 ret <4 x float> %shuf
23}
24
25define <4 x float> @hsub_v4f32(<4 x float> %a) {
26; SSSE3-LABEL: hsub_v4f32:
27; SSSE3: # BB#0:
28; SSSE3-NEXT: hsubps %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +000029; SSSE3-NEXT: retq
30;
31; AVX-LABEL: hsub_v4f32:
32; AVX: # BB#0:
33; AVX-NEXT: vhsubps %xmm0, %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +000034; AVX-NEXT: retq
35 %a02 = shufflevector <4 x float> %a, <4 x float> undef, <2 x i32> <i32 0, i32 2>
36 %a13 = shufflevector <4 x float> %a, <4 x float> undef, <2 x i32> <i32 1, i32 3>
37 %hop = fsub <2 x float> %a02, %a13
38 %shuf = shufflevector <2 x float> %hop, <2 x float> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
39 ret <4 x float> %shuf
40}
41
42define <2 x double> @hadd_v2f64(<2 x double> %a) {
43; SSSE3-LABEL: hadd_v2f64:
44; SSSE3: # BB#0:
45; SSSE3-NEXT: haddpd %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +000046; SSSE3-NEXT: retq
47;
48; AVX-LABEL: hadd_v2f64:
49; AVX: # BB#0:
50; AVX-NEXT: vhaddpd %xmm0, %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +000051; AVX-NEXT: retq
52 %a0 = shufflevector <2 x double> %a, <2 x double> undef, <2 x i32> <i32 0, i32 undef>
53 %a1 = shufflevector <2 x double> %a, <2 x double> undef, <2 x i32> <i32 1, i32 undef>
54 %hop = fadd <2 x double> %a0, %a1
55 %shuf = shufflevector <2 x double> %hop, <2 x double> undef, <2 x i32> <i32 0, i32 0>
56 ret <2 x double> %shuf
57}
58
59define <2 x double> @hsub_v2f64(<2 x double> %a) {
60; SSSE3-LABEL: hsub_v2f64:
61; SSSE3: # BB#0:
62; SSSE3-NEXT: hsubpd %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +000063; SSSE3-NEXT: retq
64;
65; AVX-LABEL: hsub_v2f64:
66; AVX: # BB#0:
67; AVX-NEXT: vhsubpd %xmm0, %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +000068; AVX-NEXT: retq
69 %a0 = shufflevector <2 x double> %a, <2 x double> undef, <2 x i32> <i32 0, i32 undef>
70 %a1 = shufflevector <2 x double> %a, <2 x double> undef, <2 x i32> <i32 1, i32 undef>
71 %hop = fsub <2 x double> %a0, %a1
72 %shuf = shufflevector <2 x double> %hop, <2 x double> undef, <2 x i32> <i32 undef, i32 0>
73 ret <2 x double> %shuf
74}
75
76define <4 x i32> @hadd_v4i32(<4 x i32> %a) {
77; SSSE3-LABEL: hadd_v4i32:
78; SSSE3: # BB#0:
79; SSSE3-NEXT: phaddd %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +000080; SSSE3-NEXT: retq
81;
82; AVX-LABEL: hadd_v4i32:
83; AVX: # BB#0:
84; AVX-NEXT: vphaddd %xmm0, %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +000085; AVX-NEXT: retq
86 %a02 = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef>
87 %a13 = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef>
88 %hop = add <4 x i32> %a02, %a13
89 %shuf = shufflevector <4 x i32> %hop, <4 x i32> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 1>
90 ret <4 x i32> %shuf
91}
92
93define <4 x i32> @hsub_v4i32(<4 x i32> %a) {
94; SSSE3-LABEL: hsub_v4i32:
95; SSSE3: # BB#0:
96; SSSE3-NEXT: phsubd %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +000097; SSSE3-NEXT: retq
98;
99; AVX-LABEL: hsub_v4i32:
100; AVX: # BB#0:
101; AVX-NEXT: vphsubd %xmm0, %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +0000102; AVX-NEXT: retq
103 %a02 = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef>
104 %a13 = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef>
105 %hop = sub <4 x i32> %a02, %a13
106 %shuf = shufflevector <4 x i32> %hop, <4 x i32> undef, <4 x i32> <i32 undef, i32 1, i32 0, i32 undef>
107 ret <4 x i32> %shuf
108}
109
110define <8 x i16> @hadd_v8i16(<8 x i16> %a) {
111; SSSE3-LABEL: hadd_v8i16:
112; SSSE3: # BB#0:
113; SSSE3-NEXT: phaddw %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +0000114; SSSE3-NEXT: retq
115;
116; AVX-LABEL: hadd_v8i16:
117; AVX: # BB#0:
118; AVX-NEXT: vphaddw %xmm0, %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +0000119; AVX-NEXT: retq
120 %a0246 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 0, i32 2, i32 4, i32 6, i32 undef, i32 undef, i32 undef, i32 undef>
121 %a1357 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 1, i32 3, i32 5, i32 7, i32 undef, i32 undef, i32 undef, i32 undef>
122 %hop = add <8 x i16> %a0246, %a1357
123 %shuf = shufflevector <8 x i16> %hop, <8 x i16> undef, <8 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 0, i32 1, i32 2, i32 3>
124 ret <8 x i16> %shuf
125}
126
127define <8 x i16> @hsub_v8i16(<8 x i16> %a) {
128; SSSE3-LABEL: hsub_v8i16:
129; SSSE3: # BB#0:
130; SSSE3-NEXT: phsubw %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +0000131; SSSE3-NEXT: retq
132;
133; AVX-LABEL: hsub_v8i16:
134; AVX: # BB#0:
135; AVX-NEXT: vphsubw %xmm0, %xmm0, %xmm0
Sanjay Patel841acbb2017-08-31 20:59:25 +0000136; AVX-NEXT: retq
137 %a0246 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 0, i32 2, i32 4, i32 6, i32 undef, i32 undef, i32 undef, i32 undef>
138 %a1357 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 1, i32 3, i32 5, i32 7, i32 undef, i32 undef, i32 undef, i32 undef>
139 %hop = sub <8 x i16> %a0246, %a1357
140 %shuf = shufflevector <8 x i16> %hop, <8 x i16> undef, <8 x i32> <i32 0, i32 undef, i32 2, i32 undef, i32 undef, i32 1, i32 undef, i32 3>
141 ret <8 x i16> %shuf
142}
143