blob: b7024bc876684aa40e64618f234807ec2af0baff [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//====- X86InstrMMX.td - Describe the X86 Instruction Set --*- tablegen -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Evan Cheng and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 MMX instruction set, defining the instructions,
11// and properties of the instructions which are needed for code generation,
12// machine code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
Dan Gohmanf17a25c2007-07-18 16:29:46 +000016// Some 'special' instructions
Evan Chengb783fa32007-07-19 01:14:50 +000017def IMPLICIT_DEF_VR64 : I<0, Pseudo, (outs VR64:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018 "#IMPLICIT_DEF $dst",
19 [(set VR64:$dst, (v8i8 (undef)))]>,
20 Requires<[HasMMX]>;
21
22// 64-bit vector undef's.
23def : Pat<(v8i8 (undef)), (IMPLICIT_DEF_VR64)>;
24def : Pat<(v4i16 (undef)), (IMPLICIT_DEF_VR64)>;
25def : Pat<(v2i32 (undef)), (IMPLICIT_DEF_VR64)>;
26def : Pat<(v1i64 (undef)), (IMPLICIT_DEF_VR64)>;
27
28//===----------------------------------------------------------------------===//
29// MMX Pattern Fragments
30//===----------------------------------------------------------------------===//
31
32def load_mmx : PatFrag<(ops node:$ptr), (v1i64 (load node:$ptr))>;
33
34def bc_v8i8 : PatFrag<(ops node:$in), (v8i8 (bitconvert node:$in))>;
35def bc_v4i16 : PatFrag<(ops node:$in), (v4i16 (bitconvert node:$in))>;
36def bc_v2i32 : PatFrag<(ops node:$in), (v2i32 (bitconvert node:$in))>;
37def bc_v1i64 : PatFrag<(ops node:$in), (v1i64 (bitconvert node:$in))>;
38
39//===----------------------------------------------------------------------===//
40// MMX Masks
41//===----------------------------------------------------------------------===//
42
43// MMX_SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to
44// PSHUFW imm.
45def MMX_SHUFFLE_get_shuf_imm : SDNodeXForm<build_vector, [{
46 return getI8Imm(X86::getShuffleSHUFImmediate(N));
47}]>;
48
49// Patterns for: vector_shuffle v1, v2, <2, 6, 3, 7, ...>
50def MMX_UNPCKH_shuffle_mask : PatLeaf<(build_vector), [{
51 return X86::isUNPCKHMask(N);
52}]>;
53
54// Patterns for: vector_shuffle v1, v2, <0, 4, 2, 5, ...>
55def MMX_UNPCKL_shuffle_mask : PatLeaf<(build_vector), [{
56 return X86::isUNPCKLMask(N);
57}]>;
58
59// Patterns for: vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
60def MMX_UNPCKH_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
61 return X86::isUNPCKH_v_undef_Mask(N);
62}]>;
63
64// Patterns for: vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
65def MMX_UNPCKL_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
66 return X86::isUNPCKL_v_undef_Mask(N);
67}]>;
68
69// Patterns for shuffling.
70def MMX_PSHUFW_shuffle_mask : PatLeaf<(build_vector), [{
71 return X86::isPSHUFDMask(N);
72}], MMX_SHUFFLE_get_shuf_imm>;
73
74// Patterns for: vector_shuffle v1, v2, <4, 5, 2, 3>; etc.
75def MMX_MOVL_shuffle_mask : PatLeaf<(build_vector), [{
76 return X86::isMOVLMask(N);
77}]>;
78
79//===----------------------------------------------------------------------===//
80// MMX Multiclasses
81//===----------------------------------------------------------------------===//
82
83let isTwoAddress = 1 in {
84 // MMXI_binop_rm - Simple MMX binary operator.
85 multiclass MMXI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
86 ValueType OpVT, bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +000087 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000088 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000089 [(set VR64:$dst, (OpVT (OpNode VR64:$src1, VR64:$src2)))]> {
90 let isCommutable = Commutable;
91 }
Evan Chengb783fa32007-07-19 01:14:50 +000092 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000093 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000094 [(set VR64:$dst, (OpVT (OpNode VR64:$src1,
95 (bitconvert
96 (load_mmx addr:$src2)))))]>;
97 }
98
99 multiclass MMXI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
100 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +0000101 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000102 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000103 [(set VR64:$dst, (IntId VR64:$src1, VR64:$src2))]> {
104 let isCommutable = Commutable;
105 }
Evan Chengb783fa32007-07-19 01:14:50 +0000106 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000107 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000108 [(set VR64:$dst, (IntId VR64:$src1,
109 (bitconvert (load_mmx addr:$src2))))]>;
110 }
111
112 // MMXI_binop_rm_v1i64 - Simple MMX binary operator whose type is v1i64.
113 //
114 // FIXME: we could eliminate this and use MMXI_binop_rm instead if tblgen knew
115 // to collapse (bitconvert VT to VT) into its operand.
116 //
117 multiclass MMXI_binop_rm_v1i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
118 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +0000119 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000120 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000121 [(set VR64:$dst, (v1i64 (OpNode VR64:$src1, VR64:$src2)))]> {
122 let isCommutable = Commutable;
123 }
Evan Chengb783fa32007-07-19 01:14:50 +0000124 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000125 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126 [(set VR64:$dst,
127 (OpNode VR64:$src1,(load_mmx addr:$src2)))]>;
128 }
129
130 multiclass MMXI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
131 string OpcodeStr, Intrinsic IntId> {
Evan Chengb783fa32007-07-19 01:14:50 +0000132 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000133 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000134 [(set VR64:$dst, (IntId VR64:$src1, VR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000135 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000136 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000137 [(set VR64:$dst, (IntId VR64:$src1,
138 (bitconvert (load_mmx addr:$src2))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000139 def ri : MMXIi8<opc2, ImmForm, (outs VR64:$dst), (ins VR64:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000140 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000141 [(set VR64:$dst, (IntId VR64:$src1,
142 (scalar_to_vector (i32 imm:$src2))))]>;
143 }
144}
145
146//===----------------------------------------------------------------------===//
147// MMX EMMS & FEMMS Instructions
148//===----------------------------------------------------------------------===//
149
Evan Chengb783fa32007-07-19 01:14:50 +0000150def MMX_EMMS : MMXI<0x77, RawFrm, (outs), (ins), "emms", [(int_x86_mmx_emms)]>;
151def MMX_FEMMS : MMXI<0x0E, RawFrm, (outs), (ins), "femms", [(int_x86_mmx_femms)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152
153//===----------------------------------------------------------------------===//
154// MMX Scalar Instructions
155//===----------------------------------------------------------------------===//
156
157// Data Transfer Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000158def MMX_MOVD64rr : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000159 "movd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000160let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000161def MMX_MOVD64rm : MMXI<0x6E, MRMSrcMem, (outs VR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000162 "movd\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000163def MMX_MOVD64mr : MMXI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000164 "movd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000165
Evan Chengb783fa32007-07-19 01:14:50 +0000166def MMX_MOVD64to64rr : MMXRI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000167 "movd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000168
Evan Chengb783fa32007-07-19 01:14:50 +0000169def MMX_MOVQ64rr : MMXI<0x6F, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000170 "movq\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000171let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000172def MMX_MOVQ64rm : MMXI<0x6F, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000173 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000174 [(set VR64:$dst, (load_mmx addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000175def MMX_MOVQ64mr : MMXI<0x7F, MRMDestMem, (outs), (ins i64mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000176 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177 [(store (v1i64 VR64:$src), addr:$dst)]>;
178
Evan Chengb783fa32007-07-19 01:14:50 +0000179def MMX_MOVDQ2Qrr : MMXID<0xD6, MRMDestMem, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000180 "movdq2q\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181 [(set VR64:$dst,
182 (v1i64 (vector_extract (v2i64 VR128:$src),
183 (iPTR 0))))]>;
184
Evan Chengb783fa32007-07-19 01:14:50 +0000185def MMX_MOVQ2DQrr : MMXIS<0xD6, MRMDestMem, (outs VR128:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000186 "movq2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187 [(set VR128:$dst,
188 (bitconvert (v1i64 VR64:$src)))]>;
189
Evan Chengb783fa32007-07-19 01:14:50 +0000190def MMX_MOVNTQmr : MMXI<0xE7, MRMDestMem, (outs), (ins i64mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000191 "movntq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192 [(int_x86_mmx_movnt_dq addr:$dst, VR64:$src)]>;
193
194let AddedComplexity = 15 in
195// movd to MMX register zero-extends
Evan Chengb783fa32007-07-19 01:14:50 +0000196def MMX_MOVZDI2PDIrr : MMX2I<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000197 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198 [(set VR64:$dst,
199 (v2i32 (vector_shuffle immAllZerosV,
200 (v2i32 (scalar_to_vector GR32:$src)),
201 MMX_MOVL_shuffle_mask)))]>;
202let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +0000203def MMX_MOVZDI2PDIrm : MMX2I<0x6E, MRMSrcMem, (outs VR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000204 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000205 [(set VR64:$dst,
206 (v2i32 (vector_shuffle immAllZerosV,
207 (v2i32 (scalar_to_vector
208 (loadi32 addr:$src))),
209 MMX_MOVL_shuffle_mask)))]>;
210
211// Arithmetic Instructions
212
213// -- Addition
214defm MMX_PADDB : MMXI_binop_rm<0xFC, "paddb", add, v8i8, 1>;
215defm MMX_PADDW : MMXI_binop_rm<0xFD, "paddw", add, v4i16, 1>;
216defm MMX_PADDD : MMXI_binop_rm<0xFE, "paddd", add, v2i32, 1>;
217defm MMX_PADDQ : MMXI_binop_rm<0xD4, "paddq", add, v1i64, 1>;
218
219defm MMX_PADDSB : MMXI_binop_rm_int<0xEC, "paddsb" , int_x86_mmx_padds_b, 1>;
220defm MMX_PADDSW : MMXI_binop_rm_int<0xED, "paddsw" , int_x86_mmx_padds_w, 1>;
221
222defm MMX_PADDUSB : MMXI_binop_rm_int<0xDC, "paddusb", int_x86_mmx_paddus_b, 1>;
223defm MMX_PADDUSW : MMXI_binop_rm_int<0xDD, "paddusw", int_x86_mmx_paddus_w, 1>;
224
225// -- Subtraction
226defm MMX_PSUBB : MMXI_binop_rm<0xF8, "psubb", sub, v8i8>;
227defm MMX_PSUBW : MMXI_binop_rm<0xF9, "psubw", sub, v4i16>;
228defm MMX_PSUBD : MMXI_binop_rm<0xFA, "psubd", sub, v2i32>;
229defm MMX_PSUBQ : MMXI_binop_rm<0xFB, "psubq", sub, v1i64>;
230
231defm MMX_PSUBSB : MMXI_binop_rm_int<0xE8, "psubsb" , int_x86_mmx_psubs_b>;
232defm MMX_PSUBSW : MMXI_binop_rm_int<0xE9, "psubsw" , int_x86_mmx_psubs_w>;
233
234defm MMX_PSUBUSB : MMXI_binop_rm_int<0xD8, "psubusb", int_x86_mmx_psubus_b>;
235defm MMX_PSUBUSW : MMXI_binop_rm_int<0xD9, "psubusw", int_x86_mmx_psubus_w>;
236
237// -- Multiplication
238defm MMX_PMULLW : MMXI_binop_rm<0xD5, "pmullw", mul, v4i16, 1>;
239
240defm MMX_PMULHW : MMXI_binop_rm_int<0xE5, "pmulhw", int_x86_mmx_pmulh_w, 1>;
241defm MMX_PMULHUW : MMXI_binop_rm_int<0xE4, "pmulhuw", int_x86_mmx_pmulhu_w, 1>;
242defm MMX_PMULUDQ : MMXI_binop_rm_int<0xF4, "pmuludq", int_x86_mmx_pmulu_dq, 1>;
243
244// -- Miscellanea
245defm MMX_PMADDWD : MMXI_binop_rm_int<0xF5, "pmaddwd", int_x86_mmx_pmadd_wd, 1>;
246
247defm MMX_PAVGB : MMXI_binop_rm_int<0xE0, "pavgb", int_x86_mmx_pavg_b, 1>;
248defm MMX_PAVGW : MMXI_binop_rm_int<0xE3, "pavgw", int_x86_mmx_pavg_w, 1>;
249
250defm MMX_PMINUB : MMXI_binop_rm_int<0xDA, "pminub", int_x86_mmx_pminu_b, 1>;
251defm MMX_PMINSW : MMXI_binop_rm_int<0xEA, "pminsw", int_x86_mmx_pmins_w, 1>;
252
253defm MMX_PMAXUB : MMXI_binop_rm_int<0xDE, "pmaxub", int_x86_mmx_pmaxu_b, 1>;
254defm MMX_PMAXSW : MMXI_binop_rm_int<0xEE, "pmaxsw", int_x86_mmx_pmaxs_w, 1>;
255
256defm MMX_PSADBW : MMXI_binop_rm_int<0xE0, "psadbw", int_x86_mmx_psad_bw, 1>;
257
258// Logical Instructions
259defm MMX_PAND : MMXI_binop_rm_v1i64<0xDB, "pand", and, 1>;
260defm MMX_POR : MMXI_binop_rm_v1i64<0xEB, "por" , or, 1>;
261defm MMX_PXOR : MMXI_binop_rm_v1i64<0xEF, "pxor", xor, 1>;
262
263let isTwoAddress = 1 in {
264 def MMX_PANDNrr : MMXI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000265 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000266 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000267 [(set VR64:$dst, (v1i64 (and (vnot VR64:$src1),
268 VR64:$src2)))]>;
269 def MMX_PANDNrm : MMXI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000270 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000271 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272 [(set VR64:$dst, (v1i64 (and (vnot VR64:$src1),
273 (load addr:$src2))))]>;
274}
275
276// Shift Instructions
277defm MMX_PSRLW : MMXI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
278 int_x86_mmx_psrl_w>;
279defm MMX_PSRLD : MMXI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
280 int_x86_mmx_psrl_d>;
281defm MMX_PSRLQ : MMXI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
282 int_x86_mmx_psrl_q>;
283
284defm MMX_PSLLW : MMXI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
285 int_x86_mmx_psll_w>;
286defm MMX_PSLLD : MMXI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
287 int_x86_mmx_psll_d>;
288defm MMX_PSLLQ : MMXI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
289 int_x86_mmx_psll_q>;
290
291defm MMX_PSRAW : MMXI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
292 int_x86_mmx_psra_w>;
293defm MMX_PSRAD : MMXI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
294 int_x86_mmx_psra_d>;
295
296// Comparison Instructions
297defm MMX_PCMPEQB : MMXI_binop_rm_int<0x74, "pcmpeqb", int_x86_mmx_pcmpeq_b>;
298defm MMX_PCMPEQW : MMXI_binop_rm_int<0x75, "pcmpeqw", int_x86_mmx_pcmpeq_w>;
299defm MMX_PCMPEQD : MMXI_binop_rm_int<0x76, "pcmpeqd", int_x86_mmx_pcmpeq_d>;
300
301defm MMX_PCMPGTB : MMXI_binop_rm_int<0x64, "pcmpgtb", int_x86_mmx_pcmpgt_b>;
302defm MMX_PCMPGTW : MMXI_binop_rm_int<0x65, "pcmpgtw", int_x86_mmx_pcmpgt_w>;
303defm MMX_PCMPGTD : MMXI_binop_rm_int<0x66, "pcmpgtd", int_x86_mmx_pcmpgt_d>;
304
305// Conversion Instructions
306
307// -- Unpack Instructions
308let isTwoAddress = 1 in {
309 // Unpack High Packed Data Instructions
310 def MMX_PUNPCKHBWrr : MMXI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000311 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000312 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 [(set VR64:$dst,
314 (v8i8 (vector_shuffle VR64:$src1, VR64:$src2,
315 MMX_UNPCKH_shuffle_mask)))]>;
316 def MMX_PUNPCKHBWrm : MMXI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000317 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000318 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319 [(set VR64:$dst,
320 (v8i8 (vector_shuffle VR64:$src1,
321 (bc_v8i8 (load_mmx addr:$src2)),
322 MMX_UNPCKH_shuffle_mask)))]>;
323
324 def MMX_PUNPCKHWDrr : MMXI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000325 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000326 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327 [(set VR64:$dst,
328 (v4i16 (vector_shuffle VR64:$src1, VR64:$src2,
329 MMX_UNPCKH_shuffle_mask)))]>;
330 def MMX_PUNPCKHWDrm : MMXI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000331 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000332 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333 [(set VR64:$dst,
334 (v4i16 (vector_shuffle VR64:$src1,
335 (bc_v4i16 (load_mmx addr:$src2)),
336 MMX_UNPCKH_shuffle_mask)))]>;
337
338 def MMX_PUNPCKHDQrr : MMXI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000339 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000340 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341 [(set VR64:$dst,
342 (v2i32 (vector_shuffle VR64:$src1, VR64:$src2,
343 MMX_UNPCKH_shuffle_mask)))]>;
344 def MMX_PUNPCKHDQrm : MMXI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000345 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000346 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000347 [(set VR64:$dst,
348 (v2i32 (vector_shuffle VR64:$src1,
349 (bc_v2i32 (load_mmx addr:$src2)),
350 MMX_UNPCKH_shuffle_mask)))]>;
351
352 // Unpack Low Packed Data Instructions
353 def MMX_PUNPCKLBWrr : MMXI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000354 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000355 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356 [(set VR64:$dst,
357 (v8i8 (vector_shuffle VR64:$src1, VR64:$src2,
358 MMX_UNPCKL_shuffle_mask)))]>;
359 def MMX_PUNPCKLBWrm : MMXI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000360 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000361 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000362 [(set VR64:$dst,
363 (v8i8 (vector_shuffle VR64:$src1,
364 (bc_v8i8 (load_mmx addr:$src2)),
365 MMX_UNPCKL_shuffle_mask)))]>;
366
367 def MMX_PUNPCKLWDrr : MMXI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000368 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000369 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000370 [(set VR64:$dst,
371 (v4i16 (vector_shuffle VR64:$src1, VR64:$src2,
372 MMX_UNPCKL_shuffle_mask)))]>;
373 def MMX_PUNPCKLWDrm : MMXI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000374 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000375 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376 [(set VR64:$dst,
377 (v4i16 (vector_shuffle VR64:$src1,
378 (bc_v4i16 (load_mmx addr:$src2)),
379 MMX_UNPCKL_shuffle_mask)))]>;
380
381 def MMX_PUNPCKLDQrr : MMXI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000382 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000383 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384 [(set VR64:$dst,
385 (v2i32 (vector_shuffle VR64:$src1, VR64:$src2,
386 MMX_UNPCKL_shuffle_mask)))]>;
387 def MMX_PUNPCKLDQrm : MMXI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000388 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000389 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390 [(set VR64:$dst,
391 (v2i32 (vector_shuffle VR64:$src1,
392 (bc_v2i32 (load_mmx addr:$src2)),
393 MMX_UNPCKL_shuffle_mask)))]>;
394}
395
396// -- Pack Instructions
397defm MMX_PACKSSWB : MMXI_binop_rm_int<0x63, "packsswb", int_x86_mmx_packsswb>;
398defm MMX_PACKSSDW : MMXI_binop_rm_int<0x6B, "packssdw", int_x86_mmx_packssdw>;
399defm MMX_PACKUSWB : MMXI_binop_rm_int<0x67, "packuswb", int_x86_mmx_packuswb>;
400
401// -- Shuffle Instructions
402def MMX_PSHUFWri : MMXIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000403 (outs VR64:$dst), (ins VR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000404 "pshufw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405 [(set VR64:$dst,
406 (v4i16 (vector_shuffle
407 VR64:$src1, (undef),
408 MMX_PSHUFW_shuffle_mask:$src2)))]>;
409def MMX_PSHUFWmi : MMXIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000410 (outs VR64:$dst), (ins i64mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000411 "pshufw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412 [(set VR64:$dst,
413 (v4i16 (vector_shuffle
414 (bc_v4i16 (load_mmx addr:$src1)),
415 (undef),
416 MMX_PSHUFW_shuffle_mask:$src2)))]>;
417
418// -- Conversion Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000419def MMX_CVTPD2PIrr : MMX2I<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000420 "cvtpd2pi\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000421def MMX_CVTPD2PIrm : MMX2I<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000422 "cvtpd2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423
Evan Chengb783fa32007-07-19 01:14:50 +0000424def MMX_CVTPI2PDrr : MMX2I<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000425 "cvtpi2pd\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000426def MMX_CVTPI2PDrm : MMX2I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000427 "cvtpi2pd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000428
Evan Chengb783fa32007-07-19 01:14:50 +0000429def MMX_CVTPI2PSrr : MMXI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000430 "cvtpi2ps\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000431def MMX_CVTPI2PSrm : MMXI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000432 "cvtpi2ps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000433
Evan Chengb783fa32007-07-19 01:14:50 +0000434def MMX_CVTPS2PIrr : MMXI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000435 "cvtps2pi\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000436def MMX_CVTPS2PIrm : MMXI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000437 "cvtps2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000438
Evan Chengb783fa32007-07-19 01:14:50 +0000439def MMX_CVTTPD2PIrr : MMX2I<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000440 "cvttpd2pi\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000441def MMX_CVTTPD2PIrm : MMX2I<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000442 "cvttpd2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000443
Evan Chengb783fa32007-07-19 01:14:50 +0000444def MMX_CVTTPS2PIrr : MMXI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000445 "cvttps2pi\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000446def MMX_CVTTPS2PIrm : MMXI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000447 "cvttps2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000448
449// Extract / Insert
450def MMX_X86pextrw : SDNode<"X86ISD::PEXTRW", SDTypeProfile<1, 2, []>, []>;
451def MMX_X86pinsrw : SDNode<"X86ISD::PINSRW", SDTypeProfile<1, 3, []>, []>;
452
453def MMX_PEXTRWri : MMXIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000454 (outs GR32:$dst), (ins VR64:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000455 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456 [(set GR32:$dst, (MMX_X86pextrw (v4i16 VR64:$src1),
457 (iPTR imm:$src2)))]>;
458let isTwoAddress = 1 in {
459 def MMX_PINSRWrri : MMXIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000460 (outs VR64:$dst), (ins VR64:$src1, GR32:$src2, i16i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000461 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000462 [(set VR64:$dst, (v4i16 (MMX_X86pinsrw (v4i16 VR64:$src1),
463 GR32:$src2, (iPTR imm:$src3))))]>;
464 def MMX_PINSRWrmi : MMXIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000465 (outs VR64:$dst), (ins VR64:$src1, i16mem:$src2, i16i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000466 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000467 [(set VR64:$dst,
468 (v4i16 (MMX_X86pinsrw (v4i16 VR64:$src1),
469 (i32 (anyext (loadi16 addr:$src2))),
470 (iPTR imm:$src3))))]>;
471}
472
473// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000474def MMX_PMOVMSKBrr : MMXI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000475 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476 [(set GR32:$dst, (int_x86_mmx_pmovmskb VR64:$src))]>;
477
478// Misc.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000479let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000480def MMX_MASKMOVQ : MMXI<0xF7, MRMDestMem, (outs), (ins VR64:$src, VR64:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +0000481 "maskmovq\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000482 [(int_x86_mmx_maskmovq VR64:$src, VR64:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483
484//===----------------------------------------------------------------------===//
485// Alias Instructions
486//===----------------------------------------------------------------------===//
487
488// Alias instructions that map zero vector to pxor.
489// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
490let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000491 def MMX_V_SET0 : MMXI<0xEF, MRMInitReg, (outs VR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000492 "pxor\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000493 [(set VR64:$dst, (v1i64 immAllZerosV))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000494 def MMX_V_SETALLONES : MMXI<0x76, MRMInitReg, (outs VR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000495 "pcmpeqd\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000496 [(set VR64:$dst, (v1i64 immAllOnesV))]>;
497}
498
499//===----------------------------------------------------------------------===//
500// Non-Instruction Patterns
501//===----------------------------------------------------------------------===//
502
503// Store 64-bit integer vector values.
504def : Pat<(store (v8i8 VR64:$src), addr:$dst),
505 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
506def : Pat<(store (v4i16 VR64:$src), addr:$dst),
507 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
508def : Pat<(store (v2i32 VR64:$src), addr:$dst),
509 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
510def : Pat<(store (v1i64 VR64:$src), addr:$dst),
511 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
512
513// 64-bit vector all zero's.
514def : Pat<(v8i8 immAllZerosV), (MMX_V_SET0)>;
515def : Pat<(v4i16 immAllZerosV), (MMX_V_SET0)>;
516def : Pat<(v2i32 immAllZerosV), (MMX_V_SET0)>;
517def : Pat<(v1i64 immAllZerosV), (MMX_V_SET0)>;
518
519// 64-bit vector all one's.
520def : Pat<(v8i8 immAllOnesV), (MMX_V_SETALLONES)>;
521def : Pat<(v4i16 immAllOnesV), (MMX_V_SETALLONES)>;
522def : Pat<(v2i32 immAllOnesV), (MMX_V_SETALLONES)>;
523def : Pat<(v1i64 immAllOnesV), (MMX_V_SETALLONES)>;
524
525// Bit convert.
526def : Pat<(v8i8 (bitconvert (v1i64 VR64:$src))), (v8i8 VR64:$src)>;
527def : Pat<(v8i8 (bitconvert (v2i32 VR64:$src))), (v8i8 VR64:$src)>;
528def : Pat<(v8i8 (bitconvert (v4i16 VR64:$src))), (v8i8 VR64:$src)>;
529def : Pat<(v4i16 (bitconvert (v1i64 VR64:$src))), (v4i16 VR64:$src)>;
530def : Pat<(v4i16 (bitconvert (v2i32 VR64:$src))), (v4i16 VR64:$src)>;
531def : Pat<(v4i16 (bitconvert (v8i8 VR64:$src))), (v4i16 VR64:$src)>;
532def : Pat<(v2i32 (bitconvert (v1i64 VR64:$src))), (v2i32 VR64:$src)>;
533def : Pat<(v2i32 (bitconvert (v4i16 VR64:$src))), (v2i32 VR64:$src)>;
534def : Pat<(v2i32 (bitconvert (v8i8 VR64:$src))), (v2i32 VR64:$src)>;
535def : Pat<(v1i64 (bitconvert (v2i32 VR64:$src))), (v1i64 VR64:$src)>;
536def : Pat<(v1i64 (bitconvert (v4i16 VR64:$src))), (v1i64 VR64:$src)>;
537def : Pat<(v1i64 (bitconvert (v8i8 VR64:$src))), (v1i64 VR64:$src)>;
538
539// 64-bit bit convert.
540def : Pat<(v1i64 (bitconvert (i64 GR64:$src))),
541 (MMX_MOVD64to64rr GR64:$src)>;
542def : Pat<(v2i32 (bitconvert (i64 GR64:$src))),
543 (MMX_MOVD64to64rr GR64:$src)>;
544def : Pat<(v4i16 (bitconvert (i64 GR64:$src))),
545 (MMX_MOVD64to64rr GR64:$src)>;
546def : Pat<(v8i8 (bitconvert (i64 GR64:$src))),
547 (MMX_MOVD64to64rr GR64:$src)>;
548
549def MMX_X86s2vec : SDNode<"X86ISD::S2VEC", SDTypeProfile<1, 1, []>, []>;
550
551// Move scalar to XMM zero-extended
552// movd to XMM register zero-extends
553let AddedComplexity = 15 in {
554 def : Pat<(v8i8 (vector_shuffle immAllZerosV,
555 (v8i8 (MMX_X86s2vec GR32:$src)), MMX_MOVL_shuffle_mask)),
556 (MMX_MOVZDI2PDIrr GR32:$src)>;
557 def : Pat<(v4i16 (vector_shuffle immAllZerosV,
558 (v4i16 (MMX_X86s2vec GR32:$src)), MMX_MOVL_shuffle_mask)),
559 (MMX_MOVZDI2PDIrr GR32:$src)>;
560 def : Pat<(v2i32 (vector_shuffle immAllZerosV,
561 (v2i32 (MMX_X86s2vec GR32:$src)), MMX_MOVL_shuffle_mask)),
562 (MMX_MOVZDI2PDIrr GR32:$src)>;
563}
564
565// Scalar to v2i32 / v4i16 / v8i8. The source may be a GR32, but only the lower
566// 8 or 16-bits matter.
567def : Pat<(v8i8 (MMX_X86s2vec GR32:$src)), (MMX_MOVD64rr GR32:$src)>;
568def : Pat<(v4i16 (MMX_X86s2vec GR32:$src)), (MMX_MOVD64rr GR32:$src)>;
569def : Pat<(v2i32 (MMX_X86s2vec GR32:$src)), (MMX_MOVD64rr GR32:$src)>;
570
571// Patterns to perform canonical versions of vector shuffling.
572let AddedComplexity = 10 in {
573 def : Pat<(v8i8 (vector_shuffle VR64:$src, (undef),
574 MMX_UNPCKL_v_undef_shuffle_mask)),
575 (MMX_PUNPCKLBWrr VR64:$src, VR64:$src)>;
576 def : Pat<(v4i16 (vector_shuffle VR64:$src, (undef),
577 MMX_UNPCKL_v_undef_shuffle_mask)),
578 (MMX_PUNPCKLWDrr VR64:$src, VR64:$src)>;
579 def : Pat<(v2i32 (vector_shuffle VR64:$src, (undef),
580 MMX_UNPCKL_v_undef_shuffle_mask)),
581 (MMX_PUNPCKLDQrr VR64:$src, VR64:$src)>;
582}
583
584let AddedComplexity = 10 in {
585 def : Pat<(v8i8 (vector_shuffle VR64:$src, (undef),
586 MMX_UNPCKH_v_undef_shuffle_mask)),
587 (MMX_PUNPCKHBWrr VR64:$src, VR64:$src)>;
588 def : Pat<(v4i16 (vector_shuffle VR64:$src, (undef),
589 MMX_UNPCKH_v_undef_shuffle_mask)),
590 (MMX_PUNPCKHWDrr VR64:$src, VR64:$src)>;
591 def : Pat<(v2i32 (vector_shuffle VR64:$src, (undef),
592 MMX_UNPCKH_v_undef_shuffle_mask)),
593 (MMX_PUNPCKHDQrr VR64:$src, VR64:$src)>;
594}
595
596// Patterns to perform vector shuffling with a zeroed out vector.
597let AddedComplexity = 20 in {
598 def : Pat<(bc_v2i32 (vector_shuffle immAllZerosV,
599 (v2i32 (scalar_to_vector (load_mmx addr:$src))),
600 MMX_UNPCKL_shuffle_mask)),
601 (MMX_PUNPCKLDQrm VR64:$src, VR64:$src)>;
602}
603
604// Some special case PANDN patterns.
605// FIXME: Get rid of these.
606def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v2i32 immAllOnesV))),
607 VR64:$src2)),
608 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
609def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v4i16 immAllOnesV))),
610 VR64:$src2)),
611 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
612def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v8i8 immAllOnesV))),
613 VR64:$src2)),
614 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
615
616def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v2i32 immAllOnesV))),
617 (load addr:$src2))),
618 (MMX_PANDNrm VR64:$src1, addr:$src2)>;
619def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v4i16 immAllOnesV))),
620 (load addr:$src2))),
621 (MMX_PANDNrm VR64:$src1, addr:$src2)>;
622def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v8i8 immAllOnesV))),
623 (load addr:$src2))),
624 (MMX_PANDNrm VR64:$src1, addr:$src2)>;