1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -disable-peephole -mtriple=i686-unknown-unknown -mattr=+avx,+xop | FileCheck %s --check-prefixes=CHECK,X86
3 ; RUN: llc < %s -disable-peephole -mtriple=x86_64-unknown-unknown -mattr=+avx,+xop | FileCheck %s --check-prefixes=CHECK,X64
5 define <16 x i8> @commute_fold_vpcomb(ptr %a0, <16 x i8> %a1) {
6 ; X86-LABEL: commute_fold_vpcomb:
8 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
9 ; X86-NEXT: vpcomgtb (%eax), %xmm0, %xmm0
12 ; X64-LABEL: commute_fold_vpcomb:
14 ; X64-NEXT: vpcomgtb (%rdi), %xmm0, %xmm0
16 %1 = load <16 x i8>, ptr %a0
17 %2 = call <16 x i8> @llvm.x86.xop.vpcomb(<16 x i8> %1, <16 x i8> %a1, i8 0) ; vpcomltb
20 declare <16 x i8> @llvm.x86.xop.vpcomb(<16 x i8>, <16 x i8>, i8) nounwind readnone
22 define <4 x i32> @commute_fold_vpcomd(ptr %a0, <4 x i32> %a1) {
23 ; X86-LABEL: commute_fold_vpcomd:
25 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
26 ; X86-NEXT: vpcomged (%eax), %xmm0, %xmm0
29 ; X64-LABEL: commute_fold_vpcomd:
31 ; X64-NEXT: vpcomged (%rdi), %xmm0, %xmm0
33 %1 = load <4 x i32>, ptr %a0
34 %2 = call <4 x i32> @llvm.x86.xop.vpcomd(<4 x i32> %1, <4 x i32> %a1, i8 1) ; vpcomled
37 declare <4 x i32> @llvm.x86.xop.vpcomd(<4 x i32>, <4 x i32>, i8) nounwind readnone
39 define <2 x i64> @commute_fold_vpcomq(ptr %a0, <2 x i64> %a1) {
40 ; X86-LABEL: commute_fold_vpcomq:
42 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
43 ; X86-NEXT: vpcomltq (%eax), %xmm0, %xmm0
46 ; X64-LABEL: commute_fold_vpcomq:
48 ; X64-NEXT: vpcomltq (%rdi), %xmm0, %xmm0
50 %1 = load <2 x i64>, ptr %a0
51 %2 = call <2 x i64> @llvm.x86.xop.vpcomq(<2 x i64> %1, <2 x i64> %a1, i8 2) ; vpcomgtq
54 declare <2 x i64> @llvm.x86.xop.vpcomq(<2 x i64>, <2 x i64>, i8) nounwind readnone
56 define <16 x i8> @commute_fold_vpcomub(ptr %a0, <16 x i8> %a1) {
57 ; X86-LABEL: commute_fold_vpcomub:
59 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
60 ; X86-NEXT: vpcomleub (%eax), %xmm0, %xmm0
63 ; X64-LABEL: commute_fold_vpcomub:
65 ; X64-NEXT: vpcomleub (%rdi), %xmm0, %xmm0
67 %1 = load <16 x i8>, ptr %a0
68 %2 = call <16 x i8> @llvm.x86.xop.vpcomub(<16 x i8> %1, <16 x i8> %a1, i8 3) ; vpcomgeub
71 declare <16 x i8> @llvm.x86.xop.vpcomub(<16 x i8>, <16 x i8>, i8) nounwind readnone
73 define <4 x i32> @commute_fold_vpcomud(ptr %a0, <4 x i32> %a1) {
74 ; X86-LABEL: commute_fold_vpcomud:
76 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
77 ; X86-NEXT: vpcomeqd (%eax), %xmm0, %xmm0
80 ; X64-LABEL: commute_fold_vpcomud:
82 ; X64-NEXT: vpcomeqd (%rdi), %xmm0, %xmm0
84 %1 = load <4 x i32>, ptr %a0
85 %2 = call <4 x i32> @llvm.x86.xop.vpcomud(<4 x i32> %1, <4 x i32> %a1, i8 4) ; vpcomequd
88 declare <4 x i32> @llvm.x86.xop.vpcomud(<4 x i32>, <4 x i32>, i8) nounwind readnone
90 define <2 x i64> @commute_fold_vpcomuq(ptr %a0, <2 x i64> %a1) {
91 ; X86-LABEL: commute_fold_vpcomuq:
93 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
94 ; X86-NEXT: vpcomneqq (%eax), %xmm0, %xmm0
97 ; X64-LABEL: commute_fold_vpcomuq:
99 ; X64-NEXT: vpcomneqq (%rdi), %xmm0, %xmm0
101 %1 = load <2 x i64>, ptr %a0
102 %2 = call <2 x i64> @llvm.x86.xop.vpcomuq(<2 x i64> %1, <2 x i64> %a1, i8 5) ; vpcomnequq
105 declare <2 x i64> @llvm.x86.xop.vpcomuq(<2 x i64>, <2 x i64>, i8) nounwind readnone
107 define <8 x i16> @commute_fold_vpcomuw(ptr %a0, <8 x i16> %a1) {
108 ; CHECK-LABEL: commute_fold_vpcomuw:
110 ; CHECK-NEXT: vxorps %xmm0, %xmm0, %xmm0
111 ; CHECK-NEXT: ret{{[l|q]}}
112 %1 = load <8 x i16>, ptr %a0
113 %2 = call <8 x i16> @llvm.x86.xop.vpcomuw(<8 x i16> %1, <8 x i16> %a1, i8 6) ; vpcomfalseuw
116 declare <8 x i16> @llvm.x86.xop.vpcomuw(<8 x i16>, <8 x i16>, i8) nounwind readnone
118 define <8 x i16> @commute_fold_vpcomw(ptr %a0, <8 x i16> %a1) {
119 ; CHECK-LABEL: commute_fold_vpcomw:
121 ; CHECK-NEXT: vpcmpeqd %xmm0, %xmm0, %xmm0
122 ; CHECK-NEXT: ret{{[l|q]}}
123 %1 = load <8 x i16>, ptr %a0
124 %2 = call <8 x i16> @llvm.x86.xop.vpcomw(<8 x i16> %1, <8 x i16> %a1, i8 7) ; vpcomtruew
127 declare <8 x i16> @llvm.x86.xop.vpcomw(<8 x i16>, <8 x i16>, i8) nounwind readnone
129 define <4 x i32> @commute_fold_vpmacsdd(ptr %a0, <4 x i32> %a1, <4 x i32> %a2) {
130 ; X86-LABEL: commute_fold_vpmacsdd:
132 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
133 ; X86-NEXT: vpmacsdd %xmm1, (%eax), %xmm0, %xmm0
136 ; X64-LABEL: commute_fold_vpmacsdd:
138 ; X64-NEXT: vpmacsdd %xmm1, (%rdi), %xmm0, %xmm0
140 %1 = load <4 x i32>, ptr %a0
141 %2 = call <4 x i32> @llvm.x86.xop.vpmacsdd(<4 x i32> %1, <4 x i32> %a1, <4 x i32> %a2)
144 declare <4 x i32> @llvm.x86.xop.vpmacsdd(<4 x i32>, <4 x i32>, <4 x i32>) nounwind readnone
146 define <2 x i64> @commute_fold_vpmacsdqh(ptr %a0, <4 x i32> %a1, <2 x i64> %a2) {
147 ; X86-LABEL: commute_fold_vpmacsdqh:
149 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
150 ; X86-NEXT: vpmacsdqh %xmm1, (%eax), %xmm0, %xmm0
153 ; X64-LABEL: commute_fold_vpmacsdqh:
155 ; X64-NEXT: vpmacsdqh %xmm1, (%rdi), %xmm0, %xmm0
157 %1 = load <4 x i32>, ptr %a0
158 %2 = call <2 x i64> @llvm.x86.xop.vpmacsdqh(<4 x i32> %1, <4 x i32> %a1, <2 x i64> %a2)
161 declare <2 x i64> @llvm.x86.xop.vpmacsdqh(<4 x i32>, <4 x i32>, <2 x i64>) nounwind readnone
163 define <2 x i64> @commute_fold_vpmacsdql(ptr %a0, <4 x i32> %a1, <2 x i64> %a2) {
164 ; X86-LABEL: commute_fold_vpmacsdql:
166 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
167 ; X86-NEXT: vpmacsdql %xmm1, (%eax), %xmm0, %xmm0
170 ; X64-LABEL: commute_fold_vpmacsdql:
172 ; X64-NEXT: vpmacsdql %xmm1, (%rdi), %xmm0, %xmm0
174 %1 = load <4 x i32>, ptr %a0
175 %2 = call <2 x i64> @llvm.x86.xop.vpmacsdql(<4 x i32> %1, <4 x i32> %a1, <2 x i64> %a2)
178 declare <2 x i64> @llvm.x86.xop.vpmacsdql(<4 x i32>, <4 x i32>, <2 x i64>) nounwind readnone
180 define <4 x i32> @commute_fold_vpmacssdd(ptr %a0, <4 x i32> %a1, <4 x i32> %a2) {
181 ; X86-LABEL: commute_fold_vpmacssdd:
183 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
184 ; X86-NEXT: vpmacssdd %xmm1, (%eax), %xmm0, %xmm0
187 ; X64-LABEL: commute_fold_vpmacssdd:
189 ; X64-NEXT: vpmacssdd %xmm1, (%rdi), %xmm0, %xmm0
191 %1 = load <4 x i32>, ptr %a0
192 %2 = call <4 x i32> @llvm.x86.xop.vpmacssdd(<4 x i32> %1, <4 x i32> %a1, <4 x i32> %a2)
195 declare <4 x i32> @llvm.x86.xop.vpmacssdd(<4 x i32>, <4 x i32>, <4 x i32>) nounwind readnone
197 define <2 x i64> @commute_fold_vpmacssdqh(ptr %a0, <4 x i32> %a1, <2 x i64> %a2) {
198 ; X86-LABEL: commute_fold_vpmacssdqh:
200 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
201 ; X86-NEXT: vpmacssdqh %xmm1, (%eax), %xmm0, %xmm0
204 ; X64-LABEL: commute_fold_vpmacssdqh:
206 ; X64-NEXT: vpmacssdqh %xmm1, (%rdi), %xmm0, %xmm0
208 %1 = load <4 x i32>, ptr %a0
209 %2 = call <2 x i64> @llvm.x86.xop.vpmacssdqh(<4 x i32> %1, <4 x i32> %a1, <2 x i64> %a2)
212 declare <2 x i64> @llvm.x86.xop.vpmacssdqh(<4 x i32>, <4 x i32>, <2 x i64>) nounwind readnone
214 define <2 x i64> @commute_fold_vpmacssdql(ptr %a0, <4 x i32> %a1, <2 x i64> %a2) {
215 ; X86-LABEL: commute_fold_vpmacssdql:
217 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
218 ; X86-NEXT: vpmacssdql %xmm1, (%eax), %xmm0, %xmm0
221 ; X64-LABEL: commute_fold_vpmacssdql:
223 ; X64-NEXT: vpmacssdql %xmm1, (%rdi), %xmm0, %xmm0
225 %1 = load <4 x i32>, ptr %a0
226 %2 = call <2 x i64> @llvm.x86.xop.vpmacssdql(<4 x i32> %1, <4 x i32> %a1, <2 x i64> %a2)
229 declare <2 x i64> @llvm.x86.xop.vpmacssdql(<4 x i32>, <4 x i32>, <2 x i64>) nounwind readnone
231 define <4 x i32> @commute_fold_vpmacsswd(ptr %a0, <8 x i16> %a1, <4 x i32> %a2) {
232 ; X86-LABEL: commute_fold_vpmacsswd:
234 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
235 ; X86-NEXT: vpmacsswd %xmm1, (%eax), %xmm0, %xmm0
238 ; X64-LABEL: commute_fold_vpmacsswd:
240 ; X64-NEXT: vpmacsswd %xmm1, (%rdi), %xmm0, %xmm0
242 %1 = load <8 x i16>, ptr %a0
243 %2 = call <4 x i32> @llvm.x86.xop.vpmacsswd(<8 x i16> %1, <8 x i16> %a1, <4 x i32> %a2)
246 declare <4 x i32> @llvm.x86.xop.vpmacsswd(<8 x i16>, <8 x i16>, <4 x i32>) nounwind readnone
248 define <8 x i16> @commute_fold_vpmacssww(ptr %a0, <8 x i16> %a1, <8 x i16> %a2) {
249 ; X86-LABEL: commute_fold_vpmacssww:
251 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
252 ; X86-NEXT: vpmacssww %xmm1, (%eax), %xmm0, %xmm0
255 ; X64-LABEL: commute_fold_vpmacssww:
257 ; X64-NEXT: vpmacssww %xmm1, (%rdi), %xmm0, %xmm0
259 %1 = load <8 x i16>, ptr %a0
260 %2 = call <8 x i16> @llvm.x86.xop.vpmacssww(<8 x i16> %1, <8 x i16> %a1, <8 x i16> %a2)
263 declare <8 x i16> @llvm.x86.xop.vpmacssww(<8 x i16>, <8 x i16>, <8 x i16>) nounwind readnone
265 define <4 x i32> @commute_fold_vpmacswd(ptr %a0, <8 x i16> %a1, <4 x i32> %a2) {
266 ; X86-LABEL: commute_fold_vpmacswd:
268 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
269 ; X86-NEXT: vpmacswd %xmm1, (%eax), %xmm0, %xmm0
272 ; X64-LABEL: commute_fold_vpmacswd:
274 ; X64-NEXT: vpmacswd %xmm1, (%rdi), %xmm0, %xmm0
276 %1 = load <8 x i16>, ptr %a0
277 %2 = call <4 x i32> @llvm.x86.xop.vpmacswd(<8 x i16> %1, <8 x i16> %a1, <4 x i32> %a2)
280 declare <4 x i32> @llvm.x86.xop.vpmacswd(<8 x i16>, <8 x i16>, <4 x i32>) nounwind readnone
282 define <8 x i16> @commute_fold_vpmacsww(ptr %a0, <8 x i16> %a1, <8 x i16> %a2) {
283 ; X86-LABEL: commute_fold_vpmacsww:
285 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
286 ; X86-NEXT: vpmacsww %xmm1, (%eax), %xmm0, %xmm0
289 ; X64-LABEL: commute_fold_vpmacsww:
291 ; X64-NEXT: vpmacsww %xmm1, (%rdi), %xmm0, %xmm0
293 %1 = load <8 x i16>, ptr %a0
294 %2 = call <8 x i16> @llvm.x86.xop.vpmacsww(<8 x i16> %1, <8 x i16> %a1, <8 x i16> %a2)
297 declare <8 x i16> @llvm.x86.xop.vpmacsww(<8 x i16>, <8 x i16>, <8 x i16>) nounwind readnone
299 define <4 x i32> @commute_fold_vpmadcsswd(ptr %a0, <8 x i16> %a1, <4 x i32> %a2) {
300 ; X86-LABEL: commute_fold_vpmadcsswd:
302 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
303 ; X86-NEXT: vpmadcsswd %xmm1, (%eax), %xmm0, %xmm0
306 ; X64-LABEL: commute_fold_vpmadcsswd:
308 ; X64-NEXT: vpmadcsswd %xmm1, (%rdi), %xmm0, %xmm0
310 %1 = load <8 x i16>, ptr %a0
311 %2 = call <4 x i32> @llvm.x86.xop.vpmadcsswd(<8 x i16> %1, <8 x i16> %a1, <4 x i32> %a2)
314 declare <4 x i32> @llvm.x86.xop.vpmadcsswd(<8 x i16>, <8 x i16>, <4 x i32>) nounwind readnone
316 define <4 x i32> @commute_fold_vpmadcswd(ptr %a0, <8 x i16> %a1, <4 x i32> %a2) {
317 ; X86-LABEL: commute_fold_vpmadcswd:
319 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
320 ; X86-NEXT: vpmadcswd %xmm1, (%eax), %xmm0, %xmm0
323 ; X64-LABEL: commute_fold_vpmadcswd:
325 ; X64-NEXT: vpmadcswd %xmm1, (%rdi), %xmm0, %xmm0
327 %1 = load <8 x i16>, ptr %a0
328 %2 = call <4 x i32> @llvm.x86.xop.vpmadcswd(<8 x i16> %1, <8 x i16> %a1, <4 x i32> %a2)
331 declare <4 x i32> @llvm.x86.xop.vpmadcswd(<8 x i16>, <8 x i16>, <4 x i32>) nounwind readnone