1 //====- X86InstrSSE.td - Describe the X86 Instruction Set --*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // 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> ]>;
23 def SDTX86VFCMP : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<1, 2>,
24 SDTCisFP<1>, SDTCisVT<3, i8>]>;
26 def X86fmin : SDNode<"X86ISD::FMIN", SDTFPBinOp>;
27 def X86fmax : SDNode<"X86ISD::FMAX", SDTFPBinOp>;
28 def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
29 [SDNPCommutative, SDNPAssociative]>;
30 def X86for : SDNode<"X86ISD::FOR", SDTFPBinOp,
31 [SDNPCommutative, SDNPAssociative]>;
32 def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
33 [SDNPCommutative, SDNPAssociative]>;
34 def X86frsqrt : SDNode<"X86ISD::FRSQRT", SDTFPUnaryOp>;
35 def X86frcp : SDNode<"X86ISD::FRCP", SDTFPUnaryOp>;
36 def X86fsrl : SDNode<"X86ISD::FSRL", SDTX86FPShiftOp>;
37 def X86comi : SDNode<"X86ISD::COMI", SDTX86CmpTest>;
38 def X86ucomi : SDNode<"X86ISD::UCOMI", SDTX86CmpTest>;
39 def X86pshufb : SDNode<"X86ISD::PSHUFB",
40 SDTypeProfile<1, 2, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
42 def X86pextrb : SDNode<"X86ISD::PEXTRB",
43 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
44 def X86pextrw : SDNode<"X86ISD::PEXTRW",
45 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
46 def X86pinsrb : SDNode<"X86ISD::PINSRB",
47 SDTypeProfile<1, 3, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
48 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
49 def X86pinsrw : SDNode<"X86ISD::PINSRW",
50 SDTypeProfile<1, 3, [SDTCisVT<0, v8i16>, SDTCisSameAs<0,1>,
51 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
52 def X86insrtps : SDNode<"X86ISD::INSERTPS",
53 SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, SDTCisSameAs<0,1>,
54 SDTCisVT<2, v4f32>, SDTCisPtrTy<3>]>>;
55 def X86vzmovl : SDNode<"X86ISD::VZEXT_MOVL",
56 SDTypeProfile<1, 1, [SDTCisSameAs<0,1>]>>;
57 def X86vzload : SDNode<"X86ISD::VZEXT_LOAD", SDTLoad,
58 [SDNPHasChain, SDNPMayLoad]>;
59 def X86vshl : SDNode<"X86ISD::VSHL", SDTIntShiftOp>;
60 def X86vshr : SDNode<"X86ISD::VSRL", SDTIntShiftOp>;
61 def X86cmpps : SDNode<"X86ISD::CMPPS", SDTX86VFCMP>;
62 def X86cmppd : SDNode<"X86ISD::CMPPD", SDTX86VFCMP>;
63 def X86pcmpeqb : SDNode<"X86ISD::PCMPEQB", SDTIntBinOp, [SDNPCommutative]>;
64 def X86pcmpeqw : SDNode<"X86ISD::PCMPEQW", SDTIntBinOp, [SDNPCommutative]>;
65 def X86pcmpeqd : SDNode<"X86ISD::PCMPEQD", SDTIntBinOp, [SDNPCommutative]>;
66 def X86pcmpeqq : SDNode<"X86ISD::PCMPEQQ", SDTIntBinOp, [SDNPCommutative]>;
67 def X86pcmpgtb : SDNode<"X86ISD::PCMPGTB", SDTIntBinOp>;
68 def X86pcmpgtw : SDNode<"X86ISD::PCMPGTW", SDTIntBinOp>;
69 def X86pcmpgtd : SDNode<"X86ISD::PCMPGTD", SDTIntBinOp>;
70 def X86pcmpgtq : SDNode<"X86ISD::PCMPGTQ", SDTIntBinOp>;
72 def SDTX86CmpPTest : SDTypeProfile<0, 2, [SDTCisVT<0, v4f32>,
74 def X86ptest : SDNode<"X86ISD::PTEST", SDTX86CmpPTest>;
76 //===----------------------------------------------------------------------===//
77 // SSE Complex Patterns
78 //===----------------------------------------------------------------------===//
80 // These are 'extloads' from a scalar to the low element of a vector, zeroing
81 // the top elements. These are used for the SSE 'ss' and 'sd' instruction
83 def sse_load_f32 : ComplexPattern<v4f32, 5, "SelectScalarSSELoad", [],
84 [SDNPHasChain, SDNPMayLoad]>;
85 def sse_load_f64 : ComplexPattern<v2f64, 5, "SelectScalarSSELoad", [],
86 [SDNPHasChain, SDNPMayLoad]>;
88 def ssmem : Operand<v4f32> {
89 let PrintMethod = "printf32mem";
90 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
91 let ParserMatchClass = X86MemAsmOperand;
93 def sdmem : Operand<v2f64> {
94 let PrintMethod = "printf64mem";
95 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
96 let ParserMatchClass = X86MemAsmOperand;
99 //===----------------------------------------------------------------------===//
100 // SSE pattern fragments
101 //===----------------------------------------------------------------------===//
103 def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
104 def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
105 def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
106 def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
108 // Like 'store', but always requires vector alignment.
109 def alignedstore : PatFrag<(ops node:$val, node:$ptr),
110 (store node:$val, node:$ptr), [{
111 return cast<StoreSDNode>(N)->getAlignment() >= 16;
114 // Like 'load', but always requires vector alignment.
115 def alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
116 return cast<LoadSDNode>(N)->getAlignment() >= 16;
119 def alignedloadfsf32 : PatFrag<(ops node:$ptr), (f32 (alignedload node:$ptr))>;
120 def alignedloadfsf64 : PatFrag<(ops node:$ptr), (f64 (alignedload node:$ptr))>;
121 def alignedloadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (alignedload node:$ptr))>;
122 def alignedloadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (alignedload node:$ptr))>;
123 def alignedloadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (alignedload node:$ptr))>;
124 def alignedloadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (alignedload node:$ptr))>;
126 // Like 'load', but uses special alignment checks suitable for use in
127 // memory operands in most SSE instructions, which are required to
128 // be naturally aligned on some targets but not on others.
129 // FIXME: Actually implement support for targets that don't require the
130 // alignment. This probably wants a subtarget predicate.
131 def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{
132 return cast<LoadSDNode>(N)->getAlignment() >= 16;
135 def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
136 def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
137 def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
138 def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
139 def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
140 def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
141 def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
143 // SSSE3 uses MMX registers for some instructions. They aren't aligned on a
145 // FIXME: 8 byte alignment for mmx reads is not required
146 def memop64 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
147 return cast<LoadSDNode>(N)->getAlignment() >= 8;
150 def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
151 def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
152 def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
153 def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
155 def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
156 def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
157 def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
158 def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
159 def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
160 def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
162 def vzmovl_v2i64 : PatFrag<(ops node:$src),
163 (bitconvert (v2i64 (X86vzmovl
164 (v2i64 (scalar_to_vector (loadi64 node:$src))))))>;
165 def vzmovl_v4i32 : PatFrag<(ops node:$src),
166 (bitconvert (v4i32 (X86vzmovl
167 (v4i32 (scalar_to_vector (loadi32 node:$src))))))>;
169 def vzload_v2i64 : PatFrag<(ops node:$src),
170 (bitconvert (v2i64 (X86vzload node:$src)))>;
173 def fp32imm0 : PatLeaf<(f32 fpimm), [{
174 return N->isExactlyValue(+0.0);
177 def PSxLDQ_imm : SDNodeXForm<imm, [{
178 // Transformation function: imm >> 3
179 return getI32Imm(N->getZExtValue() >> 3);
182 // SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
184 def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
185 return getI8Imm(X86::getShuffleSHUFImmediate(N));
188 // SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
190 def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{
191 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
194 // SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
196 def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{
197 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
200 def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
201 (vector_shuffle node:$lhs, node:$rhs), [{
202 ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
203 return SVOp->isSplat() && SVOp->getSplatIndex() == 0;
206 def movddup : PatFrag<(ops node:$lhs, node:$rhs),
207 (vector_shuffle node:$lhs, node:$rhs), [{
208 return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N));
211 def movhlps : PatFrag<(ops node:$lhs, node:$rhs),
212 (vector_shuffle node:$lhs, node:$rhs), [{
213 return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N));
216 def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs),
217 (vector_shuffle node:$lhs, node:$rhs), [{
218 return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
221 def movhp : PatFrag<(ops node:$lhs, node:$rhs),
222 (vector_shuffle node:$lhs, node:$rhs), [{
223 return X86::isMOVHPMask(cast<ShuffleVectorSDNode>(N));
226 def movlp : PatFrag<(ops node:$lhs, node:$rhs),
227 (vector_shuffle node:$lhs, node:$rhs), [{
228 return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N));
231 def movl : PatFrag<(ops node:$lhs, node:$rhs),
232 (vector_shuffle node:$lhs, node:$rhs), [{
233 return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N));
236 def movshdup : PatFrag<(ops node:$lhs, node:$rhs),
237 (vector_shuffle node:$lhs, node:$rhs), [{
238 return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N));
241 def movsldup : PatFrag<(ops node:$lhs, node:$rhs),
242 (vector_shuffle node:$lhs, node:$rhs), [{
243 return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N));
246 def unpckl : PatFrag<(ops node:$lhs, node:$rhs),
247 (vector_shuffle node:$lhs, node:$rhs), [{
248 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
251 def unpckh : PatFrag<(ops node:$lhs, node:$rhs),
252 (vector_shuffle node:$lhs, node:$rhs), [{
253 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
256 def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
257 (vector_shuffle node:$lhs, node:$rhs), [{
258 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
261 def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
262 (vector_shuffle node:$lhs, node:$rhs), [{
263 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
266 def pshufd : PatFrag<(ops node:$lhs, node:$rhs),
267 (vector_shuffle node:$lhs, node:$rhs), [{
268 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
269 }], SHUFFLE_get_shuf_imm>;
271 def shufp : PatFrag<(ops node:$lhs, node:$rhs),
272 (vector_shuffle node:$lhs, node:$rhs), [{
273 return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N));
274 }], SHUFFLE_get_shuf_imm>;
276 def pshufhw : PatFrag<(ops node:$lhs, node:$rhs),
277 (vector_shuffle node:$lhs, node:$rhs), [{
278 return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N));
279 }], SHUFFLE_get_pshufhw_imm>;
281 def pshuflw : PatFrag<(ops node:$lhs, node:$rhs),
282 (vector_shuffle node:$lhs, node:$rhs), [{
283 return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N));
284 }], SHUFFLE_get_pshuflw_imm>;
286 //===----------------------------------------------------------------------===//
287 // SSE scalar FP Instructions
288 //===----------------------------------------------------------------------===//
290 // CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
291 // scheduler into a branch sequence.
292 // These are expanded by the scheduler.
293 let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
294 def CMOV_FR32 : I<0, Pseudo,
295 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
296 "#CMOV_FR32 PSEUDO!",
297 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
299 def CMOV_FR64 : I<0, Pseudo,
300 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
301 "#CMOV_FR64 PSEUDO!",
302 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
304 def CMOV_V4F32 : I<0, Pseudo,
305 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
306 "#CMOV_V4F32 PSEUDO!",
308 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
310 def CMOV_V2F64 : I<0, Pseudo,
311 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
312 "#CMOV_V2F64 PSEUDO!",
314 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
316 def CMOV_V2I64 : I<0, Pseudo,
317 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
318 "#CMOV_V2I64 PSEUDO!",
320 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
324 //===----------------------------------------------------------------------===//
326 //===----------------------------------------------------------------------===//
329 let neverHasSideEffects = 1 in
330 def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
331 "movss\t{$src, $dst|$dst, $src}", []>;
332 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
333 def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
334 "movss\t{$src, $dst|$dst, $src}",
335 [(set FR32:$dst, (loadf32 addr:$src))]>;
336 def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
337 "movss\t{$src, $dst|$dst, $src}",
338 [(store FR32:$src, addr:$dst)]>;
340 // Conversion instructions
341 def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
342 "cvttss2si\t{$src, $dst|$dst, $src}",
343 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
344 def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
345 "cvttss2si\t{$src, $dst|$dst, $src}",
346 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
347 def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
348 "cvtsi2ss\t{$src, $dst|$dst, $src}",
349 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
350 def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
351 "cvtsi2ss\t{$src, $dst|$dst, $src}",
352 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
354 // Match intrinsics which expect XMM operand(s).
355 def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
356 "cvtss2si\t{$src, $dst|$dst, $src}",
357 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
358 def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
359 "cvtss2si\t{$src, $dst|$dst, $src}",
360 [(set GR32:$dst, (int_x86_sse_cvtss2si
361 (load addr:$src)))]>;
363 // Match intrinisics which expect MM and XMM operand(s).
364 def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
365 "cvtps2pi\t{$src, $dst|$dst, $src}",
366 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
367 def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
368 "cvtps2pi\t{$src, $dst|$dst, $src}",
369 [(set VR64:$dst, (int_x86_sse_cvtps2pi
370 (load addr:$src)))]>;
371 def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
372 "cvttps2pi\t{$src, $dst|$dst, $src}",
373 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
374 def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
375 "cvttps2pi\t{$src, $dst|$dst, $src}",
376 [(set VR64:$dst, (int_x86_sse_cvttps2pi
377 (load addr:$src)))]>;
378 let Constraints = "$src1 = $dst" in {
379 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
380 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
381 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
382 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
384 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
385 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
386 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
387 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
388 (load addr:$src2)))]>;
391 // Aliases for intrinsics
392 def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
393 "cvttss2si\t{$src, $dst|$dst, $src}",
395 (int_x86_sse_cvttss2si VR128:$src))]>;
396 def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
397 "cvttss2si\t{$src, $dst|$dst, $src}",
399 (int_x86_sse_cvttss2si(load addr:$src)))]>;
401 let Constraints = "$src1 = $dst" in {
402 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
403 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
404 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
405 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
407 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
408 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
409 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
410 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
411 (loadi32 addr:$src2)))]>;
414 // Comparison instructions
415 let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
416 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
417 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
418 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
420 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
421 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
422 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
425 let Defs = [EFLAGS] in {
426 def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
427 "ucomiss\t{$src2, $src1|$src1, $src2}",
428 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
429 def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
430 "ucomiss\t{$src2, $src1|$src1, $src2}",
431 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
435 // Aliases to match intrinsics which expect XMM operand(s).
436 let Constraints = "$src1 = $dst" in {
437 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
438 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
440 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
441 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
442 VR128:$src, imm:$cc))]>;
443 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
444 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src,
446 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
447 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
448 (load addr:$src), imm:$cc))]>;
451 let Defs = [EFLAGS] in {
452 def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
453 "ucomiss\t{$src2, $src1|$src1, $src2}",
454 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
456 def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
457 "ucomiss\t{$src2, $src1|$src1, $src2}",
458 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
461 def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
462 "comiss\t{$src2, $src1|$src1, $src2}",
463 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
465 def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
466 "comiss\t{$src2, $src1|$src1, $src2}",
467 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
471 // Aliases of packed SSE1 instructions for scalar use. These all have names
472 // that start with 'Fs'.
474 // Alias instructions that map fld0 to pxor for sse.
475 let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1 in
476 def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
477 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
478 Requires<[HasSSE1]>, TB, OpSize;
480 // Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
482 let neverHasSideEffects = 1 in
483 def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
484 "movaps\t{$src, $dst|$dst, $src}", []>;
486 // Alias instruction to load FR32 from f128mem using movaps. Upper bits are
488 let canFoldAsLoad = 1 in
489 def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
490 "movaps\t{$src, $dst|$dst, $src}",
491 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
493 // Alias bitwise logical operations using SSE logical ops on packed FP values.
494 let Constraints = "$src1 = $dst" in {
495 let isCommutable = 1 in {
496 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
497 (ins FR32:$src1, FR32:$src2),
498 "andps\t{$src2, $dst|$dst, $src2}",
499 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
500 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
501 (ins FR32:$src1, FR32:$src2),
502 "orps\t{$src2, $dst|$dst, $src2}",
503 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
504 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
505 (ins FR32:$src1, FR32:$src2),
506 "xorps\t{$src2, $dst|$dst, $src2}",
507 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
510 def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
511 (ins FR32:$src1, f128mem:$src2),
512 "andps\t{$src2, $dst|$dst, $src2}",
513 [(set FR32:$dst, (X86fand FR32:$src1,
514 (memopfsf32 addr:$src2)))]>;
515 def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
516 (ins FR32:$src1, f128mem:$src2),
517 "orps\t{$src2, $dst|$dst, $src2}",
518 [(set FR32:$dst, (X86for FR32:$src1,
519 (memopfsf32 addr:$src2)))]>;
520 def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
521 (ins FR32:$src1, f128mem:$src2),
522 "xorps\t{$src2, $dst|$dst, $src2}",
523 [(set FR32:$dst, (X86fxor FR32:$src1,
524 (memopfsf32 addr:$src2)))]>;
526 let neverHasSideEffects = 1 in {
527 def FsANDNPSrr : PSI<0x55, MRMSrcReg,
528 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
529 "andnps\t{$src2, $dst|$dst, $src2}", []>;
531 def FsANDNPSrm : PSI<0x55, MRMSrcMem,
532 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
533 "andnps\t{$src2, $dst|$dst, $src2}", []>;
537 /// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
539 /// In addition, we also have a special variant of the scalar form here to
540 /// represent the associated intrinsic operation. This form is unlike the
541 /// plain scalar form, in that it takes an entire vector (instead of a scalar)
542 /// and leaves the top elements unmodified (therefore these cannot be commuted).
544 /// These three forms can each be reg+reg or reg+mem, so there are a total of
545 /// six "instructions".
547 let Constraints = "$src1 = $dst" in {
548 multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
549 SDNode OpNode, Intrinsic F32Int,
550 bit Commutable = 0> {
551 // Scalar operation, reg+reg.
552 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
553 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
554 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
555 let isCommutable = Commutable;
558 // Scalar operation, reg+mem.
559 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
560 (ins FR32:$src1, f32mem:$src2),
561 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
562 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
564 // Vector operation, reg+reg.
565 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
566 (ins VR128:$src1, VR128:$src2),
567 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
568 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
569 let isCommutable = Commutable;
572 // Vector operation, reg+mem.
573 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
574 (ins VR128:$src1, f128mem:$src2),
575 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
576 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
578 // Intrinsic operation, reg+reg.
579 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
580 (ins VR128:$src1, VR128:$src2),
581 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
582 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
584 // Intrinsic operation, reg+mem.
585 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
586 (ins VR128:$src1, ssmem:$src2),
587 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
588 [(set VR128:$dst, (F32Int VR128:$src1,
589 sse_load_f32:$src2))]>;
593 // Arithmetic instructions
594 defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
595 defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
596 defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
597 defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
599 /// sse1_fp_binop_rm - Other SSE1 binops
601 /// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
602 /// instructions for a full-vector intrinsic form. Operations that map
603 /// onto C operators don't use this form since they just use the plain
604 /// vector form instead of having a separate vector intrinsic form.
606 /// This provides a total of eight "instructions".
608 let Constraints = "$src1 = $dst" in {
609 multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
613 bit Commutable = 0> {
615 // Scalar operation, reg+reg.
616 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
617 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
618 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
619 let isCommutable = Commutable;
622 // Scalar operation, reg+mem.
623 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
624 (ins FR32:$src1, f32mem:$src2),
625 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
626 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
628 // Vector operation, reg+reg.
629 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
630 (ins VR128:$src1, VR128:$src2),
631 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
632 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
633 let isCommutable = Commutable;
636 // Vector operation, reg+mem.
637 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
638 (ins VR128:$src1, f128mem:$src2),
639 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
640 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
642 // Intrinsic operation, reg+reg.
643 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
644 (ins VR128:$src1, VR128:$src2),
645 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
646 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
647 let isCommutable = Commutable;
650 // Intrinsic operation, reg+mem.
651 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
652 (ins VR128:$src1, ssmem:$src2),
653 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
654 [(set VR128:$dst, (F32Int VR128:$src1,
655 sse_load_f32:$src2))]>;
657 // Vector intrinsic operation, reg+reg.
658 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
659 (ins VR128:$src1, VR128:$src2),
660 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
661 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
662 let isCommutable = Commutable;
665 // Vector intrinsic operation, reg+mem.
666 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
667 (ins VR128:$src1, f128mem:$src2),
668 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
669 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
673 defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
674 int_x86_sse_max_ss, int_x86_sse_max_ps>;
675 defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
676 int_x86_sse_min_ss, int_x86_sse_min_ps>;
678 //===----------------------------------------------------------------------===//
679 // SSE packed FP Instructions
682 let neverHasSideEffects = 1 in
683 def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
684 "movaps\t{$src, $dst|$dst, $src}", []>;
685 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
686 def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
687 "movaps\t{$src, $dst|$dst, $src}",
688 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
690 def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
691 "movaps\t{$src, $dst|$dst, $src}",
692 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
694 let neverHasSideEffects = 1 in
695 def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
696 "movups\t{$src, $dst|$dst, $src}", []>;
697 let canFoldAsLoad = 1 in
698 def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
699 "movups\t{$src, $dst|$dst, $src}",
700 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
701 def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
702 "movups\t{$src, $dst|$dst, $src}",
703 [(store (v4f32 VR128:$src), addr:$dst)]>;
705 // Intrinsic forms of MOVUPS load and store
706 let canFoldAsLoad = 1 in
707 def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
708 "movups\t{$src, $dst|$dst, $src}",
709 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
710 def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
711 "movups\t{$src, $dst|$dst, $src}",
712 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
714 let Constraints = "$src1 = $dst" in {
715 let AddedComplexity = 20 in {
716 def MOVLPSrm : PSI<0x12, MRMSrcMem,
717 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
718 "movlps\t{$src2, $dst|$dst, $src2}",
721 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
722 def MOVHPSrm : PSI<0x16, MRMSrcMem,
723 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
724 "movhps\t{$src2, $dst|$dst, $src2}",
727 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
729 } // Constraints = "$src1 = $dst"
732 def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
733 "movlps\t{$src, $dst|$dst, $src}",
734 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
735 (iPTR 0))), addr:$dst)]>;
737 // v2f64 extract element 1 is always custom lowered to unpack high to low
738 // and extract element 0 so the non-store version isn't too horrible.
739 def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
740 "movhps\t{$src, $dst|$dst, $src}",
741 [(store (f64 (vector_extract
742 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
743 (undef)), (iPTR 0))), addr:$dst)]>;
745 let Constraints = "$src1 = $dst" in {
746 let AddedComplexity = 20 in {
747 def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
748 (ins VR128:$src1, VR128:$src2),
749 "movlhps\t{$src2, $dst|$dst, $src2}",
751 (v4f32 (movhp VR128:$src1, VR128:$src2)))]>;
753 def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
754 (ins VR128:$src1, VR128:$src2),
755 "movhlps\t{$src2, $dst|$dst, $src2}",
757 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
759 } // Constraints = "$src1 = $dst"
761 let AddedComplexity = 20 in {
762 def : Pat<(v4f32 (movddup VR128:$src, (undef))),
763 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
764 def : Pat<(v2i64 (movddup VR128:$src, (undef))),
765 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
772 /// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
774 /// In addition, we also have a special variant of the scalar form here to
775 /// represent the associated intrinsic operation. This form is unlike the
776 /// plain scalar form, in that it takes an entire vector (instead of a
777 /// scalar) and leaves the top elements undefined.
779 /// And, we have a special variant form for a full-vector intrinsic form.
781 /// These four forms can each have a reg or a mem operand, so there are a
782 /// total of eight "instructions".
784 multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
788 bit Commutable = 0> {
789 // Scalar operation, reg.
790 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
791 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
792 [(set FR32:$dst, (OpNode FR32:$src))]> {
793 let isCommutable = Commutable;
796 // Scalar operation, mem.
797 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
798 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
799 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
801 // Vector operation, reg.
802 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
803 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
804 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
805 let isCommutable = Commutable;
808 // Vector operation, mem.
809 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
810 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
811 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
813 // Intrinsic operation, reg.
814 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
815 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
816 [(set VR128:$dst, (F32Int VR128:$src))]> {
817 let isCommutable = Commutable;
820 // Intrinsic operation, mem.
821 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
822 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
823 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
825 // Vector intrinsic operation, reg
826 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
827 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
828 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
829 let isCommutable = Commutable;
832 // Vector intrinsic operation, mem
833 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
834 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
835 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
839 defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
840 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
842 // Reciprocal approximations. Note that these typically require refinement
843 // in order to obtain suitable precision.
844 defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
845 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
846 defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
847 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
850 let Constraints = "$src1 = $dst" in {
851 let isCommutable = 1 in {
852 def ANDPSrr : PSI<0x54, MRMSrcReg,
853 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
854 "andps\t{$src2, $dst|$dst, $src2}",
855 [(set VR128:$dst, (v2i64
856 (and VR128:$src1, VR128:$src2)))]>;
857 def ORPSrr : PSI<0x56, MRMSrcReg,
858 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
859 "orps\t{$src2, $dst|$dst, $src2}",
860 [(set VR128:$dst, (v2i64
861 (or VR128:$src1, VR128:$src2)))]>;
862 def XORPSrr : PSI<0x57, MRMSrcReg,
863 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
864 "xorps\t{$src2, $dst|$dst, $src2}",
865 [(set VR128:$dst, (v2i64
866 (xor VR128:$src1, VR128:$src2)))]>;
869 def ANDPSrm : PSI<0x54, MRMSrcMem,
870 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
871 "andps\t{$src2, $dst|$dst, $src2}",
872 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
873 (memopv2i64 addr:$src2)))]>;
874 def ORPSrm : PSI<0x56, MRMSrcMem,
875 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
876 "orps\t{$src2, $dst|$dst, $src2}",
877 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
878 (memopv2i64 addr:$src2)))]>;
879 def XORPSrm : PSI<0x57, MRMSrcMem,
880 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
881 "xorps\t{$src2, $dst|$dst, $src2}",
882 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
883 (memopv2i64 addr:$src2)))]>;
884 def ANDNPSrr : PSI<0x55, MRMSrcReg,
885 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
886 "andnps\t{$src2, $dst|$dst, $src2}",
888 (v2i64 (and (xor VR128:$src1,
889 (bc_v2i64 (v4i32 immAllOnesV))),
891 def ANDNPSrm : PSI<0x55, MRMSrcMem,
892 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
893 "andnps\t{$src2, $dst|$dst, $src2}",
895 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
896 (bc_v2i64 (v4i32 immAllOnesV))),
897 (memopv2i64 addr:$src2))))]>;
900 let Constraints = "$src1 = $dst" in {
901 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
902 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
903 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
904 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
905 VR128:$src, imm:$cc))]>;
906 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
907 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
908 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
909 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
910 (memop addr:$src), imm:$cc))]>;
912 def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
913 (CMPPSrri VR128:$src1, VR128:$src2, imm:$cc)>;
914 def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
915 (CMPPSrmi VR128:$src1, addr:$src2, imm:$cc)>;
917 // Shuffle and unpack instructions
918 let Constraints = "$src1 = $dst" in {
919 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
920 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
921 (outs VR128:$dst), (ins VR128:$src1,
922 VR128:$src2, i8imm:$src3),
923 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
925 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
926 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
927 (outs VR128:$dst), (ins VR128:$src1,
928 f128mem:$src2, i8imm:$src3),
929 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
932 VR128:$src1, (memopv4f32 addr:$src2))))]>;
934 let AddedComplexity = 10 in {
935 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
936 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
937 "unpckhps\t{$src2, $dst|$dst, $src2}",
939 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
940 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
941 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
942 "unpckhps\t{$src2, $dst|$dst, $src2}",
944 (v4f32 (unpckh VR128:$src1,
945 (memopv4f32 addr:$src2))))]>;
947 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
948 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
949 "unpcklps\t{$src2, $dst|$dst, $src2}",
951 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
952 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
953 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
954 "unpcklps\t{$src2, $dst|$dst, $src2}",
956 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
958 } // Constraints = "$src1 = $dst"
961 def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
962 "movmskps\t{$src, $dst|$dst, $src}",
963 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
964 def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
965 "movmskpd\t{$src, $dst|$dst, $src}",
966 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
968 // Prefetch intrinsic.
969 def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
970 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
971 def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
972 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
973 def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
974 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
975 def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
976 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
978 // Non-temporal stores
979 def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
980 "movntps\t{$src, $dst|$dst, $src}",
981 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
983 // Load, store, and memory fence
984 def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
987 def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
988 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
989 def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
990 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
992 // Alias instructions that map zero vector to pxor / xorp* for sse.
993 // We set canFoldAsLoad because this can be converted to a constant-pool
994 // load of an all-zeros value if folding it would be beneficial.
995 let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
997 def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
999 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
1001 let Predicates = [HasSSE1] in {
1002 def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
1003 def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1004 def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1005 def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1006 def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
1009 // FR32 to 128-bit vector conversion.
1010 let isAsCheapAsAMove = 1 in
1011 def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
1012 "movss\t{$src, $dst|$dst, $src}",
1014 (v4f32 (scalar_to_vector FR32:$src)))]>;
1015 def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
1016 "movss\t{$src, $dst|$dst, $src}",
1018 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
1020 // FIXME: may not be able to eliminate this movss with coalescing the src and
1021 // dest register classes are different. We really want to write this pattern
1023 // def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1024 // (f32 FR32:$src)>;
1025 let isAsCheapAsAMove = 1 in
1026 def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
1027 "movss\t{$src, $dst|$dst, $src}",
1028 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
1030 def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
1031 "movss\t{$src, $dst|$dst, $src}",
1032 [(store (f32 (vector_extract (v4f32 VR128:$src),
1033 (iPTR 0))), addr:$dst)]>;
1036 // Move to lower bits of a VR128, leaving upper bits alone.
1037 // Three operand (but two address) aliases.
1038 let Constraints = "$src1 = $dst" in {
1039 let neverHasSideEffects = 1 in
1040 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
1041 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
1042 "movss\t{$src2, $dst|$dst, $src2}", []>;
1044 let AddedComplexity = 15 in
1045 def MOVLPSrr : SSI<0x10, MRMSrcReg,
1046 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1047 "movss\t{$src2, $dst|$dst, $src2}",
1049 (v4f32 (movl VR128:$src1, VR128:$src2)))]>;
1052 // Move to lower bits of a VR128 and zeroing upper bits.
1053 // Loading from memory automatically zeroing upper bits.
1054 let AddedComplexity = 20 in
1055 def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
1056 "movss\t{$src, $dst|$dst, $src}",
1057 [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector
1058 (loadf32 addr:$src))))))]>;
1060 def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
1061 (MOVZSS2PSrm addr:$src)>;
1063 //===---------------------------------------------------------------------===//
1064 // SSE2 Instructions
1065 //===---------------------------------------------------------------------===//
1067 // Move Instructions
1068 let neverHasSideEffects = 1 in
1069 def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1070 "movsd\t{$src, $dst|$dst, $src}", []>;
1071 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
1072 def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
1073 "movsd\t{$src, $dst|$dst, $src}",
1074 [(set FR64:$dst, (loadf64 addr:$src))]>;
1075 def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
1076 "movsd\t{$src, $dst|$dst, $src}",
1077 [(store FR64:$src, addr:$dst)]>;
1079 // Conversion instructions
1080 def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
1081 "cvttsd2si\t{$src, $dst|$dst, $src}",
1082 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
1083 def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
1084 "cvttsd2si\t{$src, $dst|$dst, $src}",
1085 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
1086 def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
1087 "cvtsd2ss\t{$src, $dst|$dst, $src}",
1088 [(set FR32:$dst, (fround FR64:$src))]>;
1089 def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
1090 "cvtsd2ss\t{$src, $dst|$dst, $src}",
1091 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
1092 def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
1093 "cvtsi2sd\t{$src, $dst|$dst, $src}",
1094 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
1095 def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
1096 "cvtsi2sd\t{$src, $dst|$dst, $src}",
1097 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1099 // SSE2 instructions with XS prefix
1100 def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
1101 "cvtss2sd\t{$src, $dst|$dst, $src}",
1102 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1103 Requires<[HasSSE2]>;
1104 def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
1105 "cvtss2sd\t{$src, $dst|$dst, $src}",
1106 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1107 Requires<[HasSSE2]>;
1109 // Match intrinsics which expect XMM operand(s).
1110 def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
1111 "cvtsd2si\t{$src, $dst|$dst, $src}",
1112 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
1113 def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
1114 "cvtsd2si\t{$src, $dst|$dst, $src}",
1115 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1116 (load addr:$src)))]>;
1118 // Match intrinisics which expect MM and XMM operand(s).
1119 def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1120 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1121 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1122 def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1123 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1124 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
1125 (memop addr:$src)))]>;
1126 def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1127 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1128 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1129 def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1130 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1131 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
1132 (memop addr:$src)))]>;
1133 def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1134 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1135 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1136 def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1137 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1138 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
1139 (load addr:$src)))]>;
1141 // Aliases for intrinsics
1142 def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
1143 "cvttsd2si\t{$src, $dst|$dst, $src}",
1145 (int_x86_sse2_cvttsd2si VR128:$src))]>;
1146 def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
1147 "cvttsd2si\t{$src, $dst|$dst, $src}",
1148 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1149 (load addr:$src)))]>;
1151 // Comparison instructions
1152 let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
1153 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
1154 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
1155 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
1157 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
1158 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
1159 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
1162 let Defs = [EFLAGS] in {
1163 def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
1164 "ucomisd\t{$src2, $src1|$src1, $src2}",
1165 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
1166 def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
1167 "ucomisd\t{$src2, $src1|$src1, $src2}",
1168 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
1169 (implicit EFLAGS)]>;
1170 } // Defs = [EFLAGS]
1172 // Aliases to match intrinsics which expect XMM operand(s).
1173 let Constraints = "$src1 = $dst" in {
1174 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
1175 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
1177 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
1178 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1179 VR128:$src, imm:$cc))]>;
1180 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
1181 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src,
1183 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
1184 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1185 (load addr:$src), imm:$cc))]>;
1188 let Defs = [EFLAGS] in {
1189 def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1190 "ucomisd\t{$src2, $src1|$src1, $src2}",
1191 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1192 (implicit EFLAGS)]>;
1193 def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
1194 "ucomisd\t{$src2, $src1|$src1, $src2}",
1195 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1196 (implicit EFLAGS)]>;
1198 def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1199 "comisd\t{$src2, $src1|$src1, $src2}",
1200 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1201 (implicit EFLAGS)]>;
1202 def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1203 "comisd\t{$src2, $src1|$src1, $src2}",
1204 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
1205 (implicit EFLAGS)]>;
1206 } // Defs = [EFLAGS]
1208 // Aliases of packed SSE2 instructions for scalar use. These all have names
1209 // that start with 'Fs'.
1211 // Alias instructions that map fld0 to pxor for sse.
1212 let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1 in
1213 def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
1214 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
1215 Requires<[HasSSE2]>, TB, OpSize;
1217 // Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1219 let neverHasSideEffects = 1 in
1220 def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1221 "movapd\t{$src, $dst|$dst, $src}", []>;
1223 // Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1225 let canFoldAsLoad = 1 in
1226 def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
1227 "movapd\t{$src, $dst|$dst, $src}",
1228 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
1230 // Alias bitwise logical operations using SSE logical ops on packed FP values.
1231 let Constraints = "$src1 = $dst" in {
1232 let isCommutable = 1 in {
1233 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1234 (ins FR64:$src1, FR64:$src2),
1235 "andpd\t{$src2, $dst|$dst, $src2}",
1236 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
1237 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1238 (ins FR64:$src1, FR64:$src2),
1239 "orpd\t{$src2, $dst|$dst, $src2}",
1240 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
1241 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1242 (ins FR64:$src1, FR64:$src2),
1243 "xorpd\t{$src2, $dst|$dst, $src2}",
1244 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1247 def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1248 (ins FR64:$src1, f128mem:$src2),
1249 "andpd\t{$src2, $dst|$dst, $src2}",
1250 [(set FR64:$dst, (X86fand FR64:$src1,
1251 (memopfsf64 addr:$src2)))]>;
1252 def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1253 (ins FR64:$src1, f128mem:$src2),
1254 "orpd\t{$src2, $dst|$dst, $src2}",
1255 [(set FR64:$dst, (X86for FR64:$src1,
1256 (memopfsf64 addr:$src2)))]>;
1257 def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1258 (ins FR64:$src1, f128mem:$src2),
1259 "xorpd\t{$src2, $dst|$dst, $src2}",
1260 [(set FR64:$dst, (X86fxor FR64:$src1,
1261 (memopfsf64 addr:$src2)))]>;
1263 let neverHasSideEffects = 1 in {
1264 def FsANDNPDrr : PDI<0x55, MRMSrcReg,
1265 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1266 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
1268 def FsANDNPDrm : PDI<0x55, MRMSrcMem,
1269 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
1270 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
1274 /// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1276 /// In addition, we also have a special variant of the scalar form here to
1277 /// represent the associated intrinsic operation. This form is unlike the
1278 /// plain scalar form, in that it takes an entire vector (instead of a scalar)
1279 /// and leaves the top elements unmodified (therefore these cannot be commuted).
1281 /// These three forms can each be reg+reg or reg+mem, so there are a total of
1282 /// six "instructions".
1284 let Constraints = "$src1 = $dst" in {
1285 multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1286 SDNode OpNode, Intrinsic F64Int,
1287 bit Commutable = 0> {
1288 // Scalar operation, reg+reg.
1289 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1290 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1291 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1292 let isCommutable = Commutable;
1295 // Scalar operation, reg+mem.
1296 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1297 (ins FR64:$src1, f64mem:$src2),
1298 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1299 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1301 // Vector operation, reg+reg.
1302 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1303 (ins VR128:$src1, VR128:$src2),
1304 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1305 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1306 let isCommutable = Commutable;
1309 // Vector operation, reg+mem.
1310 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1311 (ins VR128:$src1, f128mem:$src2),
1312 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1313 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
1315 // Intrinsic operation, reg+reg.
1316 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1317 (ins VR128:$src1, VR128:$src2),
1318 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1319 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
1321 // Intrinsic operation, reg+mem.
1322 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1323 (ins VR128:$src1, sdmem:$src2),
1324 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1325 [(set VR128:$dst, (F64Int VR128:$src1,
1326 sse_load_f64:$src2))]>;
1330 // Arithmetic instructions
1331 defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1332 defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1333 defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1334 defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1336 /// sse2_fp_binop_rm - Other SSE2 binops
1338 /// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1339 /// instructions for a full-vector intrinsic form. Operations that map
1340 /// onto C operators don't use this form since they just use the plain
1341 /// vector form instead of having a separate vector intrinsic form.
1343 /// This provides a total of eight "instructions".
1345 let Constraints = "$src1 = $dst" in {
1346 multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1350 bit Commutable = 0> {
1352 // Scalar operation, reg+reg.
1353 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1354 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1355 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1356 let isCommutable = Commutable;
1359 // Scalar operation, reg+mem.
1360 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1361 (ins FR64:$src1, f64mem:$src2),
1362 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1363 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1365 // Vector operation, reg+reg.
1366 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1367 (ins VR128:$src1, VR128:$src2),
1368 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1369 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1370 let isCommutable = Commutable;
1373 // Vector operation, reg+mem.
1374 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1375 (ins VR128:$src1, f128mem:$src2),
1376 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1377 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
1379 // Intrinsic operation, reg+reg.
1380 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1381 (ins VR128:$src1, VR128:$src2),
1382 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1383 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1384 let isCommutable = Commutable;
1387 // Intrinsic operation, reg+mem.
1388 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1389 (ins VR128:$src1, sdmem:$src2),
1390 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1391 [(set VR128:$dst, (F64Int VR128:$src1,
1392 sse_load_f64:$src2))]>;
1394 // Vector intrinsic operation, reg+reg.
1395 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1396 (ins VR128:$src1, VR128:$src2),
1397 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1398 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1399 let isCommutable = Commutable;
1402 // Vector intrinsic operation, reg+mem.
1403 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1404 (ins VR128:$src1, f128mem:$src2),
1405 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1406 [(set VR128:$dst, (V2F64Int VR128:$src1,
1407 (memopv2f64 addr:$src2)))]>;
1411 defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1412 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1413 defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1414 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1416 //===---------------------------------------------------------------------===//
1417 // SSE packed FP Instructions
1419 // Move Instructions
1420 let neverHasSideEffects = 1 in
1421 def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1422 "movapd\t{$src, $dst|$dst, $src}", []>;
1423 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
1424 def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1425 "movapd\t{$src, $dst|$dst, $src}",
1426 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
1428 def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1429 "movapd\t{$src, $dst|$dst, $src}",
1430 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
1432 let neverHasSideEffects = 1 in
1433 def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1434 "movupd\t{$src, $dst|$dst, $src}", []>;
1435 let canFoldAsLoad = 1 in
1436 def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1437 "movupd\t{$src, $dst|$dst, $src}",
1438 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
1439 def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1440 "movupd\t{$src, $dst|$dst, $src}",
1441 [(store (v2f64 VR128:$src), addr:$dst)]>;
1443 // Intrinsic forms of MOVUPD load and store
1444 def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1445 "movupd\t{$src, $dst|$dst, $src}",
1446 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
1447 def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1448 "movupd\t{$src, $dst|$dst, $src}",
1449 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
1451 let Constraints = "$src1 = $dst" in {
1452 let AddedComplexity = 20 in {
1453 def MOVLPDrm : PDI<0x12, MRMSrcMem,
1454 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
1455 "movlpd\t{$src2, $dst|$dst, $src2}",
1457 (v2f64 (movlp VR128:$src1,
1458 (scalar_to_vector (loadf64 addr:$src2)))))]>;
1459 def MOVHPDrm : PDI<0x16, MRMSrcMem,
1460 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
1461 "movhpd\t{$src2, $dst|$dst, $src2}",
1463 (v2f64 (movhp VR128:$src1,
1464 (scalar_to_vector (loadf64 addr:$src2)))))]>;
1465 } // AddedComplexity
1466 } // Constraints = "$src1 = $dst"
1468 def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
1469 "movlpd\t{$src, $dst|$dst, $src}",
1470 [(store (f64 (vector_extract (v2f64 VR128:$src),
1471 (iPTR 0))), addr:$dst)]>;
1473 // v2f64 extract element 1 is always custom lowered to unpack high to low
1474 // and extract element 0 so the non-store version isn't too horrible.
1475 def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
1476 "movhpd\t{$src, $dst|$dst, $src}",
1477 [(store (f64 (vector_extract
1478 (v2f64 (unpckh VR128:$src, (undef))),
1479 (iPTR 0))), addr:$dst)]>;
1481 // SSE2 instructions without OpSize prefix
1482 def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1483 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1484 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1485 TB, Requires<[HasSSE2]>;
1486 def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1487 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1488 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1489 (bitconvert (memopv2i64 addr:$src))))]>,
1490 TB, Requires<[HasSSE2]>;
1492 // SSE2 instructions with XS prefix
1493 def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1494 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1495 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1496 XS, Requires<[HasSSE2]>;
1497 def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1498 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1499 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1500 (bitconvert (memopv2i64 addr:$src))))]>,
1501 XS, Requires<[HasSSE2]>;
1503 def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1504 "cvtps2dq\t{$src, $dst|$dst, $src}",
1505 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
1506 def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1507 "cvtps2dq\t{$src, $dst|$dst, $src}",
1508 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1509 (memop addr:$src)))]>;
1510 // SSE2 packed instructions with XS prefix
1511 def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1512 "cvttps2dq\t{$src, $dst|$dst, $src}",
1513 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1514 XS, Requires<[HasSSE2]>;
1515 def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1516 "cvttps2dq\t{$src, $dst|$dst, $src}",
1517 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1518 (memop addr:$src)))]>,
1519 XS, Requires<[HasSSE2]>;
1521 // SSE2 packed instructions with XD prefix
1522 def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1523 "cvtpd2dq\t{$src, $dst|$dst, $src}",
1524 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1525 XD, Requires<[HasSSE2]>;
1526 def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1527 "cvtpd2dq\t{$src, $dst|$dst, $src}",
1528 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1529 (memop addr:$src)))]>,
1530 XD, Requires<[HasSSE2]>;
1532 def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1533 "cvttpd2dq\t{$src, $dst|$dst, $src}",
1534 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
1535 def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
1536 "cvttpd2dq\t{$src, $dst|$dst, $src}",
1537 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1538 (memop addr:$src)))]>;
1540 // SSE2 instructions without OpSize prefix
1541 def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1542 "cvtps2pd\t{$src, $dst|$dst, $src}",
1543 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1544 TB, Requires<[HasSSE2]>;
1545 def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
1546 "cvtps2pd\t{$src, $dst|$dst, $src}",
1547 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1548 (load addr:$src)))]>,
1549 TB, Requires<[HasSSE2]>;
1551 def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1552 "cvtpd2ps\t{$src, $dst|$dst, $src}",
1553 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
1554 def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1555 "cvtpd2ps\t{$src, $dst|$dst, $src}",
1556 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1557 (memop addr:$src)))]>;
1559 // Match intrinsics which expect XMM operand(s).
1560 // Aliases for intrinsics
1561 let Constraints = "$src1 = $dst" in {
1562 def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
1563 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
1564 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
1565 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1567 def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
1568 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
1569 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
1570 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1571 (loadi32 addr:$src2)))]>;
1572 def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
1573 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1574 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
1575 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1577 def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
1578 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
1579 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
1580 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1581 (load addr:$src2)))]>;
1582 def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
1583 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1584 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
1585 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1586 VR128:$src2))]>, XS,
1587 Requires<[HasSSE2]>;
1588 def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
1589 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
1590 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
1591 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1592 (load addr:$src2)))]>, XS,
1593 Requires<[HasSSE2]>;
1598 /// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1600 /// In addition, we also have a special variant of the scalar form here to
1601 /// represent the associated intrinsic operation. This form is unlike the
1602 /// plain scalar form, in that it takes an entire vector (instead of a
1603 /// scalar) and leaves the top elements undefined.
1605 /// And, we have a special variant form for a full-vector intrinsic form.
1607 /// These four forms can each have a reg or a mem operand, so there are a
1608 /// total of eight "instructions".
1610 multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1614 bit Commutable = 0> {
1615 // Scalar operation, reg.
1616 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1617 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1618 [(set FR64:$dst, (OpNode FR64:$src))]> {
1619 let isCommutable = Commutable;
1622 // Scalar operation, mem.
1623 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
1624 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1625 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1627 // Vector operation, reg.
1628 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1629 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1630 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1631 let isCommutable = Commutable;
1634 // Vector operation, mem.
1635 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1636 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1637 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
1639 // Intrinsic operation, reg.
1640 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1641 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1642 [(set VR128:$dst, (F64Int VR128:$src))]> {
1643 let isCommutable = Commutable;
1646 // Intrinsic operation, mem.
1647 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
1648 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1649 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1651 // Vector intrinsic operation, reg
1652 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1653 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1654 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1655 let isCommutable = Commutable;
1658 // Vector intrinsic operation, mem
1659 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1660 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1661 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
1665 defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1666 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1668 // There is no f64 version of the reciprocal approximation instructions.
1671 let Constraints = "$src1 = $dst" in {
1672 let isCommutable = 1 in {
1673 def ANDPDrr : PDI<0x54, MRMSrcReg,
1674 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1675 "andpd\t{$src2, $dst|$dst, $src2}",
1677 (and (bc_v2i64 (v2f64 VR128:$src1)),
1678 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1679 def ORPDrr : PDI<0x56, MRMSrcReg,
1680 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1681 "orpd\t{$src2, $dst|$dst, $src2}",
1683 (or (bc_v2i64 (v2f64 VR128:$src1)),
1684 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1685 def XORPDrr : PDI<0x57, MRMSrcReg,
1686 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1687 "xorpd\t{$src2, $dst|$dst, $src2}",
1689 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1690 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1693 def ANDPDrm : PDI<0x54, MRMSrcMem,
1694 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1695 "andpd\t{$src2, $dst|$dst, $src2}",
1697 (and (bc_v2i64 (v2f64 VR128:$src1)),
1698 (memopv2i64 addr:$src2)))]>;
1699 def ORPDrm : PDI<0x56, MRMSrcMem,
1700 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1701 "orpd\t{$src2, $dst|$dst, $src2}",
1703 (or (bc_v2i64 (v2f64 VR128:$src1)),
1704 (memopv2i64 addr:$src2)))]>;
1705 def XORPDrm : PDI<0x57, MRMSrcMem,
1706 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1707 "xorpd\t{$src2, $dst|$dst, $src2}",
1709 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1710 (memopv2i64 addr:$src2)))]>;
1711 def ANDNPDrr : PDI<0x55, MRMSrcReg,
1712 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1713 "andnpd\t{$src2, $dst|$dst, $src2}",
1715 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1716 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1717 def ANDNPDrm : PDI<0x55, MRMSrcMem,
1718 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
1719 "andnpd\t{$src2, $dst|$dst, $src2}",
1721 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1722 (memopv2i64 addr:$src2)))]>;
1725 let Constraints = "$src1 = $dst" in {
1726 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
1727 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1728 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1729 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1730 VR128:$src, imm:$cc))]>;
1731 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
1732 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1733 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1734 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1735 (memop addr:$src), imm:$cc))]>;
1737 def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
1738 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
1739 def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
1740 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
1742 // Shuffle and unpack instructions
1743 let Constraints = "$src1 = $dst" in {
1744 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
1745 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1746 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1748 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
1749 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
1750 (outs VR128:$dst), (ins VR128:$src1,
1751 f128mem:$src2, i8imm:$src3),
1752 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1755 VR128:$src1, (memopv2f64 addr:$src2))))]>;
1757 let AddedComplexity = 10 in {
1758 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
1759 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1760 "unpckhpd\t{$src2, $dst|$dst, $src2}",
1762 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
1763 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
1764 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1765 "unpckhpd\t{$src2, $dst|$dst, $src2}",
1767 (v2f64 (unpckh VR128:$src1,
1768 (memopv2f64 addr:$src2))))]>;
1770 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
1771 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1772 "unpcklpd\t{$src2, $dst|$dst, $src2}",
1774 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
1775 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
1776 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1777 "unpcklpd\t{$src2, $dst|$dst, $src2}",
1779 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
1780 } // AddedComplexity
1781 } // Constraints = "$src1 = $dst"
1784 //===---------------------------------------------------------------------===//
1785 // SSE integer instructions
1787 // Move Instructions
1788 let neverHasSideEffects = 1 in
1789 def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1790 "movdqa\t{$src, $dst|$dst, $src}", []>;
1791 let canFoldAsLoad = 1, mayLoad = 1 in
1792 def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1793 "movdqa\t{$src, $dst|$dst, $src}",
1794 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
1796 def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1797 "movdqa\t{$src, $dst|$dst, $src}",
1798 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
1799 let canFoldAsLoad = 1, mayLoad = 1 in
1800 def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1801 "movdqu\t{$src, $dst|$dst, $src}",
1802 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
1803 XS, Requires<[HasSSE2]>;
1805 def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1806 "movdqu\t{$src, $dst|$dst, $src}",
1807 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
1808 XS, Requires<[HasSSE2]>;
1810 // Intrinsic forms of MOVDQU load and store
1811 let canFoldAsLoad = 1 in
1812 def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1813 "movdqu\t{$src, $dst|$dst, $src}",
1814 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1815 XS, Requires<[HasSSE2]>;
1816 def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1817 "movdqu\t{$src, $dst|$dst, $src}",
1818 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1819 XS, Requires<[HasSSE2]>;
1821 let Constraints = "$src1 = $dst" in {
1823 multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1824 bit Commutable = 0> {
1825 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1826 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1827 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1828 let isCommutable = Commutable;
1830 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1831 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1832 [(set VR128:$dst, (IntId VR128:$src1,
1833 (bitconvert (memopv2i64 addr:$src2))))]>;
1836 multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1838 Intrinsic IntId, Intrinsic IntId2> {
1839 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1841 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1842 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
1843 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1845 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1846 [(set VR128:$dst, (IntId VR128:$src1,
1847 (bitconvert (memopv2i64 addr:$src2))))]>;
1848 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1,
1850 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1851 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
1854 /// PDI_binop_rm - Simple SSE2 binary operator.
1855 multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1856 ValueType OpVT, bit Commutable = 0> {
1857 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1859 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1860 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1861 let isCommutable = Commutable;
1863 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1865 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1866 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
1867 (bitconvert (memopv2i64 addr:$src2)))))]>;
1870 /// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1872 /// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1873 /// to collapse (bitconvert VT to VT) into its operand.
1875 multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1876 bit Commutable = 0> {
1877 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1878 (ins VR128:$src1, VR128:$src2),
1879 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1880 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1881 let isCommutable = Commutable;
1883 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1884 (ins VR128:$src1, i128mem:$src2),
1885 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1886 [(set VR128:$dst, (OpNode VR128:$src1,
1887 (memopv2i64 addr:$src2)))]>;
1890 } // Constraints = "$src1 = $dst"
1892 // 128-bit Integer Arithmetic
1894 defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1895 defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1896 defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1897 defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1899 defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1900 defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1901 defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1902 defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1904 defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1905 defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1906 defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1907 defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1909 defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1910 defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1911 defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1912 defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1914 defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1916 defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1917 defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1918 defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1920 defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1922 defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1923 defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1926 defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1927 defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1928 defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1929 defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1930 defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
1933 defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
1934 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
1935 defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
1936 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
1937 defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
1938 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
1940 defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
1941 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
1942 defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
1943 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
1944 defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
1945 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
1947 defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
1948 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
1949 defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
1950 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
1952 // 128-bit logical shifts.
1953 let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
1954 def PSLLDQri : PDIi8<0x73, MRM7r,
1955 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
1956 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
1957 def PSRLDQri : PDIi8<0x73, MRM3r,
1958 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
1959 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
1960 // PSRADQri doesn't exist in SSE[1-3].
1963 let Predicates = [HasSSE2] in {
1964 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1965 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1966 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1967 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1968 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
1969 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
1970 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
1971 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
1972 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1973 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1975 // Shift up / down and insert zero's.
1976 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
1977 (v2i64 (PSLLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>;
1978 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
1979 (v2i64 (PSRLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>;
1983 defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1984 defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1985 defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1987 let Constraints = "$src1 = $dst" in {
1988 def PANDNrr : PDI<0xDF, MRMSrcReg,
1989 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1990 "pandn\t{$src2, $dst|$dst, $src2}",
1991 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1994 def PANDNrm : PDI<0xDF, MRMSrcMem,
1995 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1996 "pandn\t{$src2, $dst|$dst, $src2}",
1997 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1998 (memopv2i64 addr:$src2))))]>;
2001 // SSE2 Integer comparison
2002 defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2003 defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2004 defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2005 defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2006 defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2007 defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
2009 def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
2010 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
2011 def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
2012 (PCMPEQBrm VR128:$src1, addr:$src2)>;
2013 def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
2014 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
2015 def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
2016 (PCMPEQWrm VR128:$src1, addr:$src2)>;
2017 def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
2018 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
2019 def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
2020 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2022 def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
2023 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
2024 def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
2025 (PCMPGTBrm VR128:$src1, addr:$src2)>;
2026 def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
2027 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
2028 def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
2029 (PCMPGTWrm VR128:$src1, addr:$src2)>;
2030 def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
2031 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
2032 def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
2033 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2036 // Pack instructions
2037 defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2038 defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2039 defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2041 // Shuffle and unpack instructions
2042 def PSHUFDri : PDIi8<0x70, MRMSrcReg,
2043 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
2044 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2045 [(set VR128:$dst, (v4i32 (pshufd:$src2
2046 VR128:$src1, (undef))))]>;
2047 def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
2048 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
2049 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2050 [(set VR128:$dst, (v4i32 (pshufd:$src2
2051 (bc_v4i32(memopv2i64 addr:$src1)),
2054 // SSE2 with ImmT == Imm8 and XS prefix.
2055 def PSHUFHWri : Ii8<0x70, MRMSrcReg,
2056 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
2057 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2058 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2060 XS, Requires<[HasSSE2]>;
2061 def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
2062 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
2063 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2064 [(set VR128:$dst, (v8i16 (pshufhw:$src2
2065 (bc_v8i16 (memopv2i64 addr:$src1)),
2067 XS, Requires<[HasSSE2]>;
2069 // SSE2 with ImmT == Imm8 and XD prefix.
2070 def PSHUFLWri : Ii8<0x70, MRMSrcReg,
2071 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
2072 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2073 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2075 XD, Requires<[HasSSE2]>;
2076 def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
2077 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
2078 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2079 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2080 (bc_v8i16 (memopv2i64 addr:$src1)),
2082 XD, Requires<[HasSSE2]>;
2085 let Constraints = "$src1 = $dst" in {
2086 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
2087 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2088 "punpcklbw\t{$src2, $dst|$dst, $src2}",
2090 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
2091 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
2092 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2093 "punpcklbw\t{$src2, $dst|$dst, $src2}",
2095 (unpckl VR128:$src1,
2096 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
2097 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
2098 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2099 "punpcklwd\t{$src2, $dst|$dst, $src2}",
2101 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
2102 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
2103 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2104 "punpcklwd\t{$src2, $dst|$dst, $src2}",
2106 (unpckl VR128:$src1,
2107 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
2108 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
2109 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2110 "punpckldq\t{$src2, $dst|$dst, $src2}",
2112 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
2113 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
2114 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2115 "punpckldq\t{$src2, $dst|$dst, $src2}",
2117 (unpckl VR128:$src1,
2118 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
2119 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
2120 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2121 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
2123 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
2124 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
2125 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2126 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
2128 (v2i64 (unpckl VR128:$src1,
2129 (memopv2i64 addr:$src2))))]>;
2131 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
2132 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2133 "punpckhbw\t{$src2, $dst|$dst, $src2}",
2135 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
2136 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
2137 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2138 "punpckhbw\t{$src2, $dst|$dst, $src2}",
2140 (unpckh VR128:$src1,
2141 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
2142 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
2143 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2144 "punpckhwd\t{$src2, $dst|$dst, $src2}",
2146 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
2147 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
2148 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2149 "punpckhwd\t{$src2, $dst|$dst, $src2}",
2151 (unpckh VR128:$src1,
2152 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
2153 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
2154 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2155 "punpckhdq\t{$src2, $dst|$dst, $src2}",
2157 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
2158 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
2159 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2160 "punpckhdq\t{$src2, $dst|$dst, $src2}",
2162 (unpckh VR128:$src1,
2163 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
2164 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
2165 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2166 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
2168 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
2169 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
2170 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2171 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
2173 (v2i64 (unpckh VR128:$src1,
2174 (memopv2i64 addr:$src2))))]>;
2178 def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
2179 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
2180 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2181 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
2183 let Constraints = "$src1 = $dst" in {
2184 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
2185 (outs VR128:$dst), (ins VR128:$src1,
2186 GR32:$src2, i32i8imm:$src3),
2187 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2189 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
2190 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
2191 (outs VR128:$dst), (ins VR128:$src1,
2192 i16mem:$src2, i32i8imm:$src3),
2193 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2195 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2200 def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
2201 "pmovmskb\t{$src, $dst|$dst, $src}",
2202 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2204 // Conditional store
2206 def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2207 "maskmovdqu\t{$mask, $src|$src, $mask}",
2208 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
2211 def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2212 "maskmovdqu\t{$mask, $src|$src, $mask}",
2213 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2215 // Non-temporal stores
2216 def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2217 "movntpd\t{$src, $dst|$dst, $src}",
2218 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
2219 def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2220 "movntdq\t{$src, $dst|$dst, $src}",
2221 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
2222 def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
2223 "movnti\t{$src, $dst|$dst, $src}",
2224 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2225 TB, Requires<[HasSSE2]>;
2228 def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
2229 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
2230 TB, Requires<[HasSSE2]>;
2232 // Load, store, and memory fence
2233 def LFENCE : I<0xAE, MRM5r, (outs), (ins),
2234 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
2235 def MFENCE : I<0xAE, MRM6r, (outs), (ins),
2236 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2238 //TODO: custom lower this so as to never even generate the noop
2239 def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
2241 def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2242 def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
2243 def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
2246 // Alias instructions that map zero vector to pxor / xorp* for sse.
2247 // We set canFoldAsLoad because this can be converted to a constant-pool
2248 // load of an all-ones value if folding it would be beneficial.
2249 let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2250 isCodeGenOnly = 1 in
2251 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
2252 "pcmpeqd\t$dst, $dst",
2253 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
2255 // FR64 to 128-bit vector conversion.
2256 let isAsCheapAsAMove = 1 in
2257 def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
2258 "movsd\t{$src, $dst|$dst, $src}",
2260 (v2f64 (scalar_to_vector FR64:$src)))]>;
2261 def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2262 "movsd\t{$src, $dst|$dst, $src}",
2264 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2266 def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2267 "movd\t{$src, $dst|$dst, $src}",
2269 (v4i32 (scalar_to_vector GR32:$src)))]>;
2270 def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2271 "movd\t{$src, $dst|$dst, $src}",
2273 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2275 def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
2276 "movd\t{$src, $dst|$dst, $src}",
2277 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2279 def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
2280 "movd\t{$src, $dst|$dst, $src}",
2281 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2283 // SSE2 instructions with XS prefix
2284 def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
2285 "movq\t{$src, $dst|$dst, $src}",
2287 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2288 Requires<[HasSSE2]>;
2289 def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
2290 "movq\t{$src, $dst|$dst, $src}",
2291 [(store (i64 (vector_extract (v2i64 VR128:$src),
2292 (iPTR 0))), addr:$dst)]>;
2294 // FIXME: may not be able to eliminate this movss with coalescing the src and
2295 // dest register classes are different. We really want to write this pattern
2297 // def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2298 // (f32 FR32:$src)>;
2299 let isAsCheapAsAMove = 1 in
2300 def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
2301 "movsd\t{$src, $dst|$dst, $src}",
2302 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2304 def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
2305 "movsd\t{$src, $dst|$dst, $src}",
2306 [(store (f64 (vector_extract (v2f64 VR128:$src),
2307 (iPTR 0))), addr:$dst)]>;
2308 def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
2309 "movd\t{$src, $dst|$dst, $src}",
2310 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2312 def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
2313 "movd\t{$src, $dst|$dst, $src}",
2314 [(store (i32 (vector_extract (v4i32 VR128:$src),
2315 (iPTR 0))), addr:$dst)]>;
2317 def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
2318 "movd\t{$src, $dst|$dst, $src}",
2319 [(set GR32:$dst, (bitconvert FR32:$src))]>;
2320 def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
2321 "movd\t{$src, $dst|$dst, $src}",
2322 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2325 // Move to lower bits of a VR128, leaving upper bits alone.
2326 // Three operand (but two address) aliases.
2327 let Constraints = "$src1 = $dst" in {
2328 let neverHasSideEffects = 1 in
2329 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
2330 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
2331 "movsd\t{$src2, $dst|$dst, $src2}", []>;
2333 let AddedComplexity = 15 in
2334 def MOVLPDrr : SDI<0x10, MRMSrcReg,
2335 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2336 "movsd\t{$src2, $dst|$dst, $src2}",
2338 (v2f64 (movl VR128:$src1, VR128:$src2)))]>;
2341 // Store / copy lower 64-bits of a XMM register.
2342 def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
2343 "movq\t{$src, $dst|$dst, $src}",
2344 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2346 // Move to lower bits of a VR128 and zeroing upper bits.
2347 // Loading from memory automatically zeroing upper bits.
2348 let AddedComplexity = 20 in {
2349 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2350 "movsd\t{$src, $dst|$dst, $src}",
2352 (v2f64 (X86vzmovl (v2f64 (scalar_to_vector
2353 (loadf64 addr:$src))))))]>;
2355 def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
2356 (MOVZSD2PDrm addr:$src)>;
2357 def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
2358 (MOVZSD2PDrm addr:$src)>;
2359 def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>;
2362 // movd / movq to XMM register zero-extends
2363 let AddedComplexity = 15 in {
2364 def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2365 "movd\t{$src, $dst|$dst, $src}",
2366 [(set VR128:$dst, (v4i32 (X86vzmovl
2367 (v4i32 (scalar_to_vector GR32:$src)))))]>;
2368 // This is X86-64 only.
2369 def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2370 "mov{d|q}\t{$src, $dst|$dst, $src}",
2371 [(set VR128:$dst, (v2i64 (X86vzmovl
2372 (v2i64 (scalar_to_vector GR64:$src)))))]>;
2375 let AddedComplexity = 20 in {
2376 def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2377 "movd\t{$src, $dst|$dst, $src}",
2379 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
2380 (loadi32 addr:$src))))))]>;
2382 def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2383 (MOVZDI2PDIrm addr:$src)>;
2384 def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2385 (MOVZDI2PDIrm addr:$src)>;
2386 def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2387 (MOVZDI2PDIrm addr:$src)>;
2389 def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
2390 "movq\t{$src, $dst|$dst, $src}",
2392 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
2393 (loadi64 addr:$src))))))]>, XS,
2394 Requires<[HasSSE2]>;
2396 def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2397 (MOVZQI2PQIrm addr:$src)>;
2398 def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2399 (MOVZQI2PQIrm addr:$src)>;
2400 def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
2403 // Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2404 // IA32 document. movq xmm1, xmm2 does clear the high bits.
2405 let AddedComplexity = 15 in
2406 def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2407 "movq\t{$src, $dst|$dst, $src}",
2408 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
2409 XS, Requires<[HasSSE2]>;
2411 let AddedComplexity = 20 in {
2412 def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2413 "movq\t{$src, $dst|$dst, $src}",
2414 [(set VR128:$dst, (v2i64 (X86vzmovl
2415 (loadv2i64 addr:$src))))]>,
2416 XS, Requires<[HasSSE2]>;
2418 def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2419 (MOVZPQILo2PQIrm addr:$src)>;
2422 //===---------------------------------------------------------------------===//
2423 // SSE3 Instructions
2424 //===---------------------------------------------------------------------===//
2426 // Move Instructions
2427 def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2428 "movshdup\t{$src, $dst|$dst, $src}",
2429 [(set VR128:$dst, (v4f32 (movshdup
2430 VR128:$src, (undef))))]>;
2431 def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
2432 "movshdup\t{$src, $dst|$dst, $src}",
2433 [(set VR128:$dst, (movshdup
2434 (memopv4f32 addr:$src), (undef)))]>;
2436 def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2437 "movsldup\t{$src, $dst|$dst, $src}",
2438 [(set VR128:$dst, (v4f32 (movsldup
2439 VR128:$src, (undef))))]>;
2440 def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
2441 "movsldup\t{$src, $dst|$dst, $src}",
2442 [(set VR128:$dst, (movsldup
2443 (memopv4f32 addr:$src), (undef)))]>;
2445 def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2446 "movddup\t{$src, $dst|$dst, $src}",
2447 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
2448 def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2449 "movddup\t{$src, $dst|$dst, $src}",
2451 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2454 def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2456 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2458 let AddedComplexity = 5 in {
2459 def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
2460 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2461 def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2462 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2463 def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2464 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2465 def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2466 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2470 let Constraints = "$src1 = $dst" in {
2471 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
2472 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2473 "addsubps\t{$src2, $dst|$dst, $src2}",
2474 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2476 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
2477 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2478 "addsubps\t{$src2, $dst|$dst, $src2}",
2479 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2480 (memop addr:$src2)))]>;
2481 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
2482 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2483 "addsubpd\t{$src2, $dst|$dst, $src2}",
2484 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2486 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
2487 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2488 "addsubpd\t{$src2, $dst|$dst, $src2}",
2489 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2490 (memop addr:$src2)))]>;
2493 def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2494 "lddqu\t{$src, $dst|$dst, $src}",
2495 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2498 class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
2499 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2500 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2501 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2502 class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
2503 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2504 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2505 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
2506 class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
2507 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2508 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2509 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2510 class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
2511 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2512 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2513 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
2515 let Constraints = "$src1 = $dst" in {
2516 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2517 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2518 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2519 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2520 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2521 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2522 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2523 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2526 // Thread synchronization
2527 def MONITOR : I<0x01, MRM1r, (outs), (ins), "monitor",
2528 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
2529 def MWAIT : I<0x01, MRM1r, (outs), (ins), "mwait",
2530 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2532 // vector_shuffle v1, <undef> <1, 1, 3, 3>
2533 let AddedComplexity = 15 in
2534 def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
2535 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2536 let AddedComplexity = 20 in
2537 def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
2538 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2540 // vector_shuffle v1, <undef> <0, 0, 2, 2>
2541 let AddedComplexity = 15 in
2542 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
2543 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2544 let AddedComplexity = 20 in
2545 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
2546 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2548 //===---------------------------------------------------------------------===//
2549 // SSSE3 Instructions
2550 //===---------------------------------------------------------------------===//
2552 /// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
2553 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2554 Intrinsic IntId64, Intrinsic IntId128> {
2555 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2556 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2557 [(set VR64:$dst, (IntId64 VR64:$src))]>;
2559 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2560 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2562 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2564 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2566 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2567 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2570 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2572 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2575 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
2578 /// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2579 multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2580 Intrinsic IntId64, Intrinsic IntId128> {
2581 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2583 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2584 [(set VR64:$dst, (IntId64 VR64:$src))]>;
2586 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2588 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2591 (bitconvert (memopv4i16 addr:$src))))]>;
2593 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2595 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2596 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2599 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2601 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2604 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2607 /// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2608 multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2609 Intrinsic IntId64, Intrinsic IntId128> {
2610 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2612 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2613 [(set VR64:$dst, (IntId64 VR64:$src))]>;
2615 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2617 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2620 (bitconvert (memopv2i32 addr:$src))))]>;
2622 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2624 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2625 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2628 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2630 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2633 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2636 defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2637 int_x86_ssse3_pabs_b,
2638 int_x86_ssse3_pabs_b_128>;
2639 defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2640 int_x86_ssse3_pabs_w,
2641 int_x86_ssse3_pabs_w_128>;
2642 defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2643 int_x86_ssse3_pabs_d,
2644 int_x86_ssse3_pabs_d_128>;
2646 /// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2647 let Constraints = "$src1 = $dst" in {
2648 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2649 Intrinsic IntId64, Intrinsic IntId128,
2650 bit Commutable = 0> {
2651 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2652 (ins VR64:$src1, VR64:$src2),
2653 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2654 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2655 let isCommutable = Commutable;
2657 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2658 (ins VR64:$src1, i64mem:$src2),
2659 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2661 (IntId64 VR64:$src1,
2662 (bitconvert (memopv8i8 addr:$src2))))]>;
2664 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2665 (ins VR128:$src1, VR128:$src2),
2666 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2667 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2669 let isCommutable = Commutable;
2671 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2672 (ins VR128:$src1, i128mem:$src2),
2673 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2675 (IntId128 VR128:$src1,
2676 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2680 /// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2681 let Constraints = "$src1 = $dst" in {
2682 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2683 Intrinsic IntId64, Intrinsic IntId128,
2684 bit Commutable = 0> {
2685 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2686 (ins VR64:$src1, VR64:$src2),
2687 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2688 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2689 let isCommutable = Commutable;
2691 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2692 (ins VR64:$src1, i64mem:$src2),
2693 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2695 (IntId64 VR64:$src1,
2696 (bitconvert (memopv4i16 addr:$src2))))]>;
2698 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2699 (ins VR128:$src1, VR128:$src2),
2700 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2701 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2703 let isCommutable = Commutable;
2705 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2706 (ins VR128:$src1, i128mem:$src2),
2707 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2709 (IntId128 VR128:$src1,
2710 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2714 /// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2715 let Constraints = "$src1 = $dst" in {
2716 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2717 Intrinsic IntId64, Intrinsic IntId128,
2718 bit Commutable = 0> {
2719 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2720 (ins VR64:$src1, VR64:$src2),
2721 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2722 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2723 let isCommutable = Commutable;
2725 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2726 (ins VR64:$src1, i64mem:$src2),
2727 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2729 (IntId64 VR64:$src1,
2730 (bitconvert (memopv2i32 addr:$src2))))]>;
2732 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2733 (ins VR128:$src1, VR128:$src2),
2734 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2735 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2737 let isCommutable = Commutable;
2739 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2740 (ins VR128:$src1, i128mem:$src2),
2741 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2743 (IntId128 VR128:$src1,
2744 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2748 defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2749 int_x86_ssse3_phadd_w,
2750 int_x86_ssse3_phadd_w_128>;
2751 defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2752 int_x86_ssse3_phadd_d,
2753 int_x86_ssse3_phadd_d_128>;
2754 defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2755 int_x86_ssse3_phadd_sw,
2756 int_x86_ssse3_phadd_sw_128>;
2757 defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2758 int_x86_ssse3_phsub_w,
2759 int_x86_ssse3_phsub_w_128>;
2760 defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2761 int_x86_ssse3_phsub_d,
2762 int_x86_ssse3_phsub_d_128>;
2763 defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2764 int_x86_ssse3_phsub_sw,
2765 int_x86_ssse3_phsub_sw_128>;
2766 defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2767 int_x86_ssse3_pmadd_ub_sw,
2768 int_x86_ssse3_pmadd_ub_sw_128>;
2769 defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2770 int_x86_ssse3_pmul_hr_sw,
2771 int_x86_ssse3_pmul_hr_sw_128, 1>;
2772 defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2773 int_x86_ssse3_pshuf_b,
2774 int_x86_ssse3_pshuf_b_128>;
2775 defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2776 int_x86_ssse3_psign_b,
2777 int_x86_ssse3_psign_b_128>;
2778 defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2779 int_x86_ssse3_psign_w,
2780 int_x86_ssse3_psign_w_128>;
2781 defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
2782 int_x86_ssse3_psign_d,
2783 int_x86_ssse3_psign_d_128>;
2785 let Constraints = "$src1 = $dst" in {
2786 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2787 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
2788 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2790 (int_x86_ssse3_palign_r
2791 VR64:$src1, VR64:$src2,
2793 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
2794 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
2795 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2797 (int_x86_ssse3_palign_r
2799 (bitconvert (memopv2i32 addr:$src2)),
2802 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2803 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
2804 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2806 (int_x86_ssse3_palign_r_128
2807 VR128:$src1, VR128:$src2,
2808 imm:$src3))]>, OpSize;
2809 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
2810 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
2811 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2813 (int_x86_ssse3_palign_r_128
2815 (bitconvert (memopv4i32 addr:$src2)),
2816 imm:$src3))]>, OpSize;
2819 def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2820 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2821 def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2822 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2824 //===---------------------------------------------------------------------===//
2825 // Non-Instruction Patterns
2826 //===---------------------------------------------------------------------===//
2828 // extload f32 -> f64. This matches load+fextend because we have a hack in
2829 // the isel (PreprocessForFPConvert) that can introduce loads after dag
2831 // Since these loads aren't folded into the fextend, we have to match it
2833 let Predicates = [HasSSE2] in
2834 def : Pat<(fextend (loadf32 addr:$src)),
2835 (CVTSS2SDrm addr:$src)>;
2838 let Predicates = [HasSSE2] in {
2839 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2840 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2841 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2842 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2843 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2844 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2845 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2846 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2847 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2848 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2849 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2850 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2851 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2852 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2853 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2854 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2855 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2856 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2857 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2858 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2859 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2860 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2861 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2862 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2863 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2864 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2865 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2866 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2867 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2868 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2871 // Move scalar to XMM zero-extended
2872 // movd to XMM register zero-extends
2873 let AddedComplexity = 15 in {
2874 // Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
2875 def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
2876 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
2877 def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
2878 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE1]>;
2879 def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
2880 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
2881 def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
2882 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
2885 // Splat v2f64 / v2i64
2886 let AddedComplexity = 10 in {
2887 def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
2888 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2889 def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
2890 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2891 def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
2892 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2893 def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
2894 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2897 // Special unary SHUFPSrri case.
2898 def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
2899 (SHUFPSrri VR128:$src1, VR128:$src1,
2900 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2901 Requires<[HasSSE1]>;
2902 let AddedComplexity = 5 in
2903 def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
2904 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2905 Requires<[HasSSE2]>;
2906 // Special unary SHUFPDrri case.
2907 def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
2908 (SHUFPDrri VR128:$src1, VR128:$src1,
2909 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2910 Requires<[HasSSE2]>;
2911 // Special unary SHUFPDrri case.
2912 def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
2913 (SHUFPDrri VR128:$src1, VR128:$src1,
2914 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2915 Requires<[HasSSE2]>;
2916 // Unary v4f32 shuffle with PSHUF* in order to fold a load.
2917 def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
2918 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2919 Requires<[HasSSE2]>;
2921 // Special binary v4i32 shuffle cases with SHUFPS.
2922 def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
2923 (SHUFPSrri VR128:$src1, VR128:$src2,
2924 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2925 Requires<[HasSSE2]>;
2926 def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
2927 (SHUFPSrmi VR128:$src1, addr:$src2,
2928 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2929 Requires<[HasSSE2]>;
2930 // Special binary v2i64 shuffle cases using SHUFPDrri.
2931 def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
2932 (SHUFPDrri VR128:$src1, VR128:$src2,
2933 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2934 Requires<[HasSSE2]>;
2936 // vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2937 let AddedComplexity = 15 in {
2938 def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
2939 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2940 Requires<[OptForSpeed, HasSSE2]>;
2941 def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
2942 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2943 Requires<[OptForSpeed, HasSSE2]>;
2945 let AddedComplexity = 10 in {
2946 def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
2947 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2948 def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
2949 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2950 def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
2951 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2952 def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
2953 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2956 // vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2957 let AddedComplexity = 15 in {
2958 def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
2959 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2960 Requires<[OptForSpeed, HasSSE2]>;
2961 def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
2962 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2963 Requires<[OptForSpeed, HasSSE2]>;
2965 let AddedComplexity = 10 in {
2966 def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
2967 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2968 def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
2969 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2970 def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
2971 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2972 def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
2973 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2976 let AddedComplexity = 20 in {
2977 // vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2978 def : Pat<(v4i32 (movhp VR128:$src1, VR128:$src2)),
2979 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2981 // vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2982 def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
2983 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2985 // vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2986 def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
2987 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2988 def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
2989 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2992 let AddedComplexity = 20 in {
2993 // vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2994 // vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
2995 def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
2996 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
2997 def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
2998 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2999 def : Pat<(v4f32 (movhp VR128:$src1, (load addr:$src2))),
3000 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
3001 def : Pat<(v2f64 (movhp VR128:$src1, (load addr:$src2))),
3002 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3004 def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
3005 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3006 def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
3007 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3008 def : Pat<(v4i32 (movhp VR128:$src1, (load addr:$src2))),
3009 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
3010 def : Pat<(v2i64 (movhp VR128:$src1, (load addr:$src2))),
3011 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3014 // (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
3015 // (store (vector_shuffle (load addr), v2, <0, 1, 4, 5>), addr) using MOVHPS
3016 def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3017 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
3018 def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3019 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3020 def : Pat<(store (v4f32 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
3021 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
3022 def : Pat<(store (v2f64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
3023 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3025 def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3027 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
3028 def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3029 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3030 def : Pat<(store (v4i32 (movhp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3032 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
3033 def : Pat<(store (v2i64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
3034 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3037 let AddedComplexity = 15 in {
3038 // Setting the lowest element in the vector.
3039 def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
3040 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3041 def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
3042 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3044 // vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
3045 def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
3046 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3047 def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
3048 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3051 // vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3052 // fall back to this for SSE1)
3053 def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
3054 (SHUFPSrri VR128:$src2, VR128:$src1,
3055 (SHUFFLE_get_shuf_imm VR128:$src3))>, Requires<[HasSSE1]>;
3057 // Set lowest element and zero upper elements.
3058 let AddedComplexity = 15 in
3059 def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
3060 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
3061 def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
3062 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
3064 // Some special case pandn patterns.
3065 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3067 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3068 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3070 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3071 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3073 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3075 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3076 (memop addr:$src2))),
3077 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3078 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3079 (memop addr:$src2))),
3080 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3081 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3082 (memop addr:$src2))),
3083 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3085 // vector -> vector casts
3086 def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3087 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3088 def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3089 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
3090 def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3091 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3092 def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3093 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
3095 // Use movaps / movups for SSE integer load / store (one byte shorter).
3096 def : Pat<(alignedloadv4i32 addr:$src),
3097 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
3098 def : Pat<(loadv4i32 addr:$src),
3099 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
3100 def : Pat<(alignedloadv2i64 addr:$src),
3101 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3102 def : Pat<(loadv2i64 addr:$src),
3103 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3105 def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3106 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3107 def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3108 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3109 def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3110 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3111 def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3112 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3113 def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3114 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3115 def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3116 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3117 def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3118 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3119 def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3120 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3122 //===----------------------------------------------------------------------===//
3123 // SSE4.1 Instructions
3124 //===----------------------------------------------------------------------===//
3126 multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
3129 Intrinsic V2F64Int> {
3130 // Intrinsic operation, reg.
3131 // Vector intrinsic operation, reg
3132 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
3133 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
3134 !strconcat(OpcodeStr,
3135 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3136 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3139 // Vector intrinsic operation, mem
3140 def PSm_Int : SS4AIi8<opcps, MRMSrcMem,
3141 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
3142 !strconcat(OpcodeStr,
3143 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3145 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
3148 // Vector intrinsic operation, reg
3149 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
3150 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
3151 !strconcat(OpcodeStr,
3152 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3153 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3156 // Vector intrinsic operation, mem
3157 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
3158 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
3159 !strconcat(OpcodeStr,
3160 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3162 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
3166 let Constraints = "$src1 = $dst" in {
3167 multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3171 // Intrinsic operation, reg.
3172 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
3174 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3175 !strconcat(OpcodeStr,
3176 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3178 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3181 // Intrinsic operation, mem.
3182 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3184 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
3185 !strconcat(OpcodeStr,
3186 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3188 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3191 // Intrinsic operation, reg.
3192 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
3194 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3195 !strconcat(OpcodeStr,
3196 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3198 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3201 // Intrinsic operation, mem.
3202 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
3204 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3205 !strconcat(OpcodeStr,
3206 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3208 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3213 // FP round - roundss, roundps, roundsd, roundpd
3214 defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3215 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3216 defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3217 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
3219 // SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3220 multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3221 Intrinsic IntId128> {
3222 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3224 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3225 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3226 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3228 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3231 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3234 defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3235 int_x86_sse41_phminposuw>;
3237 /// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
3238 let Constraints = "$src1 = $dst" in {
3239 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3240 Intrinsic IntId128, bit Commutable = 0> {
3241 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3242 (ins VR128:$src1, VR128:$src2),
3243 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3244 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3246 let isCommutable = Commutable;
3248 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3249 (ins VR128:$src1, i128mem:$src2),
3250 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3252 (IntId128 VR128:$src1,
3253 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3257 defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3258 int_x86_sse41_pcmpeqq, 1>;
3259 defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3260 int_x86_sse41_packusdw, 0>;
3261 defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3262 int_x86_sse41_pminsb, 1>;
3263 defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3264 int_x86_sse41_pminsd, 1>;
3265 defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3266 int_x86_sse41_pminud, 1>;
3267 defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3268 int_x86_sse41_pminuw, 1>;
3269 defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3270 int_x86_sse41_pmaxsb, 1>;
3271 defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3272 int_x86_sse41_pmaxsd, 1>;
3273 defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3274 int_x86_sse41_pmaxud, 1>;
3275 defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3276 int_x86_sse41_pmaxuw, 1>;
3278 defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3280 def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3281 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3282 def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3283 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3285 /// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
3286 let Constraints = "$src1 = $dst" in {
3287 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3288 SDNode OpNode, Intrinsic IntId128,
3289 bit Commutable = 0> {
3290 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3291 (ins VR128:$src1, VR128:$src2),
3292 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3293 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3294 VR128:$src2))]>, OpSize {
3295 let isCommutable = Commutable;
3297 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3298 (ins VR128:$src1, VR128:$src2),
3299 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3300 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3302 let isCommutable = Commutable;
3304 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3305 (ins VR128:$src1, i128mem:$src2),
3306 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3308 (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize;
3309 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3310 (ins VR128:$src1, i128mem:$src2),
3311 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3313 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
3317 defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
3318 int_x86_sse41_pmulld, 1>;
3320 /// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
3321 let Constraints = "$src1 = $dst" in {
3322 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3323 Intrinsic IntId128, bit Commutable = 0> {
3324 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3325 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3326 !strconcat(OpcodeStr,
3327 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3329 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3331 let isCommutable = Commutable;
3333 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3334 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3335 !strconcat(OpcodeStr,
3336 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3338 (IntId128 VR128:$src1,
3339 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3344 defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3345 int_x86_sse41_blendps, 0>;
3346 defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3347 int_x86_sse41_blendpd, 0>;
3348 defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3349 int_x86_sse41_pblendw, 0>;
3350 defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3351 int_x86_sse41_dpps, 1>;
3352 defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3353 int_x86_sse41_dppd, 1>;
3354 defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
3355 int_x86_sse41_mpsadbw, 1>;
3358 /// SS41I_ternary_int - SSE 4.1 ternary operator
3359 let Uses = [XMM0], Constraints = "$src1 = $dst" in {
3360 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3361 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3362 (ins VR128:$src1, VR128:$src2),
3363 !strconcat(OpcodeStr,
3364 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3365 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3368 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3369 (ins VR128:$src1, i128mem:$src2),
3370 !strconcat(OpcodeStr,
3371 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3374 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3378 defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3379 defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3380 defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3383 multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3384 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3385 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3386 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3388 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3389 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3391 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3395 defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3396 defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3397 defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3398 defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3399 defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3400 defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3402 // Common patterns involving scalar load.
3403 def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3404 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3405 def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3406 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3408 def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3409 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3410 def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3411 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3413 def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3414 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3415 def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3416 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3418 def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3419 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3420 def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3421 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3423 def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3424 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3425 def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3426 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3428 def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3429 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3430 def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3431 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3434 multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3435 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3436 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3437 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3439 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3440 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3442 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3446 defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3447 defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3448 defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3449 defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3451 // Common patterns involving scalar load
3452 def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
3453 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
3454 def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
3455 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
3457 def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
3458 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
3459 def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
3460 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
3463 multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3464 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3465 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3466 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3468 // Expecting a i16 load any extended to i32 value.
3469 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3470 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3471 [(set VR128:$dst, (IntId (bitconvert
3472 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3476 defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
3477 defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
3479 // Common patterns involving scalar load
3480 def : Pat<(int_x86_sse41_pmovsxbq
3481 (bitconvert (v4i32 (X86vzmovl
3482 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
3483 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
3485 def : Pat<(int_x86_sse41_pmovzxbq
3486 (bitconvert (v4i32 (X86vzmovl
3487 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
3488 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
3491 /// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3492 multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
3493 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
3494 (ins VR128:$src1, i32i8imm:$src2),
3495 !strconcat(OpcodeStr,
3496 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3497 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3499 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3500 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
3501 !strconcat(OpcodeStr,
3502 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3505 // There's an AssertZext in the way of writing the store pattern
3506 // (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3509 defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
3512 /// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3513 multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
3514 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3515 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
3516 !strconcat(OpcodeStr,
3517 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3520 // There's an AssertZext in the way of writing the store pattern
3521 // (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3524 defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3527 /// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3528 multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
3529 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
3530 (ins VR128:$src1, i32i8imm:$src2),
3531 !strconcat(OpcodeStr,
3532 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3534 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
3535 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3536 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
3537 !strconcat(OpcodeStr,
3538 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3539 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3540 addr:$dst)]>, OpSize;
3543 defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
3546 /// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3548 multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
3549 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
3550 (ins VR128:$src1, i32i8imm:$src2),
3551 !strconcat(OpcodeStr,
3552 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3554 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
3556 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3557 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
3558 !strconcat(OpcodeStr,
3559 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3560 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
3561 addr:$dst)]>, OpSize;
3564 defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
3566 // Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3567 def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3570 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3571 Requires<[HasSSE41]>;
3573 let Constraints = "$src1 = $dst" in {
3574 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
3575 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3576 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
3577 !strconcat(OpcodeStr,
3578 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3580 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
3581 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3582 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3583 !strconcat(OpcodeStr,
3584 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3586 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3587 imm:$src3))]>, OpSize;
3591 defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3593 let Constraints = "$src1 = $dst" in {
3594 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
3595 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3596 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
3597 !strconcat(OpcodeStr,
3598 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3600 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3602 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3603 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3604 !strconcat(OpcodeStr,
3605 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3607 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3608 imm:$src3)))]>, OpSize;
3612 defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3614 // insertps has a few different modes, there's the first two here below which
3615 // are optimized inserts that won't zero arbitrary elements in the destination
3616 // vector. The next one matches the intrinsic and could zero arbitrary elements
3617 // in the target vector.
3618 let Constraints = "$src1 = $dst" in {
3619 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
3620 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3621 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3622 !strconcat(OpcodeStr,
3623 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3625 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
3627 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3628 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3629 !strconcat(OpcodeStr,
3630 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3632 (X86insrtps VR128:$src1,
3633 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
3634 imm:$src3))]>, OpSize;
3638 defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
3640 def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3641 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3643 // ptest instruction we'll lower to this in X86ISelLowering primarily from
3644 // the intel intrinsic that corresponds to this.
3645 let Defs = [EFLAGS] in {
3646 def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
3647 "ptest \t{$src2, $src1|$src1, $src2}",
3648 [(X86ptest VR128:$src1, VR128:$src2),
3649 (implicit EFLAGS)]>, OpSize;
3650 def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
3651 "ptest \t{$src2, $src1|$src1, $src2}",
3652 [(X86ptest VR128:$src1, (load addr:$src2)),
3653 (implicit EFLAGS)]>, OpSize;
3656 def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3657 "movntdqa\t{$src, $dst|$dst, $src}",
3658 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>;
3660 /// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3661 let Constraints = "$src1 = $dst" in {
3662 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3663 Intrinsic IntId128, bit Commutable = 0> {
3664 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3665 (ins VR128:$src1, VR128:$src2),
3666 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3667 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3669 let isCommutable = Commutable;
3671 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3672 (ins VR128:$src1, i128mem:$src2),
3673 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3675 (IntId128 VR128:$src1,
3676 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3680 defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
3682 def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3683 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3684 def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3685 (PCMPGTQrm VR128:$src1, addr:$src2)>;
3687 // crc intrinsic instruction
3688 // This set of instructions are only rm, the only difference is the size
3690 let Constraints = "$src1 = $dst" in {
3691 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
3692 (ins GR32:$src1, i8mem:$src2),
3693 "crc32 \t{$src2, $src1|$src1, $src2}",
3695 (int_x86_sse42_crc32_8 GR32:$src1,
3696 (load addr:$src2)))]>, OpSize;
3697 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
3698 (ins GR32:$src1, GR8:$src2),
3699 "crc32 \t{$src2, $src1|$src1, $src2}",
3701 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>,
3703 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
3704 (ins GR32:$src1, i16mem:$src2),
3705 "crc32 \t{$src2, $src1|$src1, $src2}",
3707 (int_x86_sse42_crc32_16 GR32:$src1,
3708 (load addr:$src2)))]>,
3710 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
3711 (ins GR32:$src1, GR16:$src2),
3712 "crc32 \t{$src2, $src1|$src1, $src2}",
3714 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
3716 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
3717 (ins GR32:$src1, i32mem:$src2),
3718 "crc32 \t{$src2, $src1|$src1, $src2}",
3720 (int_x86_sse42_crc32_32 GR32:$src1,
3721 (load addr:$src2)))]>, OpSize;
3722 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
3723 (ins GR32:$src1, GR32:$src2),
3724 "crc32 \t{$src2, $src1|$src1, $src2}",
3726 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>,
3728 def CRC64m64 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
3729 (ins GR64:$src1, i64mem:$src2),
3730 "crc32 \t{$src2, $src1|$src1, $src2}",
3732 (int_x86_sse42_crc32_64 GR64:$src1,
3733 (load addr:$src2)))]>,
3735 def CRC64r64 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
3736 (ins GR64:$src1, GR64:$src2),
3737 "crc32 \t{$src2, $src1|$src1, $src2}",
3739 (int_x86_sse42_crc32_64 GR64:$src1, GR64:$src2))]>,