1 //====- X86InstrSSE.td - Describe the X86 Instruction Set -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Evan Cheng and is distributed under the University
6 // of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the X86 SSE instruction set, defining the instructions,
11 // and properties of the instructions which are needed for code generation,
12 // machine code emission, and analysis.
14 //===----------------------------------------------------------------------===//
17 //===----------------------------------------------------------------------===//
18 // SSE specific DAG Nodes.
19 //===----------------------------------------------------------------------===//
21 def SDTX86FPShiftOp : SDTypeProfile<1, 2, [ SDTCisSameAs<0, 1>,
22 SDTCisFP<0>, SDTCisInt<2> ]>;
24 def X86fmin : SDNode<"X86ISD::FMIN", SDTFPBinOp>;
25 def X86fmax : SDNode<"X86ISD::FMAX", SDTFPBinOp>;
26 def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
27 [SDNPCommutative, SDNPAssociative]>;
28 def X86for : SDNode<"X86ISD::FOR", SDTFPBinOp,
29 [SDNPCommutative, SDNPAssociative]>;
30 def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
31 [SDNPCommutative, SDNPAssociative]>;
32 def X86frsqrt : SDNode<"X86ISD::FRSQRT", SDTFPUnaryOp>;
33 def X86frcp : SDNode<"X86ISD::FRCP", SDTFPUnaryOp>;
34 def X86fsrl : SDNode<"X86ISD::FSRL", SDTX86FPShiftOp>;
35 def X86comi : SDNode<"X86ISD::COMI", SDTX86CmpTest,
36 [SDNPHasChain, SDNPOutFlag]>;
37 def X86ucomi : SDNode<"X86ISD::UCOMI", SDTX86CmpTest,
38 [SDNPHasChain, SDNPOutFlag]>;
39 def X86s2vec : SDNode<"X86ISD::S2VEC", SDTypeProfile<1, 1, []>, []>;
40 def X86pextrw : SDNode<"X86ISD::PEXTRW", SDTypeProfile<1, 2, []>, []>;
41 def X86pinsrw : SDNode<"X86ISD::PINSRW", SDTypeProfile<1, 3, []>, []>;
43 //===----------------------------------------------------------------------===//
44 // SSE 'Special' Instructions
45 //===----------------------------------------------------------------------===//
47 def IMPLICIT_DEF_VR128 : I<0, Pseudo, (outs VR128:$dst), (ins),
49 [(set VR128:$dst, (v4f32 (undef)))]>,
51 def IMPLICIT_DEF_FR32 : I<0, Pseudo, (outs FR32:$dst), (ins),
53 [(set FR32:$dst, (undef))]>, Requires<[HasSSE2]>;
54 def IMPLICIT_DEF_FR64 : I<0, Pseudo, (outs FR64:$dst), (ins),
56 [(set FR64:$dst, (undef))]>, Requires<[HasSSE2]>;
58 //===----------------------------------------------------------------------===//
59 // SSE Complex Patterns
60 //===----------------------------------------------------------------------===//
62 // These are 'extloads' from a scalar to the low element of a vector, zeroing
63 // the top elements. These are used for the SSE 'ss' and 'sd' instruction
65 def sse_load_f32 : ComplexPattern<v4f32, 4, "SelectScalarSSELoad", [],
67 def sse_load_f64 : ComplexPattern<v2f64, 4, "SelectScalarSSELoad", [],
70 def ssmem : Operand<v4f32> {
71 let PrintMethod = "printf32mem";
72 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
74 def sdmem : Operand<v2f64> {
75 let PrintMethod = "printf64mem";
76 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
79 //===----------------------------------------------------------------------===//
80 // SSE pattern fragments
81 //===----------------------------------------------------------------------===//
83 def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
84 def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
85 def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
86 def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
88 // Like 'store', but always requires vector alignment.
89 def alignedstore : PatFrag<(ops node:$val, node:$ptr),
90 (st node:$val, node:$ptr), [{
91 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
92 return !ST->isTruncatingStore() &&
93 ST->getAddressingMode() == ISD::UNINDEXED &&
94 ST->getAlignment() >= 16;
98 // Like 'load', but always requires vector alignment.
99 def alignedload : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
100 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
101 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
102 LD->getAddressingMode() == ISD::UNINDEXED &&
103 LD->getAlignment() >= 16;
107 def alignedloadfsf32 : PatFrag<(ops node:$ptr), (f32 (alignedload node:$ptr))>;
108 def alignedloadfsf64 : PatFrag<(ops node:$ptr), (f64 (alignedload node:$ptr))>;
109 def alignedloadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (alignedload node:$ptr))>;
110 def alignedloadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (alignedload node:$ptr))>;
111 def alignedloadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (alignedload node:$ptr))>;
112 def alignedloadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (alignedload node:$ptr))>;
114 // Like 'load', but uses special alignment checks suitable for use in
115 // memory operands in most SSE instructions, which are required to
116 // be naturally aligned on some targets but not on others.
117 // FIXME: Actually implement support for targets that don't require the
118 // alignment. This probably wants a subtarget predicate.
119 def memop : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
120 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
121 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
122 LD->getAddressingMode() == ISD::UNINDEXED &&
123 LD->getAlignment() >= 16;
127 def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
128 def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
129 def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
130 def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
131 def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop node:$ptr))>;
132 def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
133 def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop node:$ptr))>;
134 def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop node:$ptr))>;
135 def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop node:$ptr))>;
136 def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
137 def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
139 def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
140 def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
141 def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
142 def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
143 def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
144 def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
146 def fp32imm0 : PatLeaf<(f32 fpimm), [{
147 return N->isExactlyValue(+0.0);
150 def PSxLDQ_imm : SDNodeXForm<imm, [{
151 // Transformation function: imm >> 3
152 return getI32Imm(N->getValue() >> 3);
155 // SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
157 def SHUFFLE_get_shuf_imm : SDNodeXForm<build_vector, [{
158 return getI8Imm(X86::getShuffleSHUFImmediate(N));
161 // SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
163 def SHUFFLE_get_pshufhw_imm : SDNodeXForm<build_vector, [{
164 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
167 // SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
169 def SHUFFLE_get_pshuflw_imm : SDNodeXForm<build_vector, [{
170 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
173 def SSE_splat_mask : PatLeaf<(build_vector), [{
174 return X86::isSplatMask(N);
175 }], SHUFFLE_get_shuf_imm>;
177 def SSE_splat_lo_mask : PatLeaf<(build_vector), [{
178 return X86::isSplatLoMask(N);
181 def MOVHLPS_shuffle_mask : PatLeaf<(build_vector), [{
182 return X86::isMOVHLPSMask(N);
185 def MOVHLPS_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
186 return X86::isMOVHLPS_v_undef_Mask(N);
189 def MOVHP_shuffle_mask : PatLeaf<(build_vector), [{
190 return X86::isMOVHPMask(N);
193 def MOVLP_shuffle_mask : PatLeaf<(build_vector), [{
194 return X86::isMOVLPMask(N);
197 def MOVL_shuffle_mask : PatLeaf<(build_vector), [{
198 return X86::isMOVLMask(N);
201 def MOVSHDUP_shuffle_mask : PatLeaf<(build_vector), [{
202 return X86::isMOVSHDUPMask(N);
205 def MOVSLDUP_shuffle_mask : PatLeaf<(build_vector), [{
206 return X86::isMOVSLDUPMask(N);
209 def UNPCKL_shuffle_mask : PatLeaf<(build_vector), [{
210 return X86::isUNPCKLMask(N);
213 def UNPCKH_shuffle_mask : PatLeaf<(build_vector), [{
214 return X86::isUNPCKHMask(N);
217 def UNPCKL_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
218 return X86::isUNPCKL_v_undef_Mask(N);
221 def UNPCKH_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
222 return X86::isUNPCKH_v_undef_Mask(N);
225 def PSHUFD_shuffle_mask : PatLeaf<(build_vector), [{
226 return X86::isPSHUFDMask(N);
227 }], SHUFFLE_get_shuf_imm>;
229 def PSHUFHW_shuffle_mask : PatLeaf<(build_vector), [{
230 return X86::isPSHUFHWMask(N);
231 }], SHUFFLE_get_pshufhw_imm>;
233 def PSHUFLW_shuffle_mask : PatLeaf<(build_vector), [{
234 return X86::isPSHUFLWMask(N);
235 }], SHUFFLE_get_pshuflw_imm>;
237 def SHUFP_unary_shuffle_mask : PatLeaf<(build_vector), [{
238 return X86::isPSHUFDMask(N);
239 }], SHUFFLE_get_shuf_imm>;
241 def SHUFP_shuffle_mask : PatLeaf<(build_vector), [{
242 return X86::isSHUFPMask(N);
243 }], SHUFFLE_get_shuf_imm>;
245 def PSHUFD_binary_shuffle_mask : PatLeaf<(build_vector), [{
246 return X86::isSHUFPMask(N);
247 }], SHUFFLE_get_shuf_imm>;
249 //===----------------------------------------------------------------------===//
250 // SSE scalar FP Instructions
251 //===----------------------------------------------------------------------===//
253 // CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
254 // scheduler into a branch sequence.
255 let usesCustomDAGSchedInserter = 1 in { // Expanded by the scheduler.
256 def CMOV_FR32 : I<0, Pseudo,
257 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
258 "#CMOV_FR32 PSEUDO!",
259 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond))]>;
260 def CMOV_FR64 : I<0, Pseudo,
261 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
262 "#CMOV_FR64 PSEUDO!",
263 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond))]>;
264 def CMOV_V4F32 : I<0, Pseudo,
265 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
266 "#CMOV_V4F32 PSEUDO!",
268 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond)))]>;
269 def CMOV_V2F64 : I<0, Pseudo,
270 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
271 "#CMOV_V2F64 PSEUDO!",
273 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond)))]>;
274 def CMOV_V2I64 : I<0, Pseudo,
275 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
276 "#CMOV_V2I64 PSEUDO!",
278 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond)))]>;
281 //===----------------------------------------------------------------------===//
283 //===----------------------------------------------------------------------===//
286 def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
287 "movss\t{$src, $dst|$dst, $src}", []>;
288 let isReMaterializable = 1 in
289 def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
290 "movss\t{$src, $dst|$dst, $src}",
291 [(set FR32:$dst, (loadf32 addr:$src))]>;
292 def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
293 "movss\t{$src, $dst|$dst, $src}",
294 [(store FR32:$src, addr:$dst)]>;
296 // Conversion instructions
297 def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
298 "cvttss2si\t{$src, $dst|$dst, $src}",
299 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
300 def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
301 "cvttss2si\t{$src, $dst|$dst, $src}",
302 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
303 def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
304 "cvtsi2ss\t{$src, $dst|$dst, $src}",
305 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
306 def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
307 "cvtsi2ss\t{$src, $dst|$dst, $src}",
308 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
310 // Match intrinsics which expect XMM operand(s).
311 def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
312 "cvtss2si\t{$src, $dst|$dst, $src}",
313 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
314 def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
315 "cvtss2si\t{$src, $dst|$dst, $src}",
316 [(set GR32:$dst, (int_x86_sse_cvtss2si
317 (load addr:$src)))]>;
319 // Aliases for intrinsics
320 def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
321 "cvttss2si\t{$src, $dst|$dst, $src}",
323 (int_x86_sse_cvttss2si VR128:$src))]>;
324 def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
325 "cvttss2si\t{$src, $dst|$dst, $src}",
327 (int_x86_sse_cvttss2si(load addr:$src)))]>;
329 let isTwoAddress = 1 in {
330 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
331 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
332 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
333 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
335 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
336 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
337 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
338 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
339 (loadi32 addr:$src2)))]>;
342 // Comparison instructions
343 let isTwoAddress = 1 in {
344 def CMPSSrr : SSI<0xC2, MRMSrcReg,
345 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
346 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
347 def CMPSSrm : SSI<0xC2, MRMSrcMem,
348 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
349 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
352 def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
353 "ucomiss\t{$src2, $src1|$src1, $src2}",
354 [(X86cmp FR32:$src1, FR32:$src2)]>;
355 def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
356 "ucomiss\t{$src2, $src1|$src1, $src2}",
357 [(X86cmp FR32:$src1, (loadf32 addr:$src2))]>;
359 // Aliases to match intrinsics which expect XMM operand(s).
360 let isTwoAddress = 1 in {
361 def Int_CMPSSrr : SSI<0xC2, MRMSrcReg,
362 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
363 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
364 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
365 VR128:$src, imm:$cc))]>;
366 def Int_CMPSSrm : SSI<0xC2, MRMSrcMem,
367 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src, SSECC:$cc),
368 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
369 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
370 (load addr:$src), imm:$cc))]>;
373 def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
374 "ucomiss\t{$src2, $src1|$src1, $src2}",
375 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2)]>;
376 def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
377 "ucomiss\t{$src2, $src1|$src1, $src2}",
378 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2))]>;
380 def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
381 "comiss\t{$src2, $src1|$src1, $src2}",
382 [(X86comi (v4f32 VR128:$src1), VR128:$src2)]>;
383 def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
384 "comiss\t{$src2, $src1|$src1, $src2}",
385 [(X86comi (v4f32 VR128:$src1), (load addr:$src2))]>;
387 // Aliases of packed SSE1 instructions for scalar use. These all have names that
390 // Alias instructions that map fld0 to pxor for sse.
391 def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
392 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
393 Requires<[HasSSE1]>, TB, OpSize;
395 // Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
397 def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
398 "movaps\t{$src, $dst|$dst, $src}", []>;
400 // Alias instruction to load FR32 from f128mem using movaps. Upper bits are
402 def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
403 "movaps\t{$src, $dst|$dst, $src}",
404 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
406 // Alias bitwise logical operations using SSE logical ops on packed FP values.
407 let isTwoAddress = 1 in {
408 let isCommutable = 1 in {
409 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
410 "andps\t{$src2, $dst|$dst, $src2}",
411 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
412 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
413 "orps\t{$src2, $dst|$dst, $src2}",
414 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
415 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
416 "xorps\t{$src2, $dst|$dst, $src2}",
417 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
420 def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
421 "andps\t{$src2, $dst|$dst, $src2}",
422 [(set FR32:$dst, (X86fand FR32:$src1,
423 (memopfsf32 addr:$src2)))]>;
424 def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
425 "orps\t{$src2, $dst|$dst, $src2}",
426 [(set FR32:$dst, (X86for FR32:$src1,
427 (memopfsf32 addr:$src2)))]>;
428 def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
429 "xorps\t{$src2, $dst|$dst, $src2}",
430 [(set FR32:$dst, (X86fxor FR32:$src1,
431 (memopfsf32 addr:$src2)))]>;
433 def FsANDNPSrr : PSI<0x55, MRMSrcReg,
434 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
435 "andnps\t{$src2, $dst|$dst, $src2}", []>;
436 def FsANDNPSrm : PSI<0x55, MRMSrcMem,
437 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
438 "andnps\t{$src2, $dst|$dst, $src2}", []>;
441 /// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
443 /// In addition, we also have a special variant of the scalar form here to
444 /// represent the associated intrinsic operation. This form is unlike the
445 /// plain scalar form, in that it takes an entire vector (instead of a scalar)
446 /// and leaves the top elements undefined.
448 /// These three forms can each be reg+reg or reg+mem, so there are a total of
449 /// six "instructions".
451 let isTwoAddress = 1 in {
452 multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
453 SDNode OpNode, Intrinsic F32Int,
454 bit Commutable = 0> {
455 // Scalar operation, reg+reg.
456 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
457 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
458 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
459 let isCommutable = Commutable;
462 // Scalar operation, reg+mem.
463 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
464 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
465 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
467 // Vector operation, reg+reg.
468 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
469 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
470 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
471 let isCommutable = Commutable;
474 // Vector operation, reg+mem.
475 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
476 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
477 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
479 // Intrinsic operation, reg+reg.
480 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
481 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
482 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
483 let isCommutable = Commutable;
486 // Intrinsic operation, reg+mem.
487 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
488 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
489 [(set VR128:$dst, (F32Int VR128:$src1,
490 sse_load_f32:$src2))]>;
494 // Arithmetic instructions
495 defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
496 defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
497 defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
498 defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
500 /// sse1_fp_binop_rm - Other SSE1 binops
502 /// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
503 /// instructions for a full-vector intrinsic form. Operations that map
504 /// onto C operators don't use this form since they just use the plain
505 /// vector form instead of having a separate vector intrinsic form.
507 /// This provides a total of eight "instructions".
509 let isTwoAddress = 1 in {
510 multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
514 bit Commutable = 0> {
516 // Scalar operation, reg+reg.
517 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
518 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
519 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
520 let isCommutable = Commutable;
523 // Scalar operation, reg+mem.
524 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
525 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
526 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
528 // Vector operation, reg+reg.
529 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
530 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
531 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
532 let isCommutable = Commutable;
535 // Vector operation, reg+mem.
536 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
537 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
538 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
540 // Intrinsic operation, reg+reg.
541 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
542 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
543 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
544 let isCommutable = Commutable;
547 // Intrinsic operation, reg+mem.
548 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
549 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
550 [(set VR128:$dst, (F32Int VR128:$src1,
551 sse_load_f32:$src2))]>;
553 // Vector intrinsic operation, reg+reg.
554 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
555 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
556 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
557 let isCommutable = Commutable;
560 // Vector intrinsic operation, reg+mem.
561 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
562 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
563 [(set VR128:$dst, (V4F32Int VR128:$src1, (load addr:$src2)))]>;
567 defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
568 int_x86_sse_max_ss, int_x86_sse_max_ps>;
569 defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
570 int_x86_sse_min_ss, int_x86_sse_min_ps>;
572 //===----------------------------------------------------------------------===//
573 // SSE packed FP Instructions
576 def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
577 "movaps\t{$src, $dst|$dst, $src}", []>;
578 let isReMaterializable = 1 in
579 def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
580 "movaps\t{$src, $dst|$dst, $src}",
581 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
583 def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
584 "movaps\t{$src, $dst|$dst, $src}",
585 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
587 def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
588 "movups\t{$src, $dst|$dst, $src}", []>;
589 def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
590 "movups\t{$src, $dst|$dst, $src}",
591 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
592 def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
593 "movups\t{$src, $dst|$dst, $src}",
594 [(store (v4f32 VR128:$src), addr:$dst)]>;
596 // Intrinsic forms of MOVUPS load and store
597 def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
598 "movups\t{$src, $dst|$dst, $src}",
599 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
600 def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
601 "movups\t{$src, $dst|$dst, $src}",
602 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
604 let isTwoAddress = 1 in {
605 let AddedComplexity = 20 in {
606 def MOVLPSrm : PSI<0x12, MRMSrcMem,
607 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
608 "movlps\t{$src2, $dst|$dst, $src2}",
610 (v4f32 (vector_shuffle VR128:$src1,
611 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
612 MOVLP_shuffle_mask)))]>;
613 def MOVHPSrm : PSI<0x16, MRMSrcMem,
614 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
615 "movhps\t{$src2, $dst|$dst, $src2}",
617 (v4f32 (vector_shuffle VR128:$src1,
618 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
619 MOVHP_shuffle_mask)))]>;
623 def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
624 "movlps\t{$src, $dst|$dst, $src}",
625 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
626 (iPTR 0))), addr:$dst)]>;
628 // v2f64 extract element 1 is always custom lowered to unpack high to low
629 // and extract element 0 so the non-store version isn't too horrible.
630 def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
631 "movhps\t{$src, $dst|$dst, $src}",
632 [(store (f64 (vector_extract
633 (v2f64 (vector_shuffle
634 (bc_v2f64 (v4f32 VR128:$src)), (undef),
635 UNPCKH_shuffle_mask)), (iPTR 0))),
638 let isTwoAddress = 1 in {
639 let AddedComplexity = 15 in {
640 def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
641 "movlhps\t{$src2, $dst|$dst, $src2}",
643 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
644 MOVHP_shuffle_mask)))]>;
646 def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
647 "movhlps\t{$src2, $dst|$dst, $src2}",
649 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
650 MOVHLPS_shuffle_mask)))]>;
658 /// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
660 /// In addition, we also have a special variant of the scalar form here to
661 /// represent the associated intrinsic operation. This form is unlike the
662 /// plain scalar form, in that it takes an entire vector (instead of a
663 /// scalar) and leaves the top elements undefined.
665 /// And, we have a special variant form for a full-vector intrinsic form.
667 /// These four forms can each have a reg or a mem operand, so there are a
668 /// total of eight "instructions".
670 multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
674 bit Commutable = 0> {
675 // Scalar operation, reg.
676 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
677 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
678 [(set FR32:$dst, (OpNode FR32:$src))]> {
679 let isCommutable = Commutable;
682 // Scalar operation, mem.
683 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
684 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
685 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
687 // Vector operation, reg.
688 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
689 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
690 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
691 let isCommutable = Commutable;
694 // Vector operation, mem.
695 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
696 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
697 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
699 // Intrinsic operation, reg.
700 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
701 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
702 [(set VR128:$dst, (F32Int VR128:$src))]> {
703 let isCommutable = Commutable;
706 // Intrinsic operation, mem.
707 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
708 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
709 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
711 // Vector intrinsic operation, reg
712 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
713 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
714 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
715 let isCommutable = Commutable;
718 // Vector intrinsic operation, mem
719 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
720 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
721 [(set VR128:$dst, (V4F32Int (load addr:$src)))]>;
725 defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
726 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
728 // Reciprocal approximations. Note that these typically require refinement
729 // in order to obtain suitable precision.
730 defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
731 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
732 defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
733 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
736 let isTwoAddress = 1 in {
737 let isCommutable = 1 in {
738 def ANDPSrr : PSI<0x54, MRMSrcReg,
739 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
740 "andps\t{$src2, $dst|$dst, $src2}",
741 [(set VR128:$dst, (v2i64
742 (and VR128:$src1, VR128:$src2)))]>;
743 def ORPSrr : PSI<0x56, MRMSrcReg,
744 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
745 "orps\t{$src2, $dst|$dst, $src2}",
746 [(set VR128:$dst, (v2i64
747 (or VR128:$src1, VR128:$src2)))]>;
748 def XORPSrr : PSI<0x57, MRMSrcReg,
749 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
750 "xorps\t{$src2, $dst|$dst, $src2}",
751 [(set VR128:$dst, (v2i64
752 (xor VR128:$src1, VR128:$src2)))]>;
755 def ANDPSrm : PSI<0x54, MRMSrcMem,
756 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
757 "andps\t{$src2, $dst|$dst, $src2}",
758 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
759 (memopv2i64 addr:$src2)))]>;
760 def ORPSrm : PSI<0x56, MRMSrcMem,
761 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
762 "orps\t{$src2, $dst|$dst, $src2}",
763 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
764 (memopv2i64 addr:$src2)))]>;
765 def XORPSrm : PSI<0x57, MRMSrcMem,
766 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
767 "xorps\t{$src2, $dst|$dst, $src2}",
768 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
769 (memopv2i64 addr:$src2)))]>;
770 def ANDNPSrr : PSI<0x55, MRMSrcReg,
771 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
772 "andnps\t{$src2, $dst|$dst, $src2}",
774 (v2i64 (and (xor VR128:$src1,
775 (bc_v2i64 (v4i32 immAllOnesV))),
777 def ANDNPSrm : PSI<0x55, MRMSrcMem,
778 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
779 "andnps\t{$src2, $dst|$dst, $src2}",
781 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
782 (bc_v2i64 (v4i32 immAllOnesV))),
783 (memopv2i64 addr:$src2))))]>;
786 let isTwoAddress = 1 in {
787 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
788 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
789 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
790 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
791 VR128:$src, imm:$cc))]>;
792 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
793 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
794 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
795 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
796 (load addr:$src), imm:$cc))]>;
799 // Shuffle and unpack instructions
800 let isTwoAddress = 1 in {
801 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
802 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
803 (outs VR128:$dst), (ins VR128:$src1,
804 VR128:$src2, i32i8imm:$src3),
805 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
807 (v4f32 (vector_shuffle
808 VR128:$src1, VR128:$src2,
809 SHUFP_shuffle_mask:$src3)))]>;
810 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
811 (outs VR128:$dst), (ins VR128:$src1,
812 f128mem:$src2, i32i8imm:$src3),
813 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
815 (v4f32 (vector_shuffle
816 VR128:$src1, (memopv4f32 addr:$src2),
817 SHUFP_shuffle_mask:$src3)))]>;
819 let AddedComplexity = 10 in {
820 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
821 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
822 "unpckhps\t{$src2, $dst|$dst, $src2}",
824 (v4f32 (vector_shuffle
825 VR128:$src1, VR128:$src2,
826 UNPCKH_shuffle_mask)))]>;
827 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
828 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
829 "unpckhps\t{$src2, $dst|$dst, $src2}",
831 (v4f32 (vector_shuffle
832 VR128:$src1, (memopv4f32 addr:$src2),
833 UNPCKH_shuffle_mask)))]>;
835 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
836 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
837 "unpcklps\t{$src2, $dst|$dst, $src2}",
839 (v4f32 (vector_shuffle
840 VR128:$src1, VR128:$src2,
841 UNPCKL_shuffle_mask)))]>;
842 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
843 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
844 "unpcklps\t{$src2, $dst|$dst, $src2}",
846 (v4f32 (vector_shuffle
847 VR128:$src1, (memopv4f32 addr:$src2),
848 UNPCKL_shuffle_mask)))]>;
853 def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
854 "movmskps\t{$src, $dst|$dst, $src}",
855 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
856 def MOVMSKPDrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
857 "movmskpd\t{$src, $dst|$dst, $src}",
858 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
860 // Prefetching loads.
861 // TODO: no intrinsics for these?
862 def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src), "prefetcht0\t$src", []>;
863 def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src), "prefetcht1\t$src", []>;
864 def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src), "prefetcht2\t$src", []>;
865 def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src), "prefetchnta\t$src", []>;
867 // Non-temporal stores
868 def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
869 "movntps\t{$src, $dst|$dst, $src}",
870 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
872 // Load, store, and memory fence
873 def SFENCE : PSI<0xAE, MRM7m, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
876 def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
877 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
878 def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
879 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
881 // Alias instructions that map zero vector to pxor / xorp* for sse.
882 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
883 let isReMaterializable = 1 in
884 def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
886 [(set VR128:$dst, (v4f32 immAllZerosV))]>;
888 // FR32 to 128-bit vector conversion.
889 def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
890 "movss\t{$src, $dst|$dst, $src}",
892 (v4f32 (scalar_to_vector FR32:$src)))]>;
893 def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
894 "movss\t{$src, $dst|$dst, $src}",
896 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
898 // FIXME: may not be able to eliminate this movss with coalescing the src and
899 // dest register classes are different. We really want to write this pattern
901 // def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
903 def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
904 "movss\t{$src, $dst|$dst, $src}",
905 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
907 def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
908 "movss\t{$src, $dst|$dst, $src}",
909 [(store (f32 (vector_extract (v4f32 VR128:$src),
910 (iPTR 0))), addr:$dst)]>;
913 // Move to lower bits of a VR128, leaving upper bits alone.
914 // Three operand (but two address) aliases.
915 let isTwoAddress = 1 in {
916 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
917 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
918 "movss\t{$src2, $dst|$dst, $src2}", []>;
920 let AddedComplexity = 15 in
921 def MOVLPSrr : SSI<0x10, MRMSrcReg,
922 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
923 "movss\t{$src2, $dst|$dst, $src2}",
925 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
926 MOVL_shuffle_mask)))]>;
929 // Move to lower bits of a VR128 and zeroing upper bits.
930 // Loading from memory automatically zeroing upper bits.
931 let AddedComplexity = 20 in
932 def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
933 "movss\t{$src, $dst|$dst, $src}",
934 [(set VR128:$dst, (v4f32 (vector_shuffle immAllZerosV,
935 (v4f32 (scalar_to_vector (loadf32 addr:$src))),
936 MOVL_shuffle_mask)))]>;
939 //===----------------------------------------------------------------------===//
941 //===----------------------------------------------------------------------===//
944 def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
945 "movsd\t{$src, $dst|$dst, $src}", []>;
946 let isReMaterializable = 1 in
947 def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
948 "movsd\t{$src, $dst|$dst, $src}",
949 [(set FR64:$dst, (loadf64 addr:$src))]>;
950 def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
951 "movsd\t{$src, $dst|$dst, $src}",
952 [(store FR64:$src, addr:$dst)]>;
954 // Conversion instructions
955 def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
956 "cvttsd2si\t{$src, $dst|$dst, $src}",
957 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
958 def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
959 "cvttsd2si\t{$src, $dst|$dst, $src}",
960 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
961 def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
962 "cvtsd2ss\t{$src, $dst|$dst, $src}",
963 [(set FR32:$dst, (fround FR64:$src))]>;
964 def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
965 "cvtsd2ss\t{$src, $dst|$dst, $src}",
966 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
967 def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
968 "cvtsi2sd\t{$src, $dst|$dst, $src}",
969 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
970 def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
971 "cvtsi2sd\t{$src, $dst|$dst, $src}",
972 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
974 // SSE2 instructions with XS prefix
975 def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
976 "cvtss2sd\t{$src, $dst|$dst, $src}",
977 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
979 def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
980 "cvtss2sd\t{$src, $dst|$dst, $src}",
981 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
984 // Match intrinsics which expect XMM operand(s).
985 def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
986 "cvtsd2si\t{$src, $dst|$dst, $src}",
987 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
988 def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
989 "cvtsd2si\t{$src, $dst|$dst, $src}",
990 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
991 (load addr:$src)))]>;
993 // Aliases for intrinsics
994 def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
995 "cvttsd2si\t{$src, $dst|$dst, $src}",
997 (int_x86_sse2_cvttsd2si VR128:$src))]>;
998 def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
999 "cvttsd2si\t{$src, $dst|$dst, $src}",
1000 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1001 (load addr:$src)))]>;
1003 // Comparison instructions
1004 let isTwoAddress = 1 in {
1005 def CMPSDrr : SDI<0xC2, MRMSrcReg,
1006 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
1007 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
1008 def CMPSDrm : SDI<0xC2, MRMSrcMem,
1009 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
1010 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
1013 def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
1014 "ucomisd\t{$src2, $src1|$src1, $src2}",
1015 [(X86cmp FR64:$src1, FR64:$src2)]>;
1016 def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
1017 "ucomisd\t{$src2, $src1|$src1, $src2}",
1018 [(X86cmp FR64:$src1, (loadf64 addr:$src2))]>;
1020 // Aliases to match intrinsics which expect XMM operand(s).
1021 let isTwoAddress = 1 in {
1022 def Int_CMPSDrr : SDI<0xC2, MRMSrcReg,
1023 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1024 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
1025 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1026 VR128:$src, imm:$cc))]>;
1027 def Int_CMPSDrm : SDI<0xC2, MRMSrcMem,
1028 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src, SSECC:$cc),
1029 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
1030 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1031 (load addr:$src), imm:$cc))]>;
1034 def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1035 "ucomisd\t{$src2, $src1|$src1, $src2}",
1036 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2))]>;
1037 def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1038 "ucomisd\t{$src2, $src1|$src1, $src2}",
1039 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2))]>;
1041 def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1042 "comisd\t{$src2, $src1|$src1, $src2}",
1043 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2))]>;
1044 def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1045 "comisd\t{$src2, $src1|$src1, $src2}",
1046 [(X86comi (v2f64 VR128:$src1), (load addr:$src2))]>;
1048 // Aliases of packed SSE2 instructions for scalar use. These all have names that
1051 // Alias instructions that map fld0 to pxor for sse.
1052 def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
1053 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
1054 Requires<[HasSSE2]>, TB, OpSize;
1056 // Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1058 def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1059 "movapd\t{$src, $dst|$dst, $src}", []>;
1061 // Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1063 def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
1064 "movapd\t{$src, $dst|$dst, $src}",
1065 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
1067 // Alias bitwise logical operations using SSE logical ops on packed FP values.
1068 let isTwoAddress = 1 in {
1069 let isCommutable = 1 in {
1070 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1071 "andpd\t{$src2, $dst|$dst, $src2}",
1072 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
1073 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1074 "orpd\t{$src2, $dst|$dst, $src2}",
1075 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
1076 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1077 "xorpd\t{$src2, $dst|$dst, $src2}",
1078 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1081 def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
1082 "andpd\t{$src2, $dst|$dst, $src2}",
1083 [(set FR64:$dst, (X86fand FR64:$src1,
1084 (memopfsf64 addr:$src2)))]>;
1085 def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
1086 "orpd\t{$src2, $dst|$dst, $src2}",
1087 [(set FR64:$dst, (X86for FR64:$src1,
1088 (memopfsf64 addr:$src2)))]>;
1089 def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
1090 "xorpd\t{$src2, $dst|$dst, $src2}",
1091 [(set FR64:$dst, (X86fxor FR64:$src1,
1092 (memopfsf64 addr:$src2)))]>;
1094 def FsANDNPDrr : PDI<0x55, MRMSrcReg,
1095 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1096 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
1097 def FsANDNPDrm : PDI<0x55, MRMSrcMem,
1098 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
1099 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
1102 /// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1104 /// In addition, we also have a special variant of the scalar form here to
1105 /// represent the associated intrinsic operation. This form is unlike the
1106 /// plain scalar form, in that it takes an entire vector (instead of a scalar)
1107 /// and leaves the top elements undefined.
1109 /// These three forms can each be reg+reg or reg+mem, so there are a total of
1110 /// six "instructions".
1112 let isTwoAddress = 1 in {
1113 multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1114 SDNode OpNode, Intrinsic F64Int,
1115 bit Commutable = 0> {
1116 // Scalar operation, reg+reg.
1117 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1118 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1119 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1120 let isCommutable = Commutable;
1123 // Scalar operation, reg+mem.
1124 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
1125 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1126 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1128 // Vector operation, reg+reg.
1129 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1130 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1131 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1132 let isCommutable = Commutable;
1135 // Vector operation, reg+mem.
1136 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1137 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1138 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
1140 // Intrinsic operation, reg+reg.
1141 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1142 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1143 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1144 let isCommutable = Commutable;
1147 // Intrinsic operation, reg+mem.
1148 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
1149 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1150 [(set VR128:$dst, (F64Int VR128:$src1,
1151 sse_load_f64:$src2))]>;
1155 // Arithmetic instructions
1156 defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1157 defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1158 defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1159 defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1161 /// sse2_fp_binop_rm - Other SSE2 binops
1163 /// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1164 /// instructions for a full-vector intrinsic form. Operations that map
1165 /// onto C operators don't use this form since they just use the plain
1166 /// vector form instead of having a separate vector intrinsic form.
1168 /// This provides a total of eight "instructions".
1170 let isTwoAddress = 1 in {
1171 multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1175 bit Commutable = 0> {
1177 // Scalar operation, reg+reg.
1178 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1179 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1180 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1181 let isCommutable = Commutable;
1184 // Scalar operation, reg+mem.
1185 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
1186 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1187 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1189 // Vector operation, reg+reg.
1190 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1191 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1192 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1193 let isCommutable = Commutable;
1196 // Vector operation, reg+mem.
1197 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1198 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1199 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
1201 // Intrinsic operation, reg+reg.
1202 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1203 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1204 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1205 let isCommutable = Commutable;
1208 // Intrinsic operation, reg+mem.
1209 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
1210 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1211 [(set VR128:$dst, (F64Int VR128:$src1,
1212 sse_load_f64:$src2))]>;
1214 // Vector intrinsic operation, reg+reg.
1215 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1216 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1217 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1218 let isCommutable = Commutable;
1221 // Vector intrinsic operation, reg+mem.
1222 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1223 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1224 [(set VR128:$dst, (V2F64Int VR128:$src1, (load addr:$src2)))]>;
1228 defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1229 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1230 defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1231 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1233 //===----------------------------------------------------------------------===//
1234 // SSE packed FP Instructions
1236 // Move Instructions
1237 def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1238 "movapd\t{$src, $dst|$dst, $src}", []>;
1239 let isReMaterializable = 1 in
1240 def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1241 "movapd\t{$src, $dst|$dst, $src}",
1242 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
1244 def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1245 "movapd\t{$src, $dst|$dst, $src}",
1246 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
1248 def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1249 "movupd\t{$src, $dst|$dst, $src}", []>;
1250 def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1251 "movupd\t{$src, $dst|$dst, $src}",
1252 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
1253 def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1254 "movupd\t{$src, $dst|$dst, $src}",
1255 [(store (v2f64 VR128:$src), addr:$dst)]>;
1257 // Intrinsic forms of MOVUPD load and store
1258 def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1259 "movupd\t{$src, $dst|$dst, $src}",
1260 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
1261 def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1262 "movupd\t{$src, $dst|$dst, $src}",
1263 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
1265 let isTwoAddress = 1 in {
1266 let AddedComplexity = 20 in {
1267 def MOVLPDrm : PDI<0x12, MRMSrcMem,
1268 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
1269 "movlpd\t{$src2, $dst|$dst, $src2}",
1271 (v2f64 (vector_shuffle VR128:$src1,
1272 (scalar_to_vector (loadf64 addr:$src2)),
1273 MOVLP_shuffle_mask)))]>;
1274 def MOVHPDrm : PDI<0x16, MRMSrcMem,
1275 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
1276 "movhpd\t{$src2, $dst|$dst, $src2}",
1278 (v2f64 (vector_shuffle VR128:$src1,
1279 (scalar_to_vector (loadf64 addr:$src2)),
1280 MOVHP_shuffle_mask)))]>;
1281 } // AddedComplexity
1284 def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
1285 "movlpd\t{$src, $dst|$dst, $src}",
1286 [(store (f64 (vector_extract (v2f64 VR128:$src),
1287 (iPTR 0))), addr:$dst)]>;
1289 // v2f64 extract element 1 is always custom lowered to unpack high to low
1290 // and extract element 0 so the non-store version isn't too horrible.
1291 def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
1292 "movhpd\t{$src, $dst|$dst, $src}",
1293 [(store (f64 (vector_extract
1294 (v2f64 (vector_shuffle VR128:$src, (undef),
1295 UNPCKH_shuffle_mask)), (iPTR 0))),
1298 // SSE2 instructions without OpSize prefix
1299 def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1300 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1301 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1302 TB, Requires<[HasSSE2]>;
1303 def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1304 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1305 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1306 (bitconvert (memopv2i64 addr:$src))))]>,
1307 TB, Requires<[HasSSE2]>;
1309 // SSE2 instructions with XS prefix
1310 def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1311 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1312 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1313 XS, Requires<[HasSSE2]>;
1314 def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1315 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1316 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1317 (bitconvert (memopv2i64 addr:$src))))]>,
1318 XS, Requires<[HasSSE2]>;
1320 def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1321 "cvtps2dq\t{$src, $dst|$dst, $src}",
1322 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
1323 def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1324 "cvtps2dq\t{$src, $dst|$dst, $src}",
1325 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1326 (load addr:$src)))]>;
1327 // SSE2 packed instructions with XS prefix
1328 def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1329 "cvttps2dq\t{$src, $dst|$dst, $src}",
1330 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1331 XS, Requires<[HasSSE2]>;
1332 def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1333 "cvttps2dq\t{$src, $dst|$dst, $src}",
1334 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1335 (load addr:$src)))]>,
1336 XS, Requires<[HasSSE2]>;
1338 // SSE2 packed instructions with XD prefix
1339 def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1340 "cvtpd2dq\t{$src, $dst|$dst, $src}",
1341 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1342 XD, Requires<[HasSSE2]>;
1343 def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1344 "cvtpd2dq\t{$src, $dst|$dst, $src}",
1345 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1346 (load addr:$src)))]>,
1347 XD, Requires<[HasSSE2]>;
1349 def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1350 "cvttpd2dq\t{$src, $dst|$dst, $src}",
1351 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
1352 def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1353 "cvttpd2dq\t{$src, $dst|$dst, $src}",
1354 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1355 (load addr:$src)))]>;
1357 // SSE2 instructions without OpSize prefix
1358 def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1359 "cvtps2pd\t{$src, $dst|$dst, $src}",
1360 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1361 TB, Requires<[HasSSE2]>;
1362 def Int_CVTPS2PDrm : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f64mem:$src),
1363 "cvtps2pd\t{$src, $dst|$dst, $src}",
1364 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1365 (load addr:$src)))]>,
1366 TB, Requires<[HasSSE2]>;
1368 def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1369 "cvtpd2ps\t{$src, $dst|$dst, $src}",
1370 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
1371 def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f128mem:$src),
1372 "cvtpd2ps\t{$src, $dst|$dst, $src}",
1373 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1374 (load addr:$src)))]>;
1376 // Match intrinsics which expect XMM operand(s).
1377 // Aliases for intrinsics
1378 let isTwoAddress = 1 in {
1379 def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
1380 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
1381 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
1382 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1384 def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
1385 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
1386 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
1387 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1388 (loadi32 addr:$src2)))]>;
1389 def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
1390 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1391 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
1392 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1394 def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
1395 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
1396 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
1397 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1398 (load addr:$src2)))]>;
1399 def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
1400 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1401 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
1402 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1403 VR128:$src2))]>, XS,
1404 Requires<[HasSSE2]>;
1405 def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
1406 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
1407 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
1408 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1409 (load addr:$src2)))]>, XS,
1410 Requires<[HasSSE2]>;
1415 /// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1417 /// In addition, we also have a special variant of the scalar form here to
1418 /// represent the associated intrinsic operation. This form is unlike the
1419 /// plain scalar form, in that it takes an entire vector (instead of a
1420 /// scalar) and leaves the top elements undefined.
1422 /// And, we have a special variant form for a full-vector intrinsic form.
1424 /// These four forms can each have a reg or a mem operand, so there are a
1425 /// total of eight "instructions".
1427 multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1431 bit Commutable = 0> {
1432 // Scalar operation, reg.
1433 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1434 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1435 [(set FR64:$dst, (OpNode FR64:$src))]> {
1436 let isCommutable = Commutable;
1439 // Scalar operation, mem.
1440 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
1441 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1442 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1444 // Vector operation, reg.
1445 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1446 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1447 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1448 let isCommutable = Commutable;
1451 // Vector operation, mem.
1452 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1453 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1454 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
1456 // Intrinsic operation, reg.
1457 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1458 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1459 [(set VR128:$dst, (F64Int VR128:$src))]> {
1460 let isCommutable = Commutable;
1463 // Intrinsic operation, mem.
1464 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
1465 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1466 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1468 // Vector intrinsic operation, reg
1469 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1470 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1471 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1472 let isCommutable = Commutable;
1475 // Vector intrinsic operation, mem
1476 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1477 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1478 [(set VR128:$dst, (V2F64Int (load addr:$src)))]>;
1482 defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1483 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1485 // There is no f64 version of the reciprocal approximation instructions.
1488 let isTwoAddress = 1 in {
1489 let isCommutable = 1 in {
1490 def ANDPDrr : PDI<0x54, MRMSrcReg,
1491 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1492 "andpd\t{$src2, $dst|$dst, $src2}",
1494 (and (bc_v2i64 (v2f64 VR128:$src1)),
1495 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1496 def ORPDrr : PDI<0x56, MRMSrcReg,
1497 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1498 "orpd\t{$src2, $dst|$dst, $src2}",
1500 (or (bc_v2i64 (v2f64 VR128:$src1)),
1501 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1502 def XORPDrr : PDI<0x57, MRMSrcReg,
1503 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1504 "xorpd\t{$src2, $dst|$dst, $src2}",
1506 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1507 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1510 def ANDPDrm : PDI<0x54, MRMSrcMem,
1511 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1512 "andpd\t{$src2, $dst|$dst, $src2}",
1514 (and (bc_v2i64 (v2f64 VR128:$src1)),
1515 (memopv2i64 addr:$src2)))]>;
1516 def ORPDrm : PDI<0x56, MRMSrcMem,
1517 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1518 "orpd\t{$src2, $dst|$dst, $src2}",
1520 (or (bc_v2i64 (v2f64 VR128:$src1)),
1521 (memopv2i64 addr:$src2)))]>;
1522 def XORPDrm : PDI<0x57, MRMSrcMem,
1523 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1524 "xorpd\t{$src2, $dst|$dst, $src2}",
1526 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1527 (memopv2i64 addr:$src2)))]>;
1528 def ANDNPDrr : PDI<0x55, MRMSrcReg,
1529 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1530 "andnpd\t{$src2, $dst|$dst, $src2}",
1532 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1533 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1534 def ANDNPDrm : PDI<0x55, MRMSrcMem,
1535 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
1536 "andnpd\t{$src2, $dst|$dst, $src2}",
1538 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1539 (memopv2i64 addr:$src2)))]>;
1542 let isTwoAddress = 1 in {
1543 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
1544 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1545 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1546 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1547 VR128:$src, imm:$cc))]>;
1548 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
1549 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1550 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1551 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1552 (load addr:$src), imm:$cc))]>;
1555 // Shuffle and unpack instructions
1556 let isTwoAddress = 1 in {
1557 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
1558 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1559 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1560 [(set VR128:$dst, (v2f64 (vector_shuffle
1561 VR128:$src1, VR128:$src2,
1562 SHUFP_shuffle_mask:$src3)))]>;
1563 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
1564 (outs VR128:$dst), (ins VR128:$src1,
1565 f128mem:$src2, i8imm:$src3),
1566 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1568 (v2f64 (vector_shuffle
1569 VR128:$src1, (memopv2f64 addr:$src2),
1570 SHUFP_shuffle_mask:$src3)))]>;
1572 let AddedComplexity = 10 in {
1573 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
1574 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1575 "unpckhpd\t{$src2, $dst|$dst, $src2}",
1577 (v2f64 (vector_shuffle
1578 VR128:$src1, VR128:$src2,
1579 UNPCKH_shuffle_mask)))]>;
1580 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
1581 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1582 "unpckhpd\t{$src2, $dst|$dst, $src2}",
1584 (v2f64 (vector_shuffle
1585 VR128:$src1, (memopv2f64 addr:$src2),
1586 UNPCKH_shuffle_mask)))]>;
1588 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
1589 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1590 "unpcklpd\t{$src2, $dst|$dst, $src2}",
1592 (v2f64 (vector_shuffle
1593 VR128:$src1, VR128:$src2,
1594 UNPCKL_shuffle_mask)))]>;
1595 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
1596 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1597 "unpcklpd\t{$src2, $dst|$dst, $src2}",
1599 (v2f64 (vector_shuffle
1600 VR128:$src1, (memopv2f64 addr:$src2),
1601 UNPCKL_shuffle_mask)))]>;
1602 } // AddedComplexity
1606 //===----------------------------------------------------------------------===//
1607 // SSE integer instructions
1609 // Move Instructions
1610 def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1611 "movdqa\t{$src, $dst|$dst, $src}", []>;
1612 def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1613 "movdqa\t{$src, $dst|$dst, $src}",
1614 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
1615 def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1616 "movdqa\t{$src, $dst|$dst, $src}",
1617 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
1618 def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1619 "movdqu\t{$src, $dst|$dst, $src}",
1620 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
1621 XS, Requires<[HasSSE2]>;
1622 def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1623 "movdqu\t{$src, $dst|$dst, $src}",
1624 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
1625 XS, Requires<[HasSSE2]>;
1627 // Intrinsic forms of MOVDQU load and store
1628 def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1629 "movdqu\t{$src, $dst|$dst, $src}",
1630 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1631 XS, Requires<[HasSSE2]>;
1632 def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1633 "movdqu\t{$src, $dst|$dst, $src}",
1634 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1635 XS, Requires<[HasSSE2]>;
1637 let isTwoAddress = 1 in {
1639 multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1640 bit Commutable = 0> {
1641 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1642 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1643 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1644 let isCommutable = Commutable;
1646 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1647 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1648 [(set VR128:$dst, (IntId VR128:$src1,
1649 (bitconvert (memopv2i64 addr:$src2))))]>;
1652 multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1653 string OpcodeStr, Intrinsic IntId> {
1654 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1655 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1656 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
1657 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1658 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1659 [(set VR128:$dst, (IntId VR128:$src1,
1660 (bitconvert (memopv2i64 addr:$src2))))]>;
1661 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
1662 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1663 [(set VR128:$dst, (IntId VR128:$src1,
1664 (scalar_to_vector (i32 imm:$src2))))]>;
1668 /// PDI_binop_rm - Simple SSE2 binary operator.
1669 multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1670 ValueType OpVT, bit Commutable = 0> {
1671 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1672 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1673 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1674 let isCommutable = Commutable;
1676 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1677 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1678 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
1679 (bitconvert (memopv2i64 addr:$src2)))))]>;
1682 /// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1684 /// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1685 /// to collapse (bitconvert VT to VT) into its operand.
1687 multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1688 bit Commutable = 0> {
1689 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1690 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1691 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1692 let isCommutable = Commutable;
1694 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1695 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1696 [(set VR128:$dst, (OpNode VR128:$src1,(memopv2i64 addr:$src2)))]>;
1701 // 128-bit Integer Arithmetic
1703 defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1704 defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1705 defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1706 defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1708 defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1709 defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1710 defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1711 defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1713 defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1714 defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1715 defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1716 defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1718 defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1719 defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1720 defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1721 defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1723 defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1725 defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1726 defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1727 defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1729 defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1731 defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1732 defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1735 defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1736 defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1737 defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1738 defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1739 defm PSADBW : PDI_binop_rm_int<0xE0, "psadbw", int_x86_sse2_psad_bw, 1>;
1742 defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw", int_x86_sse2_psll_w>;
1743 defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld", int_x86_sse2_psll_d>;
1744 defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq", int_x86_sse2_psll_q>;
1746 defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", int_x86_sse2_psrl_w>;
1747 defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld", int_x86_sse2_psrl_d>;
1748 defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq", int_x86_sse2_psrl_q>;
1750 defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw", int_x86_sse2_psra_w>;
1751 defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad", int_x86_sse2_psra_d>;
1752 // PSRAQ doesn't exist in SSE[1-3].
1754 // 128-bit logical shifts.
1755 let isTwoAddress = 1 in {
1756 def PSLLDQri : PDIi8<0x73, MRM7r,
1757 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
1758 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
1759 def PSRLDQri : PDIi8<0x73, MRM3r,
1760 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
1761 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
1762 // PSRADQri doesn't exist in SSE[1-3].
1765 let Predicates = [HasSSE2] in {
1766 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1767 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1768 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1769 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1770 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1771 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1775 defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1776 defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1777 defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1779 let isTwoAddress = 1 in {
1780 def PANDNrr : PDI<0xDF, MRMSrcReg,
1781 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1782 "pandn\t{$src2, $dst|$dst, $src2}",
1783 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1786 def PANDNrm : PDI<0xDF, MRMSrcMem,
1787 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1788 "pandn\t{$src2, $dst|$dst, $src2}",
1789 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1790 (memopv2i64 addr:$src2))))]>;
1793 // SSE2 Integer comparison
1794 defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1795 defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
1796 defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
1797 defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
1798 defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
1799 defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
1801 // Pack instructions
1802 defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
1803 defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
1804 defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
1806 // Shuffle and unpack instructions
1807 def PSHUFDri : PDIi8<0x70, MRMSrcReg,
1808 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
1809 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1810 [(set VR128:$dst, (v4i32 (vector_shuffle
1811 VR128:$src1, (undef),
1812 PSHUFD_shuffle_mask:$src2)))]>;
1813 def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
1814 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
1815 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1816 [(set VR128:$dst, (v4i32 (vector_shuffle
1817 (bc_v4i32(memopv2i64 addr:$src1)),
1819 PSHUFD_shuffle_mask:$src2)))]>;
1821 // SSE2 with ImmT == Imm8 and XS prefix.
1822 def PSHUFHWri : Ii8<0x70, MRMSrcReg,
1823 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
1824 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1825 [(set VR128:$dst, (v8i16 (vector_shuffle
1826 VR128:$src1, (undef),
1827 PSHUFHW_shuffle_mask:$src2)))]>,
1828 XS, Requires<[HasSSE2]>;
1829 def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
1830 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
1831 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1832 [(set VR128:$dst, (v8i16 (vector_shuffle
1833 (bc_v8i16 (memopv2i64 addr:$src1)),
1835 PSHUFHW_shuffle_mask:$src2)))]>,
1836 XS, Requires<[HasSSE2]>;
1838 // SSE2 with ImmT == Imm8 and XD prefix.
1839 def PSHUFLWri : Ii8<0x70, MRMSrcReg,
1840 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
1841 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1842 [(set VR128:$dst, (v8i16 (vector_shuffle
1843 VR128:$src1, (undef),
1844 PSHUFLW_shuffle_mask:$src2)))]>,
1845 XD, Requires<[HasSSE2]>;
1846 def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
1847 (outs VR128:$dst), (ins i128mem:$src1, i32i8imm:$src2),
1848 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1849 [(set VR128:$dst, (v8i16 (vector_shuffle
1850 (bc_v8i16 (memopv2i64 addr:$src1)),
1852 PSHUFLW_shuffle_mask:$src2)))]>,
1853 XD, Requires<[HasSSE2]>;
1856 let isTwoAddress = 1 in {
1857 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
1858 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1859 "punpcklbw\t{$src2, $dst|$dst, $src2}",
1861 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1862 UNPCKL_shuffle_mask)))]>;
1863 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
1864 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1865 "punpcklbw\t{$src2, $dst|$dst, $src2}",
1867 (v16i8 (vector_shuffle VR128:$src1,
1868 (bc_v16i8 (memopv2i64 addr:$src2)),
1869 UNPCKL_shuffle_mask)))]>;
1870 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
1871 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1872 "punpcklwd\t{$src2, $dst|$dst, $src2}",
1874 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1875 UNPCKL_shuffle_mask)))]>;
1876 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
1877 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1878 "punpcklwd\t{$src2, $dst|$dst, $src2}",
1880 (v8i16 (vector_shuffle VR128:$src1,
1881 (bc_v8i16 (memopv2i64 addr:$src2)),
1882 UNPCKL_shuffle_mask)))]>;
1883 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
1884 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1885 "punpckldq\t{$src2, $dst|$dst, $src2}",
1887 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1888 UNPCKL_shuffle_mask)))]>;
1889 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
1890 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1891 "punpckldq\t{$src2, $dst|$dst, $src2}",
1893 (v4i32 (vector_shuffle VR128:$src1,
1894 (bc_v4i32 (memopv2i64 addr:$src2)),
1895 UNPCKL_shuffle_mask)))]>;
1896 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
1897 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1898 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
1900 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1901 UNPCKL_shuffle_mask)))]>;
1902 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
1903 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1904 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
1906 (v2i64 (vector_shuffle VR128:$src1,
1907 (memopv2i64 addr:$src2),
1908 UNPCKL_shuffle_mask)))]>;
1910 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
1911 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1912 "punpckhbw\t{$src2, $dst|$dst, $src2}",
1914 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1915 UNPCKH_shuffle_mask)))]>;
1916 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
1917 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1918 "punpckhbw\t{$src2, $dst|$dst, $src2}",
1920 (v16i8 (vector_shuffle VR128:$src1,
1921 (bc_v16i8 (memopv2i64 addr:$src2)),
1922 UNPCKH_shuffle_mask)))]>;
1923 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
1924 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1925 "punpckhwd\t{$src2, $dst|$dst, $src2}",
1927 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1928 UNPCKH_shuffle_mask)))]>;
1929 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
1930 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1931 "punpckhwd\t{$src2, $dst|$dst, $src2}",
1933 (v8i16 (vector_shuffle VR128:$src1,
1934 (bc_v8i16 (memopv2i64 addr:$src2)),
1935 UNPCKH_shuffle_mask)))]>;
1936 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
1937 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1938 "punpckhdq\t{$src2, $dst|$dst, $src2}",
1940 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1941 UNPCKH_shuffle_mask)))]>;
1942 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
1943 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1944 "punpckhdq\t{$src2, $dst|$dst, $src2}",
1946 (v4i32 (vector_shuffle VR128:$src1,
1947 (bc_v4i32 (memopv2i64 addr:$src2)),
1948 UNPCKH_shuffle_mask)))]>;
1949 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
1950 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1951 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
1953 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1954 UNPCKH_shuffle_mask)))]>;
1955 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
1956 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1957 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
1959 (v2i64 (vector_shuffle VR128:$src1,
1960 (memopv2i64 addr:$src2),
1961 UNPCKH_shuffle_mask)))]>;
1965 def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
1966 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
1967 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1968 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
1969 (iPTR imm:$src2)))]>;
1970 let isTwoAddress = 1 in {
1971 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
1972 (outs VR128:$dst), (ins VR128:$src1,
1973 GR32:$src2, i32i8imm:$src3),
1974 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1976 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
1977 GR32:$src2, (iPTR imm:$src3))))]>;
1978 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
1979 (outs VR128:$dst), (ins VR128:$src1,
1980 i16mem:$src2, i32i8imm:$src3),
1981 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1983 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
1984 (i32 (anyext (loadi16 addr:$src2))),
1985 (iPTR imm:$src3))))]>;
1989 def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
1990 "pmovmskb\t{$src, $dst|$dst, $src}",
1991 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
1993 // Conditional store
1994 def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
1995 "maskmovdqu\t{$mask, $src|$src, $mask}",
1996 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>,
1999 // Non-temporal stores
2000 def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2001 "movntpd\t{$src, $dst|$dst, $src}",
2002 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
2003 def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2004 "movntdq\t{$src, $dst|$dst, $src}",
2005 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
2006 def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
2007 "movnti\t{$src, $dst|$dst, $src}",
2008 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2009 TB, Requires<[HasSSE2]>;
2012 def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
2013 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
2014 TB, Requires<[HasSSE2]>;
2016 // Load, store, and memory fence
2017 def LFENCE : I<0xAE, MRM5m, (outs), (ins),
2018 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
2019 def MFENCE : I<0xAE, MRM6m, (outs), (ins),
2020 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2023 // Alias instructions that map zero vector to pxor / xorp* for sse.
2024 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2025 let isReMaterializable = 1 in
2026 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
2027 "pcmpeqd\t$dst, $dst",
2028 [(set VR128:$dst, (v2f64 immAllOnesV))]>;
2030 // FR64 to 128-bit vector conversion.
2031 def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
2032 "movsd\t{$src, $dst|$dst, $src}",
2034 (v2f64 (scalar_to_vector FR64:$src)))]>;
2035 def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2036 "movsd\t{$src, $dst|$dst, $src}",
2038 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2040 def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2041 "movd\t{$src, $dst|$dst, $src}",
2043 (v4i32 (scalar_to_vector GR32:$src)))]>;
2044 def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2045 "movd\t{$src, $dst|$dst, $src}",
2047 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2049 def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
2050 "movd\t{$src, $dst|$dst, $src}",
2051 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2053 def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
2054 "movd\t{$src, $dst|$dst, $src}",
2055 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2057 // SSE2 instructions with XS prefix
2058 def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
2059 "movq\t{$src, $dst|$dst, $src}",
2061 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2062 Requires<[HasSSE2]>;
2063 def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
2064 "movq\t{$src, $dst|$dst, $src}",
2065 [(store (i64 (vector_extract (v2i64 VR128:$src),
2066 (iPTR 0))), addr:$dst)]>;
2068 // FIXME: may not be able to eliminate this movss with coalescing the src and
2069 // dest register classes are different. We really want to write this pattern
2071 // def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2072 // (f32 FR32:$src)>;
2073 def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
2074 "movsd\t{$src, $dst|$dst, $src}",
2075 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2077 def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
2078 "movsd\t{$src, $dst|$dst, $src}",
2079 [(store (f64 (vector_extract (v2f64 VR128:$src),
2080 (iPTR 0))), addr:$dst)]>;
2081 def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
2082 "movd\t{$src, $dst|$dst, $src}",
2083 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2085 def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
2086 "movd\t{$src, $dst|$dst, $src}",
2087 [(store (i32 (vector_extract (v4i32 VR128:$src),
2088 (iPTR 0))), addr:$dst)]>;
2090 def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
2091 "movd\t{$src, $dst|$dst, $src}",
2092 [(set GR32:$dst, (bitconvert FR32:$src))]>;
2093 def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
2094 "movd\t{$src, $dst|$dst, $src}",
2095 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2098 // Move to lower bits of a VR128, leaving upper bits alone.
2099 // Three operand (but two address) aliases.
2100 let isTwoAddress = 1 in {
2101 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
2102 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
2103 "movsd\t{$src2, $dst|$dst, $src2}", []>;
2105 let AddedComplexity = 15 in
2106 def MOVLPDrr : SDI<0x10, MRMSrcReg,
2107 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2108 "movsd\t{$src2, $dst|$dst, $src2}",
2110 (v2f64 (vector_shuffle VR128:$src1, VR128:$src2,
2111 MOVL_shuffle_mask)))]>;
2114 // Store / copy lower 64-bits of a XMM register.
2115 def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
2116 "movq\t{$src, $dst|$dst, $src}",
2117 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2119 // Move to lower bits of a VR128 and zeroing upper bits.
2120 // Loading from memory automatically zeroing upper bits.
2121 let AddedComplexity = 20 in
2122 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2123 "movsd\t{$src, $dst|$dst, $src}",
2125 (v2f64 (vector_shuffle immAllZerosV,
2126 (v2f64 (scalar_to_vector
2127 (loadf64 addr:$src))),
2128 MOVL_shuffle_mask)))]>;
2130 let AddedComplexity = 15 in
2131 // movd / movq to XMM register zero-extends
2132 def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2133 "movd\t{$src, $dst|$dst, $src}",
2135 (v4i32 (vector_shuffle immAllZerosV,
2136 (v4i32 (scalar_to_vector GR32:$src)),
2137 MOVL_shuffle_mask)))]>;
2138 let AddedComplexity = 20 in
2139 def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2140 "movd\t{$src, $dst|$dst, $src}",
2142 (v4i32 (vector_shuffle immAllZerosV,
2143 (v4i32 (scalar_to_vector (loadi32 addr:$src))),
2144 MOVL_shuffle_mask)))]>;
2146 // Moving from XMM to XMM but still clear upper 64 bits.
2147 let AddedComplexity = 15 in
2148 def MOVZQI2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2149 "movq\t{$src, $dst|$dst, $src}",
2150 [(set VR128:$dst, (int_x86_sse2_movl_dq VR128:$src))]>,
2151 XS, Requires<[HasSSE2]>;
2152 let AddedComplexity = 20 in
2153 def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
2154 "movq\t{$src, $dst|$dst, $src}",
2155 [(set VR128:$dst, (int_x86_sse2_movl_dq
2156 (bitconvert (memopv2i64 addr:$src))))]>,
2157 XS, Requires<[HasSSE2]>;
2160 //===----------------------------------------------------------------------===//
2161 // SSE3 Instructions
2162 //===----------------------------------------------------------------------===//
2164 // Move Instructions
2165 def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2166 "movshdup\t{$src, $dst|$dst, $src}",
2167 [(set VR128:$dst, (v4f32 (vector_shuffle
2168 VR128:$src, (undef),
2169 MOVSHDUP_shuffle_mask)))]>;
2170 def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
2171 "movshdup\t{$src, $dst|$dst, $src}",
2172 [(set VR128:$dst, (v4f32 (vector_shuffle
2173 (memopv4f32 addr:$src), (undef),
2174 MOVSHDUP_shuffle_mask)))]>;
2176 def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2177 "movsldup\t{$src, $dst|$dst, $src}",
2178 [(set VR128:$dst, (v4f32 (vector_shuffle
2179 VR128:$src, (undef),
2180 MOVSLDUP_shuffle_mask)))]>;
2181 def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
2182 "movsldup\t{$src, $dst|$dst, $src}",
2183 [(set VR128:$dst, (v4f32 (vector_shuffle
2184 (memopv4f32 addr:$src), (undef),
2185 MOVSLDUP_shuffle_mask)))]>;
2187 def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2188 "movddup\t{$src, $dst|$dst, $src}",
2189 [(set VR128:$dst, (v2f64 (vector_shuffle
2190 VR128:$src, (undef),
2191 SSE_splat_lo_mask)))]>;
2192 def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2193 "movddup\t{$src, $dst|$dst, $src}",
2195 (v2f64 (vector_shuffle
2196 (scalar_to_vector (loadf64 addr:$src)),
2198 SSE_splat_lo_mask)))]>;
2201 let isTwoAddress = 1 in {
2202 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
2203 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2204 "addsubps\t{$src2, $dst|$dst, $src2}",
2205 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2207 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
2208 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2209 "addsubps\t{$src2, $dst|$dst, $src2}",
2210 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2211 (load addr:$src2)))]>;
2212 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
2213 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2214 "addsubpd\t{$src2, $dst|$dst, $src2}",
2215 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2217 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
2218 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2219 "addsubpd\t{$src2, $dst|$dst, $src2}",
2220 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2221 (load addr:$src2)))]>;
2224 def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2225 "lddqu\t{$src, $dst|$dst, $src}",
2226 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2229 class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
2230 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2231 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2232 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2233 class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
2234 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2235 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2236 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (load addr:$src2))))]>;
2237 class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
2238 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2239 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2240 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2241 class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
2242 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2243 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2244 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (load addr:$src2))))]>;
2246 let isTwoAddress = 1 in {
2247 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2248 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2249 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2250 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2251 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2252 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2253 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2254 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2257 // Thread synchronization
2258 def MONITOR : I<0xC8, RawFrm, (outs), (ins), "monitor",
2259 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
2260 def MWAIT : I<0xC9, RawFrm, (outs), (ins), "mwait",
2261 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2263 // vector_shuffle v1, <undef> <1, 1, 3, 3>
2264 let AddedComplexity = 15 in
2265 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2266 MOVSHDUP_shuffle_mask)),
2267 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2268 let AddedComplexity = 20 in
2269 def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
2270 MOVSHDUP_shuffle_mask)),
2271 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2273 // vector_shuffle v1, <undef> <0, 0, 2, 2>
2274 let AddedComplexity = 15 in
2275 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2276 MOVSLDUP_shuffle_mask)),
2277 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2278 let AddedComplexity = 20 in
2279 def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
2280 MOVSLDUP_shuffle_mask)),
2281 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2283 //===----------------------------------------------------------------------===//
2284 // SSSE3 Instructions
2285 //===----------------------------------------------------------------------===//
2287 // SSE3 Instruction Templates:
2289 // SS38I - SSSE3 instructions with T8 prefix.
2290 // SS3AI - SSSE3 instructions with TA prefix.
2292 class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
2294 : I<o, F, outs, ins, asm, pattern>, T8, Requires<[HasSSSE3]>;
2295 class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
2297 : I<o, F, outs, ins, asm, pattern>, TA, Requires<[HasSSSE3]>;
2299 /// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
2300 let isTwoAddress = 1 in {
2301 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2302 Intrinsic IntId64, Intrinsic IntId128,
2303 bit Commutable = 0> {
2304 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2305 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2306 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2307 let isCommutable = Commutable;
2309 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2310 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2312 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2314 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2316 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2317 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2319 let isCommutable = Commutable;
2321 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2323 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2326 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
2330 /// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2331 let isTwoAddress = 1 in {
2332 multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2333 Intrinsic IntId64, Intrinsic IntId128,
2334 bit Commutable = 0> {
2335 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2337 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2338 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2339 let isCommutable = Commutable;
2341 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2343 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2346 (bitconvert (memopv4i16 addr:$src))))]>;
2348 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2350 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2351 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2353 let isCommutable = Commutable;
2355 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2357 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2360 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2364 /// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2365 let isTwoAddress = 1 in {
2366 multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2367 Intrinsic IntId64, Intrinsic IntId128,
2368 bit Commutable = 0> {
2369 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2371 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2372 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2373 let isCommutable = Commutable;
2375 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2377 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2380 (bitconvert (memopv2i32 addr:$src))))]>;
2382 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2384 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2385 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2387 let isCommutable = Commutable;
2389 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2391 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2394 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2398 defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2399 int_x86_ssse3_pabs_b,
2400 int_x86_ssse3_pabs_b_128>;
2401 defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2402 int_x86_ssse3_pabs_w,
2403 int_x86_ssse3_pabs_w_128>;
2404 defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2405 int_x86_ssse3_pabs_d,
2406 int_x86_ssse3_pabs_d_128>;
2408 /// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2409 let isTwoAddress = 1 in {
2410 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2411 Intrinsic IntId64, Intrinsic IntId128,
2412 bit Commutable = 0> {
2413 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2414 (ins VR64:$src1, VR64:$src2),
2415 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2416 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2417 let isCommutable = Commutable;
2419 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2420 (ins VR64:$src1, i64mem:$src2),
2421 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2423 (IntId64 VR64:$src1,
2424 (bitconvert (memopv8i8 addr:$src2))))]>;
2426 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2427 (ins VR128:$src1, VR128:$src2),
2428 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2429 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2431 let isCommutable = Commutable;
2433 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2434 (ins VR128:$src1, i128mem:$src2),
2435 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2437 (IntId128 VR128:$src1,
2438 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2442 /// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2443 let isTwoAddress = 1 in {
2444 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2445 Intrinsic IntId64, Intrinsic IntId128,
2446 bit Commutable = 0> {
2447 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2448 (ins VR64:$src1, VR64:$src2),
2449 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2450 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2451 let isCommutable = Commutable;
2453 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2454 (ins VR64:$src1, i64mem:$src2),
2455 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2457 (IntId64 VR64:$src1,
2458 (bitconvert (memopv4i16 addr:$src2))))]>;
2460 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2461 (ins VR128:$src1, VR128:$src2),
2462 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2463 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2465 let isCommutable = Commutable;
2467 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2468 (ins VR128:$src1, i128mem:$src2),
2469 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2471 (IntId128 VR128:$src1,
2472 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2476 /// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2477 let isTwoAddress = 1 in {
2478 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2479 Intrinsic IntId64, Intrinsic IntId128,
2480 bit Commutable = 0> {
2481 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2482 (ins VR64:$src1, VR64:$src2),
2483 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2484 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2485 let isCommutable = Commutable;
2487 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2488 (ins VR64:$src1, i64mem:$src2),
2489 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2491 (IntId64 VR64:$src1,
2492 (bitconvert (memopv2i32 addr:$src2))))]>;
2494 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2495 (ins VR128:$src1, VR128:$src2),
2496 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2497 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2499 let isCommutable = Commutable;
2501 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2502 (ins VR128:$src1, i128mem:$src2),
2503 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2505 (IntId128 VR128:$src1,
2506 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2510 defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2511 int_x86_ssse3_phadd_w,
2512 int_x86_ssse3_phadd_w_128, 1>;
2513 defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2514 int_x86_ssse3_phadd_d,
2515 int_x86_ssse3_phadd_d_128, 1>;
2516 defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2517 int_x86_ssse3_phadd_sw,
2518 int_x86_ssse3_phadd_sw_128, 1>;
2519 defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2520 int_x86_ssse3_phsub_w,
2521 int_x86_ssse3_phsub_w_128>;
2522 defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2523 int_x86_ssse3_phsub_d,
2524 int_x86_ssse3_phsub_d_128>;
2525 defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2526 int_x86_ssse3_phsub_sw,
2527 int_x86_ssse3_phsub_sw_128>;
2528 defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2529 int_x86_ssse3_pmadd_ub_sw,
2530 int_x86_ssse3_pmadd_ub_sw_128, 1>;
2531 defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2532 int_x86_ssse3_pmul_hr_sw,
2533 int_x86_ssse3_pmul_hr_sw_128, 1>;
2534 defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2535 int_x86_ssse3_pshuf_b,
2536 int_x86_ssse3_pshuf_b_128>;
2537 defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2538 int_x86_ssse3_psign_b,
2539 int_x86_ssse3_psign_b_128>;
2540 defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2541 int_x86_ssse3_psign_w,
2542 int_x86_ssse3_psign_w_128>;
2543 defm PSIGND : SS3I_binop_rm_int_32<0x09, "psignd",
2544 int_x86_ssse3_psign_d,
2545 int_x86_ssse3_psign_d_128>;
2547 let isTwoAddress = 1 in {
2548 def PALIGN64rr : SS38I<0x0F, MRMSrcReg, (outs VR64:$dst),
2549 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
2550 "palignr\t{$src2, $dst|$dst, $src2}",
2552 (int_x86_ssse3_palign_r
2553 VR64:$src1, VR64:$src2,
2555 def PALIGN64rm : SS38I<0x0F, MRMSrcReg, (outs VR64:$dst),
2556 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
2557 "palignr\t{$src2, $dst|$dst, $src2}",
2559 (int_x86_ssse3_palign_r
2561 (bitconvert (memopv2i32 addr:$src2)),
2564 def PALIGN128rr : SS38I<0x0F, MRMSrcReg, (outs VR128:$dst),
2565 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
2566 "palignr\t{$src2, $dst|$dst, $src2}",
2568 (int_x86_ssse3_palign_r_128
2569 VR128:$src1, VR128:$src2,
2570 imm:$src3))]>, OpSize;
2571 def PALIGN128rm : SS38I<0x0F, MRMSrcReg, (outs VR128:$dst),
2572 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
2573 "palignr\t{$src2, $dst|$dst, $src2}",
2575 (int_x86_ssse3_palign_r_128
2577 (bitconvert (memopv4i32 addr:$src2)),
2578 imm:$src3))]>, OpSize;
2581 //===----------------------------------------------------------------------===//
2582 // Non-Instruction Patterns
2583 //===----------------------------------------------------------------------===//
2585 // 128-bit vector undef's.
2586 def : Pat<(v2f64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2587 def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2588 def : Pat<(v8i16 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2589 def : Pat<(v4i32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2590 def : Pat<(v2i64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2592 // 128-bit vector all zero's.
2593 def : Pat<(v16i8 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2594 def : Pat<(v8i16 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2595 def : Pat<(v4i32 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2596 def : Pat<(v2i64 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2597 def : Pat<(v2f64 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2599 // 128-bit vector all one's.
2600 def : Pat<(v16i8 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2601 def : Pat<(v8i16 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2602 def : Pat<(v4i32 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2603 def : Pat<(v2i64 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2604 def : Pat<(v4f32 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE1]>;
2607 // Scalar to v8i16 / v16i8. The source may be a GR32, but only the lower 8 or
2609 def : Pat<(v8i16 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2610 Requires<[HasSSE2]>;
2611 def : Pat<(v16i8 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2612 Requires<[HasSSE2]>;
2615 let Predicates = [HasSSE2] in {
2616 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2617 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2618 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2619 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2620 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2621 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2622 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2623 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2624 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2625 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2626 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2627 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2628 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2629 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2630 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2631 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2632 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2633 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2634 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2635 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2636 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2637 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2638 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2639 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2640 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2641 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2642 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2643 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2644 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2645 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2648 // Move scalar to XMM zero-extended
2649 // movd to XMM register zero-extends
2650 let AddedComplexity = 15 in {
2651 def : Pat<(v8i16 (vector_shuffle immAllZerosV,
2652 (v8i16 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2653 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2654 def : Pat<(v16i8 (vector_shuffle immAllZerosV,
2655 (v16i8 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2656 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2657 // Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
2658 def : Pat<(v2f64 (vector_shuffle immAllZerosV,
2659 (v2f64 (scalar_to_vector FR64:$src)), MOVL_shuffle_mask)),
2660 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
2661 def : Pat<(v4f32 (vector_shuffle immAllZerosV,
2662 (v4f32 (scalar_to_vector FR32:$src)), MOVL_shuffle_mask)),
2663 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>;
2666 // Splat v2f64 / v2i64
2667 let AddedComplexity = 10 in {
2668 def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2669 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2670 def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2671 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2672 def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2673 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2674 def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2675 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2679 def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), SSE_splat_mask:$sm),
2680 (SHUFPSrri VR128:$src, VR128:$src, SSE_splat_mask:$sm)>,
2681 Requires<[HasSSE1]>;
2683 // Special unary SHUFPSrri case.
2684 // FIXME: when we want non two-address code, then we should use PSHUFD?
2685 def : Pat<(vector_shuffle (v4f32 VR128:$src1), (undef),
2686 SHUFP_unary_shuffle_mask:$sm),
2687 (SHUFPSrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2688 Requires<[HasSSE1]>;
2689 // Special unary SHUFPDrri case.
2690 def : Pat<(vector_shuffle (v2f64 VR128:$src1), (undef),
2691 SHUFP_unary_shuffle_mask:$sm),
2692 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2693 Requires<[HasSSE2]>;
2694 // Unary v4f32 shuffle with PSHUF* in order to fold a load.
2695 def : Pat<(vector_shuffle (memopv4f32 addr:$src1), (undef),
2696 SHUFP_unary_shuffle_mask:$sm),
2697 (PSHUFDmi addr:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2698 Requires<[HasSSE2]>;
2699 // Special binary v4i32 shuffle cases with SHUFPS.
2700 def : Pat<(vector_shuffle (v4i32 VR128:$src1), (v4i32 VR128:$src2),
2701 PSHUFD_binary_shuffle_mask:$sm),
2702 (SHUFPSrri VR128:$src1, VR128:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2703 Requires<[HasSSE2]>;
2704 def : Pat<(vector_shuffle (v4i32 VR128:$src1),
2705 (bc_v4i32 (memopv2i64 addr:$src2)), PSHUFD_binary_shuffle_mask:$sm),
2706 (SHUFPSrmi VR128:$src1, addr:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2707 Requires<[HasSSE2]>;
2709 // vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2710 let AddedComplexity = 10 in {
2711 def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2712 UNPCKL_v_undef_shuffle_mask)),
2713 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2714 def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2715 UNPCKL_v_undef_shuffle_mask)),
2716 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2717 def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2718 UNPCKL_v_undef_shuffle_mask)),
2719 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2720 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2721 UNPCKL_v_undef_shuffle_mask)),
2722 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2725 // vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2726 let AddedComplexity = 10 in {
2727 def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2728 UNPCKH_v_undef_shuffle_mask)),
2729 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2730 def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2731 UNPCKH_v_undef_shuffle_mask)),
2732 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2733 def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2734 UNPCKH_v_undef_shuffle_mask)),
2735 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2736 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2737 UNPCKH_v_undef_shuffle_mask)),
2738 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2741 let AddedComplexity = 15 in {
2742 // vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2743 def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2744 MOVHP_shuffle_mask)),
2745 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2747 // vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2748 def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2749 MOVHLPS_shuffle_mask)),
2750 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2752 // vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2753 def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2754 MOVHLPS_v_undef_shuffle_mask)),
2755 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2756 def : Pat<(v4i32 (vector_shuffle VR128:$src1, (undef),
2757 MOVHLPS_v_undef_shuffle_mask)),
2758 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2761 let AddedComplexity = 20 in {
2762 // vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2763 // vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
2764 def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
2765 MOVLP_shuffle_mask)),
2766 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
2767 def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
2768 MOVLP_shuffle_mask)),
2769 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2770 def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
2771 MOVHP_shuffle_mask)),
2772 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
2773 def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
2774 MOVHP_shuffle_mask)),
2775 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2777 def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
2778 MOVLP_shuffle_mask)),
2779 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2780 def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
2781 MOVLP_shuffle_mask)),
2782 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2783 def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
2784 MOVHP_shuffle_mask)),
2785 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
2786 def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
2787 MOVLP_shuffle_mask)),
2788 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2791 let AddedComplexity = 15 in {
2792 // Setting the lowest element in the vector.
2793 def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2794 MOVL_shuffle_mask)),
2795 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2796 def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2797 MOVL_shuffle_mask)),
2798 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2800 // vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
2801 def : Pat<(v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
2802 MOVLP_shuffle_mask)),
2803 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2804 def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2805 MOVLP_shuffle_mask)),
2806 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2809 // Set lowest element and zero upper elements.
2810 let AddedComplexity = 20 in
2811 def : Pat<(bc_v2i64 (vector_shuffle immAllZerosV,
2812 (v2f64 (scalar_to_vector (loadf64 addr:$src))),
2813 MOVL_shuffle_mask)),
2814 (MOVZQI2PQIrm addr:$src)>, Requires<[HasSSE2]>;
2816 // FIXME: Temporary workaround since 2-wide shuffle is broken.
2817 def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2),
2818 (v2f64 (MOVLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2819 def : Pat<(int_x86_sse2_loadh_pd VR128:$src1, addr:$src2),
2820 (v2f64 (MOVHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2821 def : Pat<(int_x86_sse2_loadl_pd VR128:$src1, addr:$src2),
2822 (v2f64 (MOVLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2823 def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, VR128:$src2, imm:$src3),
2824 (v2f64 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$src3))>,
2825 Requires<[HasSSE2]>;
2826 def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, (load addr:$src2), imm:$src3),
2827 (v2f64 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$src3))>,
2828 Requires<[HasSSE2]>;
2829 def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, VR128:$src2),
2830 (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2831 def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, (load addr:$src2)),
2832 (v2f64 (UNPCKHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2833 def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, VR128:$src2),
2834 (v2f64 (UNPCKLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2835 def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, (load addr:$src2)),
2836 (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2837 def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, VR128:$src2),
2838 (v2i64 (PUNPCKHQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2839 def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, (load addr:$src2)),
2840 (v2i64 (PUNPCKHQDQrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2841 def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, VR128:$src2),
2842 (v2i64 (PUNPCKLQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2843 def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, (load addr:$src2)),
2844 (PUNPCKLQDQrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2846 // Some special case pandn patterns.
2847 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
2849 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2850 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
2852 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2853 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
2855 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2857 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
2858 (memopv2i64 addr:$src2))),
2859 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2860 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
2861 (memopv2i64 addr:$src2))),
2862 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2863 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
2864 (memopv2i64 addr:$src2))),
2865 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2867 // Use movaps / movups for SSE integer load / store (one byte shorter).
2868 def : Pat<(alignedloadv4i32 addr:$src),
2869 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
2870 def : Pat<(loadv4i32 addr:$src),
2871 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
2872 def : Pat<(alignedloadv2i64 addr:$src),
2873 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
2874 def : Pat<(loadv2i64 addr:$src),
2875 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
2877 def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
2878 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2879 def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
2880 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2881 def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
2882 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2883 def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
2884 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2885 def : Pat<(store (v2i64 VR128:$src), addr:$dst),
2886 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2887 def : Pat<(store (v4i32 VR128:$src), addr:$dst),
2888 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2889 def : Pat<(store (v8i16 VR128:$src), addr:$dst),
2890 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2891 def : Pat<(store (v16i8 VR128:$src), addr:$dst),
2892 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2894 // (vextract (v4i32 bc (v4f32 s2v (f32 load $addr))), 0) -> (i32 load $addr)
2895 def : Pat<(vector_extract
2896 (bc_v4i32 (v4f32 (scalar_to_vector (loadf32 addr:$src)))), (iPTR 0)),
2897 (MOV32rm addr:$src)>, Requires<[HasSSE2]>;
2898 def : Pat<(vector_extract
2899 (bc_v2i64 (v2f64 (scalar_to_vector (loadf64 addr:$src)))), (iPTR 0)),
2900 (MOV64rm addr:$src)>, Requires<[HasSSE2, In64BitMode]>;