xref: /llvm-project/llvm/test/Transforms/InstCombine/X86/x86-pmaddubsw.ll (revision d893ed78718e25a982dcba9cdba2d78212b79353)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=instcombine -mtriple=x86_64-unknown-unknown -S | FileCheck %s
3
4;
5; UNDEF Elts
6;
7
8define <8 x i16> @undef_pmaddubsw_128(<16 x i8> %a0) {
9; CHECK-LABEL: @undef_pmaddubsw_128(
10; CHECK-NEXT:    ret <8 x i16> zeroinitializer
11;
12  %1 = call <8 x i16> @llvm.x86.ssse3.pmadd.ub.sw.128(<16 x i8> %a0, <16 x i8> undef)
13  ret <8 x i16> %1
14}
15
16define <8 x i16> @undef_pmaddubsw_128_commute(<16 x i8> %a0) {
17; CHECK-LABEL: @undef_pmaddubsw_128_commute(
18; CHECK-NEXT:    ret <8 x i16> zeroinitializer
19;
20  %1 = call <8 x i16> @llvm.x86.ssse3.pmadd.ub.sw.128(<16 x i8> undef, <16 x i8> %a0)
21  ret <8 x i16> %1
22}
23
24define <16 x i16> @undef_pmaddubsw_256(<32 x i8> %a0) {
25; CHECK-LABEL: @undef_pmaddubsw_256(
26; CHECK-NEXT:    ret <16 x i16> zeroinitializer
27;
28  %1 = call <16 x i16> @llvm.x86.avx2.pmadd.ub.sw(<32 x i8> %a0, <32 x i8> undef)
29  ret <16 x i16> %1
30}
31
32define <16 x i16> @undef_pmaddubsw_256_commute(<32 x i8> %a0) {
33; CHECK-LABEL: @undef_pmaddubsw_256_commute(
34; CHECK-NEXT:    ret <16 x i16> zeroinitializer
35;
36  %1 = call <16 x i16> @llvm.x86.avx2.pmadd.ub.sw(<32 x i8> undef, <32 x i8> %a0)
37  ret <16 x i16> %1
38}
39
40define <32 x i16> @undef_pmaddubsw_512(<64 x i8> %a0) {
41; CHECK-LABEL: @undef_pmaddubsw_512(
42; CHECK-NEXT:    ret <32 x i16> zeroinitializer
43;
44  %1 = call <32 x i16> @llvm.x86.avx512.pmaddubs.w.512(<64 x i8> %a0, <64 x i8> undef)
45  ret <32 x i16> %1
46}
47
48define <32 x i16> @undef_pmaddubsw_512_commute(<64 x i8> %a0) {
49; CHECK-LABEL: @undef_pmaddubsw_512_commute(
50; CHECK-NEXT:    ret <32 x i16> zeroinitializer
51;
52  %1 = call <32 x i16> @llvm.x86.avx512.pmaddubs.w.512(<64 x i8> undef, <64 x i8> %a0)
53  ret <32 x i16> %1
54}
55
56;
57; Zero Elts
58;
59
60define <8 x i16> @zero_pmaddubsw_128(<16 x i8> %a0) {
61; CHECK-LABEL: @zero_pmaddubsw_128(
62; CHECK-NEXT:    ret <8 x i16> zeroinitializer
63;
64  %1 = call <8 x i16> @llvm.x86.ssse3.pmadd.ub.sw.128(<16 x i8> %a0, <16 x i8> zeroinitializer)
65  ret <8 x i16> %1
66}
67
68define <8 x i16> @zero_pmaddubsw_128_commute(<16 x i8> %a0) {
69; CHECK-LABEL: @zero_pmaddubsw_128_commute(
70; CHECK-NEXT:    ret <8 x i16> zeroinitializer
71;
72  %1 = call <8 x i16> @llvm.x86.ssse3.pmadd.ub.sw.128(<16 x i8> zeroinitializer, <16 x i8> %a0)
73  ret <8 x i16> %1
74}
75
76define <16 x i16> @zero_pmaddubsw_256(<32 x i8>%a0) {
77; CHECK-LABEL: @zero_pmaddubsw_256(
78; CHECK-NEXT:    ret <16 x i16> zeroinitializer
79;
80  %1 = call <16 x i16> @llvm.x86.avx2.pmadd.ub.sw(<32 x i8> %a0, <32 x i8> zeroinitializer)
81  ret <16 x i16> %1
82}
83
84define <16 x i16> @zero_pmaddubsw_256_commute(<32 x i8> %a0) {
85; CHECK-LABEL: @zero_pmaddubsw_256_commute(
86; CHECK-NEXT:    ret <16 x i16> zeroinitializer
87;
88  %1 = call <16 x i16> @llvm.x86.avx2.pmadd.ub.sw(<32 x i8> zeroinitializer, <32 x i8> %a0)
89  ret <16 x i16> %1
90}
91
92define <32 x i16> @zero_pmaddubsw_512(<64 x i8> %a0) {
93; CHECK-LABEL: @zero_pmaddubsw_512(
94; CHECK-NEXT:    ret <32 x i16> zeroinitializer
95;
96  %1 = call <32 x i16> @llvm.x86.avx512.pmaddubs.w.512(<64 x i8> %a0, <64 x i8> zeroinitializer)
97  ret <32 x i16> %1
98}
99
100define <32 x i16> @zero_pmaddubsw_512_commute(<64 x i8> %a0) {
101; CHECK-LABEL: @zero_pmaddubsw_512_commute(
102; CHECK-NEXT:    ret <32 x i16> zeroinitializer
103;
104  %1 = call <32 x i16> @llvm.x86.avx512.pmaddubs.w.512(<64 x i8> zeroinitializer, <64 x i8> %a0)
105  ret <32 x i16> %1
106}
107
108;
109; Constant Folding
110;
111
112define <8 x i16> @fold_pmaddubsw_128() {
113; CHECK-LABEL: @fold_pmaddubsw_128(
114; CHECK-NEXT:    ret <8 x i16> <i16 -32768, i16 18, i16 50, i16 1694, i16 162, i16 242, i16 338, i16 450>
115;
116  %1 = call <8 x i16> @llvm.x86.ssse3.pmadd.ub.sw.128(<16 x i8> <i8 -1, i8 -1, i8 2, i8 3, i8 4, i8 5, i8 -6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8> <i8 -128, i8 -128, i8 3, i8 4, i8 5, i8 6, i8 7, i8 -8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 16>)
117  ret <8 x i16> %1
118}
119
120define <16 x i16> @fold_pmaddubsw_256() {
121; CHECK-LABEL: @fold_pmaddubsw_256(
122; CHECK-NEXT:    ret <16 x i16> <i16 -32768, i16 18, i16 50, i16 1694, i16 162, i16 242, i16 338, i16 450, i16 -256, i16 18, i16 50, i16 1694, i16 162, i16 242, i16 338, i16 450>
123;
124  %1 = call <16 x i16> @llvm.x86.avx2.pmadd.ub.sw(<32 x i8> <i8 -1, i8 -1, i8 2, i8 3, i8 4, i8 5, i8 -6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 -128, i8 -128, i8 3, i8 4, i8 5, i8 6, i8 7, i8 -8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 16>, <32 x i8> <i8 -128, i8 -128, i8 3, i8 4, i8 5, i8 6, i8 7, i8 -8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 16, i8 -1, i8 -1, i8 2, i8 3, i8 4, i8 5, i8 -6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>)
125  ret <16 x i16> %1
126}
127
128define <32 x i16> @fold_pmaddubsw_512() {
129; CHECK-LABEL: @fold_pmaddubsw_512(
130; CHECK-NEXT:    ret <32 x i16> <i16 -32768, i16 18, i16 50, i16 1694, i16 162, i16 242, i16 338, i16 450, i16 -256, i16 18, i16 50, i16 1694, i16 162, i16 242, i16 338, i16 450, i16 -256, i16 18, i16 50, i16 1694, i16 162, i16 242, i16 338, i16 450, i16 -32768, i16 18, i16 50, i16 1694, i16 162, i16 242, i16 338, i16 450>
131;
132  %1 = call <32 x i16> @llvm.x86.avx512.pmaddubs.w.512(<64 x i8> <i8 -1, i8 -1, i8 2, i8 3, i8 4, i8 5, i8 -6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 -128, i8 -128, i8 3, i8 4, i8 5, i8 6, i8 7, i8 -8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 16, i8 -128, i8 -128, i8 3, i8 4, i8 5, i8 6, i8 7, i8 -8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 16, i8 -1, i8 -1, i8 2, i8 3, i8 4, i8 5, i8 -6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <64 x i8> <i8 -128, i8 -128, i8 3, i8 4, i8 5, i8 6, i8 7, i8 -8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 16, i8 -1, i8 -1, i8 2, i8 3, i8 4, i8 5, i8 -6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 -1, i8 -1, i8 2, i8 3, i8 4, i8 5, i8 -6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 -128, i8 -128, i8 3, i8 4, i8 5, i8 6, i8 7, i8 -8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 16>)
133  ret <32 x i16> %1
134}
135
136;
137; Demanded Elts
138;
139
140define <8 x i16> @elts_pmaddubsw_128(<16 x i8> %a0, <16 x i8> %a1) {
141; CHECK-LABEL: @elts_pmaddubsw_128(
142; CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i16> @llvm.x86.ssse3.pmadd.ub.sw.128(<16 x i8> [[A0:%.*]], <16 x i8> [[A1:%.*]])
143; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <8 x i32> zeroinitializer
144; CHECK-NEXT:    ret <8 x i16> [[TMP2]]
145;
146  %1 = shufflevector <16 x i8> %a0, <16 x i8> undef, <16 x i32> <i32 0, i32 1, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
147  %2 = shufflevector <16 x i8> %a1, <16 x i8> undef, <16 x i32> <i32 0, i32 1, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
148  %3 = call <8 x i16> @llvm.x86.ssse3.pmadd.ub.sw.128(<16 x i8> %1, <16 x i8> %2)
149  %4 = shufflevector <8 x i16> %3, <8 x i16> poison, <8 x i32> zeroinitializer
150  ret <8 x i16> %4
151}
152
153define <16 x i16> @elts_pmaddubsw_256(<32 x i8> %a0, <32 x i8> %a1) {
154; CHECK-LABEL: @elts_pmaddubsw_256(
155; CHECK-NEXT:    [[TMP1:%.*]] = call <16 x i16> @llvm.x86.avx2.pmadd.ub.sw(<32 x i8> [[A0:%.*]], <32 x i8> [[A1:%.*]])
156; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <16 x i16> [[TMP1]], <16 x i16> poison, <16 x i32> zeroinitializer
157; CHECK-NEXT:    ret <16 x i16> [[TMP2]]
158;
159  %1 = shufflevector <32 x i8> %a0, <32 x i8> undef, <32 x i32> <i32 0, i32 1, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
160  %2 = shufflevector <32 x i8> %a1, <32 x i8> undef, <32 x i32> <i32 0, i32 1, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
161  %3 = call <16 x i16> @llvm.x86.avx2.pmadd.ub.sw(<32 x i8> %1, <32 x i8> %2)
162  %4 = shufflevector <16 x i16> %3, <16 x i16> poison, <16 x i32> zeroinitializer
163  ret <16 x i16> %4
164}
165
166define <32 x i16> @elts_pmaddubsw_512(<64 x i8> %a0, <64 x i8> %a1) {
167; CHECK-LABEL: @elts_pmaddubsw_512(
168; CHECK-NEXT:    [[TMP1:%.*]] = call <32 x i16> @llvm.x86.avx512.pmaddubs.w.512(<64 x i8> [[A0:%.*]], <64 x i8> [[A1:%.*]])
169; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <32 x i16> [[TMP1]], <32 x i16> poison, <32 x i32> zeroinitializer
170; CHECK-NEXT:    ret <32 x i16> [[TMP2]]
171;
172  %1 = shufflevector <64 x i8> %a0, <64 x i8> undef, <64 x i32> <i32 0, i32 1, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 63, i32 62, i32 61, i32 60, i32 59, i32 58, i32 57, i32 56, i32 55, i32 54, i32 53, i32 52, i32 51, i32 50, i32 49, i32 48, i32 47, i32 46, i32 45, i32 44, i32 43, i32 42, i32 41, i32 40, i32 39, i32 38, i32 37, i32 36, i32 35, i32 34, i32 33, i32 32>
173  %2 = shufflevector <64 x i8> %a1, <64 x i8> undef, <64 x i32> <i32 0, i32 1, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 63, i32 62, i32 61, i32 60, i32 59, i32 58, i32 57, i32 56, i32 55, i32 54, i32 53, i32 52, i32 51, i32 50, i32 49, i32 48, i32 47, i32 46, i32 45, i32 44, i32 43, i32 42, i32 41, i32 40, i32 39, i32 38, i32 37, i32 36, i32 35, i32 34, i32 33, i32 32>
174  %3 = call <32 x i16> @llvm.x86.avx512.pmaddubs.w.512(<64 x i8> %1, <64 x i8> %2)
175  %4 = shufflevector <32 x i16> %3, <32 x i16> poison, <32 x i32> zeroinitializer
176  ret <32 x i16> %4
177}
178