[DAGCombiner] Eliminate dead stores to stack.
[llvm-complete.git] / test / CodeGen / X86 / avx2-phaddsub.ll
blob99cdb100e3f2a44556a58f9882ae6aaee5c9ba45
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686--   -mattr=+avx2           | FileCheck %s --check-prefixes=X32,X32-SLOW
3 ; RUN: llc < %s -mtriple=i686--   -mattr=+avx2,fast-hops | FileCheck %s --check-prefixes=X32,X32-FAST
4 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx2           | FileCheck %s --check-prefixes=X64,X64-SLOW
5 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx2,fast-hops | FileCheck %s --check-prefixes=X64,X64-FAST
7 define <16 x i16> @phaddw1(<16 x i16> %x, <16 x i16> %y) {
8 ; X32-LABEL: phaddw1:
9 ; X32:       # %bb.0:
10 ; X32-NEXT:    vphaddw %ymm1, %ymm0, %ymm0
11 ; X32-NEXT:    retl
13 ; X64-LABEL: phaddw1:
14 ; X64:       # %bb.0:
15 ; X64-NEXT:    vphaddw %ymm1, %ymm0, %ymm0
16 ; X64-NEXT:    retq
17   %a = shufflevector <16 x i16> %x, <16 x i16> %y, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 8, i32 10, i32 12, i32 14, i32 24, i32 26, i32 28, i32 30>
18   %b = shufflevector <16 x i16> %x, <16 x i16> %y, <16 x i32> <i32 1, i32 3, i32 5, i32 7, i32 17, i32 19, i32 21, i32 23, i32 9, i32 11, i32 13, i32 15, i32 25, i32 27, i32 29, i32 31>
19   %r = add <16 x i16> %a, %b
20   ret <16 x i16> %r
23 define <16 x i16> @phaddw2(<16 x i16> %x, <16 x i16> %y) {
24 ; X32-LABEL: phaddw2:
25 ; X32:       # %bb.0:
26 ; X32-NEXT:    vphaddw %ymm1, %ymm0, %ymm0
27 ; X32-NEXT:    retl
29 ; X64-LABEL: phaddw2:
30 ; X64:       # %bb.0:
31 ; X64-NEXT:    vphaddw %ymm1, %ymm0, %ymm0
32 ; X64-NEXT:    retq
33   %a = shufflevector <16 x i16> %x, <16 x i16> %y, <16 x i32> <i32 1, i32 3, i32 5, i32 7, i32 17, i32 19, i32 21, i32 23, i32 9, i32 11, i32 13, i32 15, i32 25, i32 27, i32 29, i32 31>
34   %b = shufflevector <16 x i16> %y, <16 x i16> %x, <16 x i32> <i32 16, i32 18, i32 20, i32 22, i32 0, i32 2, i32 4, i32 6, i32 24, i32 26, i32 28, i32 30, i32 8, i32 10, i32 12, i32 14>
35   %r = add <16 x i16> %a, %b
36   ret <16 x i16> %r
39 define <8 x i32> @phaddd1(<8 x i32> %x, <8 x i32> %y) {
40 ; X32-LABEL: phaddd1:
41 ; X32:       # %bb.0:
42 ; X32-NEXT:    vphaddd %ymm1, %ymm0, %ymm0
43 ; X32-NEXT:    retl
45 ; X64-LABEL: phaddd1:
46 ; X64:       # %bb.0:
47 ; X64-NEXT:    vphaddd %ymm1, %ymm0, %ymm0
48 ; X64-NEXT:    retq
49   %a = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 0, i32 2, i32 8, i32 10, i32 4, i32 6, i32 12, i32 14>
50   %b = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 1, i32 3, i32 9, i32 11, i32 5, i32 7, i32 13, i32 15>
51   %r = add <8 x i32> %a, %b
52   ret <8 x i32> %r
55 define <8 x i32> @phaddd2(<8 x i32> %x, <8 x i32> %y) {
56 ; X32-LABEL: phaddd2:
57 ; X32:       # %bb.0:
58 ; X32-NEXT:    vphaddd %ymm1, %ymm0, %ymm0
59 ; X32-NEXT:    retl
61 ; X64-LABEL: phaddd2:
62 ; X64:       # %bb.0:
63 ; X64-NEXT:    vphaddd %ymm1, %ymm0, %ymm0
64 ; X64-NEXT:    retq
65   %a = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 1, i32 2, i32 9, i32 10, i32 5, i32 6, i32 13, i32 14>
66   %b = shufflevector <8 x i32> %y, <8 x i32> %x, <8 x i32> <i32 8, i32 11, i32 0, i32 3, i32 12, i32 15, i32 4, i32 7>
67   %r = add <8 x i32> %a, %b
68   ret <8 x i32> %r
71 define <8 x i32> @phaddd3(<8 x i32> %x) {
72 ; X32-SLOW-LABEL: phaddd3:
73 ; X32-SLOW:       # %bb.0:
74 ; X32-SLOW-NEXT:    vpshufd {{.*#+}} ymm1 = ymm0[0,2,2,3,4,6,6,7]
75 ; X32-SLOW-NEXT:    vpshufd {{.*#+}} ymm0 = ymm0[1,3,2,3,5,7,6,7]
76 ; X32-SLOW-NEXT:    vpaddd %ymm0, %ymm1, %ymm0
77 ; X32-SLOW-NEXT:    retl
79 ; X32-FAST-LABEL: phaddd3:
80 ; X32-FAST:       # %bb.0:
81 ; X32-FAST-NEXT:    vphaddd %ymm0, %ymm0, %ymm0
82 ; X32-FAST-NEXT:    retl
84 ; X64-SLOW-LABEL: phaddd3:
85 ; X64-SLOW:       # %bb.0:
86 ; X64-SLOW-NEXT:    vpshufd {{.*#+}} ymm1 = ymm0[0,2,2,3,4,6,6,7]
87 ; X64-SLOW-NEXT:    vpshufd {{.*#+}} ymm0 = ymm0[1,3,2,3,5,7,6,7]
88 ; X64-SLOW-NEXT:    vpaddd %ymm0, %ymm1, %ymm0
89 ; X64-SLOW-NEXT:    retq
91 ; X64-FAST-LABEL: phaddd3:
92 ; X64-FAST:       # %bb.0:
93 ; X64-FAST-NEXT:    vphaddd %ymm0, %ymm0, %ymm0
94 ; X64-FAST-NEXT:    retq
95   %a = shufflevector <8 x i32> %x, <8 x i32> undef, <8 x i32> <i32 undef, i32 2, i32 8, i32 10, i32 4, i32 6, i32 undef, i32 14>
96   %b = shufflevector <8 x i32> %x, <8 x i32> undef, <8 x i32> <i32 1, i32 3, i32 9, i32 undef, i32 5, i32 7, i32 13, i32 15>
97   %r = add <8 x i32> %a, %b
98   ret <8 x i32> %r
101 define <16 x i16> @phsubw1(<16 x i16> %x, <16 x i16> %y) {
102 ; X32-LABEL: phsubw1:
103 ; X32:       # %bb.0:
104 ; X32-NEXT:    vphsubw %ymm1, %ymm0, %ymm0
105 ; X32-NEXT:    retl
107 ; X64-LABEL: phsubw1:
108 ; X64:       # %bb.0:
109 ; X64-NEXT:    vphsubw %ymm1, %ymm0, %ymm0
110 ; X64-NEXT:    retq
111   %a = shufflevector <16 x i16> %x, <16 x i16> %y, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 8, i32 10, i32 12, i32 14, i32 24, i32 26, i32 28, i32 30>
112   %b = shufflevector <16 x i16> %x, <16 x i16> %y, <16 x i32> <i32 1, i32 3, i32 5, i32 7, i32 17, i32 19, i32 21, i32 23, i32 9, i32 11, i32 13, i32 15, i32 25, i32 27, i32 29, i32 31>
113   %r = sub <16 x i16> %a, %b
114   ret <16 x i16> %r
117 define <8 x i32> @phsubd1(<8 x i32> %x, <8 x i32> %y) {
118 ; X32-LABEL: phsubd1:
119 ; X32:       # %bb.0:
120 ; X32-NEXT:    vphsubd %ymm1, %ymm0, %ymm0
121 ; X32-NEXT:    retl
123 ; X64-LABEL: phsubd1:
124 ; X64:       # %bb.0:
125 ; X64-NEXT:    vphsubd %ymm1, %ymm0, %ymm0
126 ; X64-NEXT:    retq
127   %a = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 0, i32 2, i32 8, i32 10, i32 4, i32 6, i32 12, i32 14>
128   %b = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 1, i32 3, i32 9, i32 11, i32 5, i32 7, i32 13, i32 15>
129   %r = sub <8 x i32> %a, %b
130   ret <8 x i32> %r
133 define <8 x i32> @phsubd2(<8 x i32> %x, <8 x i32> %y) {
134 ; X32-LABEL: phsubd2:
135 ; X32:       # %bb.0:
136 ; X32-NEXT:    vphsubd %ymm1, %ymm0, %ymm0
137 ; X32-NEXT:    retl
139 ; X64-LABEL: phsubd2:
140 ; X64:       # %bb.0:
141 ; X64-NEXT:    vphsubd %ymm1, %ymm0, %ymm0
142 ; X64-NEXT:    retq
143   %a = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 0, i32 undef, i32 8, i32 undef, i32 4, i32 6, i32 12, i32 14>
144   %b = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 1, i32 undef, i32 9, i32 11, i32 5, i32 7, i32 undef, i32 15>
145   %r = sub <8 x i32> %a, %b
146   ret <8 x i32> %r