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, f32>, 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 //===----------------------------------------------------------------------===//
73 // SSE Complex Patterns
74 //===----------------------------------------------------------------------===//
76 // These are 'extloads' from a scalar to the low element of a vector, zeroing
77 // the top elements. These are used for the SSE 'ss' and 'sd' instruction
79 def sse_load_f32 : ComplexPattern<v4f32, 5, "SelectScalarSSELoad", [],
80 [SDNPHasChain, SDNPMayLoad]>;
81 def sse_load_f64 : ComplexPattern<v2f64, 5, "SelectScalarSSELoad", [],
82 [SDNPHasChain, SDNPMayLoad]>;
84 def ssmem : Operand<v4f32> {
85 let PrintMethod = "printf32mem";
86 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm, i8imm);
88 def sdmem : Operand<v2f64> {
89 let PrintMethod = "printf64mem";
90 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm, i8imm);
93 //===----------------------------------------------------------------------===//
94 // SSE pattern fragments
95 //===----------------------------------------------------------------------===//
97 def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
98 def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
99 def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
100 def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
102 // Like 'store', but always requires vector alignment.
103 def alignedstore : PatFrag<(ops node:$val, node:$ptr),
104 (store node:$val, node:$ptr), [{
105 return cast<StoreSDNode>(N)->getAlignment() >= 16;
108 // Like 'load', but always requires vector alignment.
109 def alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
110 return cast<LoadSDNode>(N)->getAlignment() >= 16;
113 def alignedloadfsf32 : PatFrag<(ops node:$ptr), (f32 (alignedload node:$ptr))>;
114 def alignedloadfsf64 : PatFrag<(ops node:$ptr), (f64 (alignedload node:$ptr))>;
115 def alignedloadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (alignedload node:$ptr))>;
116 def alignedloadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (alignedload node:$ptr))>;
117 def alignedloadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (alignedload node:$ptr))>;
118 def alignedloadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (alignedload node:$ptr))>;
120 // Like 'load', but uses special alignment checks suitable for use in
121 // memory operands in most SSE instructions, which are required to
122 // be naturally aligned on some targets but not on others.
123 // FIXME: Actually implement support for targets that don't require the
124 // alignment. This probably wants a subtarget predicate.
125 def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{
126 return cast<LoadSDNode>(N)->getAlignment() >= 16;
129 def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
130 def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
131 def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
132 def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
133 def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
134 def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
135 def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
137 // SSSE3 uses MMX registers for some instructions. They aren't aligned on a
139 // FIXME: 8 byte alignment for mmx reads is not required
140 def memop64 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
141 return cast<LoadSDNode>(N)->getAlignment() >= 8;
144 def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
145 def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
146 def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
147 def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
149 def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
150 def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
151 def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
152 def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
153 def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
154 def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
156 def vzmovl_v2i64 : PatFrag<(ops node:$src),
157 (bitconvert (v2i64 (X86vzmovl
158 (v2i64 (scalar_to_vector (loadi64 node:$src))))))>;
159 def vzmovl_v4i32 : PatFrag<(ops node:$src),
160 (bitconvert (v4i32 (X86vzmovl
161 (v4i32 (scalar_to_vector (loadi32 node:$src))))))>;
163 def vzload_v2i64 : PatFrag<(ops node:$src),
164 (bitconvert (v2i64 (X86vzload node:$src)))>;
167 def fp32imm0 : PatLeaf<(f32 fpimm), [{
168 return N->isExactlyValue(+0.0);
171 def PSxLDQ_imm : SDNodeXForm<imm, [{
172 // Transformation function: imm >> 3
173 return getI32Imm(N->getZExtValue() >> 3);
176 // SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
178 def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
179 return getI8Imm(X86::getShuffleSHUFImmediate(N));
182 // SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
184 def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{
185 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
188 // SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
190 def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{
191 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
194 def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
195 (vector_shuffle node:$lhs, node:$rhs), [{
196 ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
197 return SVOp->isSplat() && SVOp->getSplatIndex() == 0;
200 def movddup : PatFrag<(ops node:$lhs, node:$rhs),
201 (vector_shuffle node:$lhs, node:$rhs), [{
202 return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N));
205 def movhlps : PatFrag<(ops node:$lhs, node:$rhs),
206 (vector_shuffle node:$lhs, node:$rhs), [{
207 return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N));
210 def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs),
211 (vector_shuffle node:$lhs, node:$rhs), [{
212 return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
215 def movhp : PatFrag<(ops node:$lhs, node:$rhs),
216 (vector_shuffle node:$lhs, node:$rhs), [{
217 return X86::isMOVHPMask(cast<ShuffleVectorSDNode>(N));
220 def movlp : PatFrag<(ops node:$lhs, node:$rhs),
221 (vector_shuffle node:$lhs, node:$rhs), [{
222 return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N));
225 def movl : PatFrag<(ops node:$lhs, node:$rhs),
226 (vector_shuffle node:$lhs, node:$rhs), [{
227 return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N));
230 def movshdup : PatFrag<(ops node:$lhs, node:$rhs),
231 (vector_shuffle node:$lhs, node:$rhs), [{
232 return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N));
235 def movsldup : PatFrag<(ops node:$lhs, node:$rhs),
236 (vector_shuffle node:$lhs, node:$rhs), [{
237 return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N));
240 def unpckl : PatFrag<(ops node:$lhs, node:$rhs),
241 (vector_shuffle node:$lhs, node:$rhs), [{
242 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
245 def unpckh : PatFrag<(ops node:$lhs, node:$rhs),
246 (vector_shuffle node:$lhs, node:$rhs), [{
247 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
250 def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
251 (vector_shuffle node:$lhs, node:$rhs), [{
252 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
255 def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
256 (vector_shuffle node:$lhs, node:$rhs), [{
257 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
260 def pshufd : PatFrag<(ops node:$lhs, node:$rhs),
261 (vector_shuffle node:$lhs, node:$rhs), [{
262 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
263 }], SHUFFLE_get_shuf_imm>;
265 def shufp : PatFrag<(ops node:$lhs, node:$rhs),
266 (vector_shuffle node:$lhs, node:$rhs), [{
267 return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N));
268 }], SHUFFLE_get_shuf_imm>;
270 def pshufhw : PatFrag<(ops node:$lhs, node:$rhs),
271 (vector_shuffle node:$lhs, node:$rhs), [{
272 return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N));
273 }], SHUFFLE_get_pshufhw_imm>;
275 def pshuflw : PatFrag<(ops node:$lhs, node:$rhs),
276 (vector_shuffle node:$lhs, node:$rhs), [{
277 return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N));
278 }], SHUFFLE_get_pshuflw_imm>;
280 //===----------------------------------------------------------------------===//
281 // SSE scalar FP Instructions
282 //===----------------------------------------------------------------------===//
284 // CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
285 // scheduler into a branch sequence.
286 // These are expanded by the scheduler.
287 let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
288 def CMOV_FR32 : I<0, Pseudo,
289 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
290 "#CMOV_FR32 PSEUDO!",
291 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
293 def CMOV_FR64 : I<0, Pseudo,
294 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
295 "#CMOV_FR64 PSEUDO!",
296 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
298 def CMOV_V4F32 : I<0, Pseudo,
299 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
300 "#CMOV_V4F32 PSEUDO!",
302 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
304 def CMOV_V2F64 : I<0, Pseudo,
305 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
306 "#CMOV_V2F64 PSEUDO!",
308 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
310 def CMOV_V2I64 : I<0, Pseudo,
311 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
312 "#CMOV_V2I64 PSEUDO!",
314 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
318 //===----------------------------------------------------------------------===//
320 //===----------------------------------------------------------------------===//
323 let neverHasSideEffects = 1 in
324 def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
325 "movss\t{$src, $dst|$dst, $src}", []>;
326 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
327 def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
328 "movss\t{$src, $dst|$dst, $src}",
329 [(set FR32:$dst, (loadf32 addr:$src))]>;
330 def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
331 "movss\t{$src, $dst|$dst, $src}",
332 [(store FR32:$src, addr:$dst)]>;
334 // Conversion instructions
335 def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
336 "cvttss2si\t{$src, $dst|$dst, $src}",
337 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
338 def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
339 "cvttss2si\t{$src, $dst|$dst, $src}",
340 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
341 def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
342 "cvtsi2ss\t{$src, $dst|$dst, $src}",
343 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
344 def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
345 "cvtsi2ss\t{$src, $dst|$dst, $src}",
346 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
348 // Match intrinsics which expect XMM operand(s).
349 def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
350 "cvtss2si\t{$src, $dst|$dst, $src}",
351 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
352 def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
353 "cvtss2si\t{$src, $dst|$dst, $src}",
354 [(set GR32:$dst, (int_x86_sse_cvtss2si
355 (load addr:$src)))]>;
357 // Match intrinisics which expect MM and XMM operand(s).
358 def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
359 "cvtps2pi\t{$src, $dst|$dst, $src}",
360 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
361 def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
362 "cvtps2pi\t{$src, $dst|$dst, $src}",
363 [(set VR64:$dst, (int_x86_sse_cvtps2pi
364 (load addr:$src)))]>;
365 def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
366 "cvttps2pi\t{$src, $dst|$dst, $src}",
367 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
368 def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
369 "cvttps2pi\t{$src, $dst|$dst, $src}",
370 [(set VR64:$dst, (int_x86_sse_cvttps2pi
371 (load addr:$src)))]>;
372 let Constraints = "$src1 = $dst" in {
373 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
374 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
375 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
376 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
378 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
379 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
380 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
381 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
382 (load addr:$src2)))]>;
385 // Aliases for intrinsics
386 def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
387 "cvttss2si\t{$src, $dst|$dst, $src}",
389 (int_x86_sse_cvttss2si VR128:$src))]>;
390 def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
391 "cvttss2si\t{$src, $dst|$dst, $src}",
393 (int_x86_sse_cvttss2si(load addr:$src)))]>;
395 let Constraints = "$src1 = $dst" in {
396 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
397 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
398 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
399 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
401 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
402 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
403 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
404 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
405 (loadi32 addr:$src2)))]>;
408 // Comparison instructions
409 let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
410 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
411 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
412 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
414 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
415 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
416 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
419 let Defs = [EFLAGS] in {
420 def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
421 "ucomiss\t{$src2, $src1|$src1, $src2}",
422 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
423 def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
424 "ucomiss\t{$src2, $src1|$src1, $src2}",
425 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
429 // Aliases to match intrinsics which expect XMM operand(s).
430 let Constraints = "$src1 = $dst" in {
431 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
432 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
433 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
434 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
435 VR128:$src, imm:$cc))]>;
436 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
437 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src, SSECC:$cc),
438 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
439 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
440 (load addr:$src), imm:$cc))]>;
443 let Defs = [EFLAGS] in {
444 def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
445 "ucomiss\t{$src2, $src1|$src1, $src2}",
446 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
448 def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
449 "ucomiss\t{$src2, $src1|$src1, $src2}",
450 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
453 def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
454 "comiss\t{$src2, $src1|$src1, $src2}",
455 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
457 def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
458 "comiss\t{$src2, $src1|$src1, $src2}",
459 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
463 // Aliases of packed SSE1 instructions for scalar use. These all have names that
466 // Alias instructions that map fld0 to pxor for sse.
467 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
468 def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
469 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
470 Requires<[HasSSE1]>, TB, OpSize;
472 // Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
474 let neverHasSideEffects = 1 in
475 def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
476 "movaps\t{$src, $dst|$dst, $src}", []>;
478 // Alias instruction to load FR32 from f128mem using movaps. Upper bits are
480 let canFoldAsLoad = 1 in
481 def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
482 "movaps\t{$src, $dst|$dst, $src}",
483 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
485 // Alias bitwise logical operations using SSE logical ops on packed FP values.
486 let Constraints = "$src1 = $dst" in {
487 let isCommutable = 1 in {
488 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
489 (ins FR32:$src1, FR32:$src2),
490 "andps\t{$src2, $dst|$dst, $src2}",
491 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
492 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
493 (ins FR32:$src1, FR32:$src2),
494 "orps\t{$src2, $dst|$dst, $src2}",
495 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
496 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
497 (ins FR32:$src1, FR32:$src2),
498 "xorps\t{$src2, $dst|$dst, $src2}",
499 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
502 def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
503 (ins FR32:$src1, f128mem:$src2),
504 "andps\t{$src2, $dst|$dst, $src2}",
505 [(set FR32:$dst, (X86fand FR32:$src1,
506 (memopfsf32 addr:$src2)))]>;
507 def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
508 (ins FR32:$src1, f128mem:$src2),
509 "orps\t{$src2, $dst|$dst, $src2}",
510 [(set FR32:$dst, (X86for FR32:$src1,
511 (memopfsf32 addr:$src2)))]>;
512 def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
513 (ins FR32:$src1, f128mem:$src2),
514 "xorps\t{$src2, $dst|$dst, $src2}",
515 [(set FR32:$dst, (X86fxor FR32:$src1,
516 (memopfsf32 addr:$src2)))]>;
518 let neverHasSideEffects = 1 in {
519 def FsANDNPSrr : PSI<0x55, MRMSrcReg,
520 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
521 "andnps\t{$src2, $dst|$dst, $src2}", []>;
523 def FsANDNPSrm : PSI<0x55, MRMSrcMem,
524 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
525 "andnps\t{$src2, $dst|$dst, $src2}", []>;
529 /// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
531 /// In addition, we also have a special variant of the scalar form here to
532 /// represent the associated intrinsic operation. This form is unlike the
533 /// plain scalar form, in that it takes an entire vector (instead of a scalar)
534 /// and leaves the top elements unmodified (therefore these cannot be commuted).
536 /// These three forms can each be reg+reg or reg+mem, so there are a total of
537 /// six "instructions".
539 let Constraints = "$src1 = $dst" in {
540 multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
541 SDNode OpNode, Intrinsic F32Int,
542 bit Commutable = 0> {
543 // Scalar operation, reg+reg.
544 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
545 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
546 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
547 let isCommutable = Commutable;
550 // Scalar operation, reg+mem.
551 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
552 (ins FR32:$src1, f32mem:$src2),
553 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
554 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
556 // Vector operation, reg+reg.
557 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
558 (ins VR128:$src1, VR128:$src2),
559 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
560 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
561 let isCommutable = Commutable;
564 // Vector operation, reg+mem.
565 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
566 (ins VR128:$src1, f128mem:$src2),
567 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
568 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
570 // Intrinsic operation, reg+reg.
571 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
572 (ins VR128:$src1, VR128:$src2),
573 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
574 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
576 // Intrinsic operation, reg+mem.
577 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
578 (ins VR128:$src1, ssmem:$src2),
579 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
580 [(set VR128:$dst, (F32Int VR128:$src1,
581 sse_load_f32:$src2))]>;
585 // Arithmetic instructions
586 defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
587 defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
588 defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
589 defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
591 /// sse1_fp_binop_rm - Other SSE1 binops
593 /// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
594 /// instructions for a full-vector intrinsic form. Operations that map
595 /// onto C operators don't use this form since they just use the plain
596 /// vector form instead of having a separate vector intrinsic form.
598 /// This provides a total of eight "instructions".
600 let Constraints = "$src1 = $dst" in {
601 multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
605 bit Commutable = 0> {
607 // Scalar operation, reg+reg.
608 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
609 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
610 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
611 let isCommutable = Commutable;
614 // Scalar operation, reg+mem.
615 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
616 (ins FR32:$src1, f32mem:$src2),
617 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
618 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
620 // Vector operation, reg+reg.
621 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
622 (ins VR128:$src1, VR128:$src2),
623 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
624 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
625 let isCommutable = Commutable;
628 // Vector operation, reg+mem.
629 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
630 (ins VR128:$src1, f128mem:$src2),
631 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
632 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
634 // Intrinsic operation, reg+reg.
635 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
636 (ins VR128:$src1, VR128:$src2),
637 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
638 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
639 let isCommutable = Commutable;
642 // Intrinsic operation, reg+mem.
643 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
644 (ins VR128:$src1, ssmem:$src2),
645 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
646 [(set VR128:$dst, (F32Int VR128:$src1,
647 sse_load_f32:$src2))]>;
649 // Vector intrinsic operation, reg+reg.
650 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
651 (ins VR128:$src1, VR128:$src2),
652 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
653 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
654 let isCommutable = Commutable;
657 // Vector intrinsic operation, reg+mem.
658 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
659 (ins VR128:$src1, f128mem:$src2),
660 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
661 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
665 defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
666 int_x86_sse_max_ss, int_x86_sse_max_ps>;
667 defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
668 int_x86_sse_min_ss, int_x86_sse_min_ps>;
670 //===----------------------------------------------------------------------===//
671 // SSE packed FP Instructions
674 let neverHasSideEffects = 1 in
675 def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
676 "movaps\t{$src, $dst|$dst, $src}", []>;
677 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
678 def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
679 "movaps\t{$src, $dst|$dst, $src}",
680 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
682 def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
683 "movaps\t{$src, $dst|$dst, $src}",
684 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
686 let neverHasSideEffects = 1 in
687 def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
688 "movups\t{$src, $dst|$dst, $src}", []>;
689 let canFoldAsLoad = 1 in
690 def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
691 "movups\t{$src, $dst|$dst, $src}",
692 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
693 def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
694 "movups\t{$src, $dst|$dst, $src}",
695 [(store (v4f32 VR128:$src), addr:$dst)]>;
697 // Intrinsic forms of MOVUPS load and store
698 let canFoldAsLoad = 1 in
699 def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
700 "movups\t{$src, $dst|$dst, $src}",
701 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
702 def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
703 "movups\t{$src, $dst|$dst, $src}",
704 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
706 let Constraints = "$src1 = $dst" in {
707 let AddedComplexity = 20 in {
708 def MOVLPSrm : PSI<0x12, MRMSrcMem,
709 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
710 "movlps\t{$src2, $dst|$dst, $src2}",
713 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
714 def MOVHPSrm : PSI<0x16, MRMSrcMem,
715 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
716 "movhps\t{$src2, $dst|$dst, $src2}",
719 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
721 } // Constraints = "$src1 = $dst"
724 def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
725 "movlps\t{$src, $dst|$dst, $src}",
726 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
727 (iPTR 0))), addr:$dst)]>;
729 // v2f64 extract element 1 is always custom lowered to unpack high to low
730 // and extract element 0 so the non-store version isn't too horrible.
731 def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
732 "movhps\t{$src, $dst|$dst, $src}",
733 [(store (f64 (vector_extract
734 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
735 (undef)), (iPTR 0))), addr:$dst)]>;
737 let Constraints = "$src1 = $dst" in {
738 let AddedComplexity = 20 in {
739 def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
740 "movlhps\t{$src2, $dst|$dst, $src2}",
742 (v4f32 (movhp VR128:$src1, VR128:$src2)))]>;
744 def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
745 "movhlps\t{$src2, $dst|$dst, $src2}",
747 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
749 } // Constraints = "$src1 = $dst"
751 let AddedComplexity = 20 in {
752 def : Pat<(v4f32 (movddup VR128:$src, (undef))),
753 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
754 def : Pat<(v2i64 (movddup VR128:$src, (undef))),
755 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
762 /// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
764 /// In addition, we also have a special variant of the scalar form here to
765 /// represent the associated intrinsic operation. This form is unlike the
766 /// plain scalar form, in that it takes an entire vector (instead of a
767 /// scalar) and leaves the top elements undefined.
769 /// And, we have a special variant form for a full-vector intrinsic form.
771 /// These four forms can each have a reg or a mem operand, so there are a
772 /// total of eight "instructions".
774 multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
778 bit Commutable = 0> {
779 // Scalar operation, reg.
780 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
781 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
782 [(set FR32:$dst, (OpNode FR32:$src))]> {
783 let isCommutable = Commutable;
786 // Scalar operation, mem.
787 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
788 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
789 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
791 // Vector operation, reg.
792 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
793 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
794 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
795 let isCommutable = Commutable;
798 // Vector operation, mem.
799 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
800 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
801 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
803 // Intrinsic operation, reg.
804 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
805 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
806 [(set VR128:$dst, (F32Int VR128:$src))]> {
807 let isCommutable = Commutable;
810 // Intrinsic operation, mem.
811 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
812 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
813 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
815 // Vector intrinsic operation, reg
816 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
817 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
818 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
819 let isCommutable = Commutable;
822 // Vector intrinsic operation, mem
823 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
824 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
825 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
829 defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
830 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
832 // Reciprocal approximations. Note that these typically require refinement
833 // in order to obtain suitable precision.
834 defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
835 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
836 defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
837 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
840 let Constraints = "$src1 = $dst" in {
841 let isCommutable = 1 in {
842 def ANDPSrr : PSI<0x54, MRMSrcReg,
843 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
844 "andps\t{$src2, $dst|$dst, $src2}",
845 [(set VR128:$dst, (v2i64
846 (and VR128:$src1, VR128:$src2)))]>;
847 def ORPSrr : PSI<0x56, MRMSrcReg,
848 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
849 "orps\t{$src2, $dst|$dst, $src2}",
850 [(set VR128:$dst, (v2i64
851 (or VR128:$src1, VR128:$src2)))]>;
852 def XORPSrr : PSI<0x57, MRMSrcReg,
853 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
854 "xorps\t{$src2, $dst|$dst, $src2}",
855 [(set VR128:$dst, (v2i64
856 (xor VR128:$src1, VR128:$src2)))]>;
859 def ANDPSrm : PSI<0x54, MRMSrcMem,
860 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
861 "andps\t{$src2, $dst|$dst, $src2}",
862 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
863 (memopv2i64 addr:$src2)))]>;
864 def ORPSrm : PSI<0x56, MRMSrcMem,
865 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
866 "orps\t{$src2, $dst|$dst, $src2}",
867 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
868 (memopv2i64 addr:$src2)))]>;
869 def XORPSrm : PSI<0x57, MRMSrcMem,
870 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
871 "xorps\t{$src2, $dst|$dst, $src2}",
872 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
873 (memopv2i64 addr:$src2)))]>;
874 def ANDNPSrr : PSI<0x55, MRMSrcReg,
875 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
876 "andnps\t{$src2, $dst|$dst, $src2}",
878 (v2i64 (and (xor VR128:$src1,
879 (bc_v2i64 (v4i32 immAllOnesV))),
881 def ANDNPSrm : PSI<0x55, MRMSrcMem,
882 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
883 "andnps\t{$src2, $dst|$dst, $src2}",
885 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
886 (bc_v2i64 (v4i32 immAllOnesV))),
887 (memopv2i64 addr:$src2))))]>;
890 let Constraints = "$src1 = $dst" in {
891 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
892 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
893 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
894 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
895 VR128:$src, imm:$cc))]>;
896 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
897 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
898 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
899 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
900 (memop addr:$src), imm:$cc))]>;
902 def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
903 (CMPPSrri VR128:$src1, VR128:$src2, imm:$cc)>;
904 def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
905 (CMPPSrmi VR128:$src1, addr:$src2, imm:$cc)>;
907 // Shuffle and unpack instructions
908 let Constraints = "$src1 = $dst" in {
909 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
910 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
911 (outs VR128:$dst), (ins VR128:$src1,
912 VR128:$src2, i8imm:$src3),
913 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
915 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
916 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
917 (outs VR128:$dst), (ins VR128:$src1,
918 f128mem:$src2, i8imm:$src3),
919 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
922 VR128:$src1, (memopv4f32 addr:$src2))))]>;
924 let AddedComplexity = 10 in {
925 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
926 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
927 "unpckhps\t{$src2, $dst|$dst, $src2}",
929 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
930 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
931 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
932 "unpckhps\t{$src2, $dst|$dst, $src2}",
934 (v4f32 (unpckh VR128:$src1,
935 (memopv4f32 addr:$src2))))]>;
937 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
938 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
939 "unpcklps\t{$src2, $dst|$dst, $src2}",
941 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
942 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
943 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
944 "unpcklps\t{$src2, $dst|$dst, $src2}",
946 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
948 } // Constraints = "$src1 = $dst"
951 def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
952 "movmskps\t{$src, $dst|$dst, $src}",
953 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
954 def MOVMSKPDrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
955 "movmskpd\t{$src, $dst|$dst, $src}",
956 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
958 // Prefetch intrinsic.
959 def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
960 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
961 def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
962 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
963 def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
964 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
965 def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
966 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
968 // Non-temporal stores
969 def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
970 "movntps\t{$src, $dst|$dst, $src}",
971 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
973 // Load, store, and memory fence
974 def SFENCE : PSI<0xAE, MRM7m, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
977 def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
978 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
979 def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
980 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
982 // Alias instructions that map zero vector to pxor / xorp* for sse.
983 // We set canFoldAsLoad because this can be converted to a constant-pool
984 // load of an all-zeros value if folding it would be beneficial.
985 let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1 in
986 def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
988 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
990 let Predicates = [HasSSE1] in {
991 def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
992 def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
993 def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
994 def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
995 def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
998 // FR32 to 128-bit vector conversion.
999 let isAsCheapAsAMove = 1 in
1000 def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
1001 "movss\t{$src, $dst|$dst, $src}",
1003 (v4f32 (scalar_to_vector FR32:$src)))]>;
1004 def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
1005 "movss\t{$src, $dst|$dst, $src}",
1007 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
1009 // FIXME: may not be able to eliminate this movss with coalescing the src and
1010 // dest register classes are different. We really want to write this pattern
1012 // def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1013 // (f32 FR32:$src)>;
1014 let isAsCheapAsAMove = 1 in
1015 def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
1016 "movss\t{$src, $dst|$dst, $src}",
1017 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
1019 def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
1020 "movss\t{$src, $dst|$dst, $src}",
1021 [(store (f32 (vector_extract (v4f32 VR128:$src),
1022 (iPTR 0))), addr:$dst)]>;
1025 // Move to lower bits of a VR128, leaving upper bits alone.
1026 // Three operand (but two address) aliases.
1027 let Constraints = "$src1 = $dst" in {
1028 let neverHasSideEffects = 1 in
1029 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
1030 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
1031 "movss\t{$src2, $dst|$dst, $src2}", []>;
1033 let AddedComplexity = 15 in
1034 def MOVLPSrr : SSI<0x10, MRMSrcReg,
1035 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1036 "movss\t{$src2, $dst|$dst, $src2}",
1038 (v4f32 (movl VR128:$src1, VR128:$src2)))]>;
1041 // Move to lower bits of a VR128 and zeroing upper bits.
1042 // Loading from memory automatically zeroing upper bits.
1043 let AddedComplexity = 20 in
1044 def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
1045 "movss\t{$src, $dst|$dst, $src}",
1046 [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector
1047 (loadf32 addr:$src))))))]>;
1049 def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
1050 (MOVZSS2PSrm addr:$src)>;
1052 //===----------------------------------------------------------------------===//
1053 // SSE2 Instructions
1054 //===----------------------------------------------------------------------===//
1056 // Move Instructions
1057 let neverHasSideEffects = 1 in
1058 def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1059 "movsd\t{$src, $dst|$dst, $src}", []>;
1060 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
1061 def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
1062 "movsd\t{$src, $dst|$dst, $src}",
1063 [(set FR64:$dst, (loadf64 addr:$src))]>;
1064 def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
1065 "movsd\t{$src, $dst|$dst, $src}",
1066 [(store FR64:$src, addr:$dst)]>;
1068 // Conversion instructions
1069 def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
1070 "cvttsd2si\t{$src, $dst|$dst, $src}",
1071 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
1072 def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
1073 "cvttsd2si\t{$src, $dst|$dst, $src}",
1074 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
1075 def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
1076 "cvtsd2ss\t{$src, $dst|$dst, $src}",
1077 [(set FR32:$dst, (fround FR64:$src))]>;
1078 def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
1079 "cvtsd2ss\t{$src, $dst|$dst, $src}",
1080 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
1081 def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
1082 "cvtsi2sd\t{$src, $dst|$dst, $src}",
1083 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
1084 def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
1085 "cvtsi2sd\t{$src, $dst|$dst, $src}",
1086 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1088 // SSE2 instructions with XS prefix
1089 def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
1090 "cvtss2sd\t{$src, $dst|$dst, $src}",
1091 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1092 Requires<[HasSSE2]>;
1093 def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
1094 "cvtss2sd\t{$src, $dst|$dst, $src}",
1095 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1096 Requires<[HasSSE2]>;
1098 // Match intrinsics which expect XMM operand(s).
1099 def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
1100 "cvtsd2si\t{$src, $dst|$dst, $src}",
1101 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
1102 def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
1103 "cvtsd2si\t{$src, $dst|$dst, $src}",
1104 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1105 (load addr:$src)))]>;
1107 // Match intrinisics which expect MM and XMM operand(s).
1108 def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1109 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1110 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1111 def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1112 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1113 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
1114 (memop addr:$src)))]>;
1115 def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1116 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1117 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1118 def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1119 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1120 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
1121 (memop addr:$src)))]>;
1122 def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1123 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1124 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1125 def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1126 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1127 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
1128 (load addr:$src)))]>;
1130 // Aliases for intrinsics
1131 def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
1132 "cvttsd2si\t{$src, $dst|$dst, $src}",
1134 (int_x86_sse2_cvttsd2si VR128:$src))]>;
1135 def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
1136 "cvttsd2si\t{$src, $dst|$dst, $src}",
1137 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1138 (load addr:$src)))]>;
1140 // Comparison instructions
1141 let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
1142 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
1143 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
1144 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
1146 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
1147 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
1148 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
1151 let Defs = [EFLAGS] in {
1152 def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
1153 "ucomisd\t{$src2, $src1|$src1, $src2}",
1154 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
1155 def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
1156 "ucomisd\t{$src2, $src1|$src1, $src2}",
1157 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
1158 (implicit EFLAGS)]>;
1159 } // Defs = [EFLAGS]
1161 // Aliases to match intrinsics which expect XMM operand(s).
1162 let Constraints = "$src1 = $dst" in {
1163 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
1164 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1165 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
1166 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1167 VR128:$src, imm:$cc))]>;
1168 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
1169 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src, SSECC:$cc),
1170 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
1171 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1172 (load addr:$src), imm:$cc))]>;
1175 let Defs = [EFLAGS] in {
1176 def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1177 "ucomisd\t{$src2, $src1|$src1, $src2}",
1178 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1179 (implicit EFLAGS)]>;
1180 def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
1181 "ucomisd\t{$src2, $src1|$src1, $src2}",
1182 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1183 (implicit EFLAGS)]>;
1185 def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1186 "comisd\t{$src2, $src1|$src1, $src2}",
1187 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1188 (implicit EFLAGS)]>;
1189 def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1190 "comisd\t{$src2, $src1|$src1, $src2}",
1191 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
1192 (implicit EFLAGS)]>;
1193 } // Defs = [EFLAGS]
1195 // Aliases of packed SSE2 instructions for scalar use. These all have names that
1198 // Alias instructions that map fld0 to pxor for sse.
1199 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1200 def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
1201 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
1202 Requires<[HasSSE2]>, TB, OpSize;
1204 // Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1206 let neverHasSideEffects = 1 in
1207 def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1208 "movapd\t{$src, $dst|$dst, $src}", []>;
1210 // Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1212 let canFoldAsLoad = 1 in
1213 def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
1214 "movapd\t{$src, $dst|$dst, $src}",
1215 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
1217 // Alias bitwise logical operations using SSE logical ops on packed FP values.
1218 let Constraints = "$src1 = $dst" in {
1219 let isCommutable = 1 in {
1220 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1221 (ins FR64:$src1, FR64:$src2),
1222 "andpd\t{$src2, $dst|$dst, $src2}",
1223 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
1224 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1225 (ins FR64:$src1, FR64:$src2),
1226 "orpd\t{$src2, $dst|$dst, $src2}",
1227 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
1228 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1229 (ins FR64:$src1, FR64:$src2),
1230 "xorpd\t{$src2, $dst|$dst, $src2}",
1231 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1234 def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1235 (ins FR64:$src1, f128mem:$src2),
1236 "andpd\t{$src2, $dst|$dst, $src2}",
1237 [(set FR64:$dst, (X86fand FR64:$src1,
1238 (memopfsf64 addr:$src2)))]>;
1239 def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1240 (ins FR64:$src1, f128mem:$src2),
1241 "orpd\t{$src2, $dst|$dst, $src2}",
1242 [(set FR64:$dst, (X86for FR64:$src1,
1243 (memopfsf64 addr:$src2)))]>;
1244 def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1245 (ins FR64:$src1, f128mem:$src2),
1246 "xorpd\t{$src2, $dst|$dst, $src2}",
1247 [(set FR64:$dst, (X86fxor FR64:$src1,
1248 (memopfsf64 addr:$src2)))]>;
1250 let neverHasSideEffects = 1 in {
1251 def FsANDNPDrr : PDI<0x55, MRMSrcReg,
1252 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1253 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
1255 def FsANDNPDrm : PDI<0x55, MRMSrcMem,
1256 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
1257 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
1261 /// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1263 /// In addition, we also have a special variant of the scalar form here to
1264 /// represent the associated intrinsic operation. This form is unlike the
1265 /// plain scalar form, in that it takes an entire vector (instead of a scalar)
1266 /// and leaves the top elements unmodified (therefore these cannot be commuted).
1268 /// These three forms can each be reg+reg or reg+mem, so there are a total of
1269 /// six "instructions".
1271 let Constraints = "$src1 = $dst" in {
1272 multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1273 SDNode OpNode, Intrinsic F64Int,
1274 bit Commutable = 0> {
1275 // Scalar operation, reg+reg.
1276 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1277 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1278 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1279 let isCommutable = Commutable;
1282 // Scalar operation, reg+mem.
1283 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1284 (ins FR64:$src1, f64mem:$src2),
1285 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1286 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1288 // Vector operation, reg+reg.
1289 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1290 (ins VR128:$src1, VR128:$src2),
1291 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1292 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1293 let isCommutable = Commutable;
1296 // Vector operation, reg+mem.
1297 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1298 (ins VR128:$src1, f128mem:$src2),
1299 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1300 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
1302 // Intrinsic operation, reg+reg.
1303 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1304 (ins VR128:$src1, VR128:$src2),
1305 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1306 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
1308 // Intrinsic operation, reg+mem.
1309 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1310 (ins VR128:$src1, sdmem:$src2),
1311 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1312 [(set VR128:$dst, (F64Int VR128:$src1,
1313 sse_load_f64:$src2))]>;
1317 // Arithmetic instructions
1318 defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1319 defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1320 defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1321 defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1323 /// sse2_fp_binop_rm - Other SSE2 binops
1325 /// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1326 /// instructions for a full-vector intrinsic form. Operations that map
1327 /// onto C operators don't use this form since they just use the plain
1328 /// vector form instead of having a separate vector intrinsic form.
1330 /// This provides a total of eight "instructions".
1332 let Constraints = "$src1 = $dst" in {
1333 multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1337 bit Commutable = 0> {
1339 // Scalar operation, reg+reg.
1340 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1341 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1342 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1343 let isCommutable = Commutable;
1346 // Scalar operation, reg+mem.
1347 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1348 (ins FR64:$src1, f64mem:$src2),
1349 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1350 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1352 // Vector operation, reg+reg.
1353 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1354 (ins VR128:$src1, VR128:$src2),
1355 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1356 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1357 let isCommutable = Commutable;
1360 // Vector operation, reg+mem.
1361 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1362 (ins VR128:$src1, f128mem:$src2),
1363 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1364 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
1366 // Intrinsic operation, reg+reg.
1367 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1368 (ins VR128:$src1, VR128:$src2),
1369 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1370 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1371 let isCommutable = Commutable;
1374 // Intrinsic operation, reg+mem.
1375 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1376 (ins VR128:$src1, sdmem:$src2),
1377 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1378 [(set VR128:$dst, (F64Int VR128:$src1,
1379 sse_load_f64:$src2))]>;
1381 // Vector intrinsic operation, reg+reg.
1382 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1383 (ins VR128:$src1, VR128:$src2),
1384 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1385 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1386 let isCommutable = Commutable;
1389 // Vector intrinsic operation, reg+mem.
1390 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1391 (ins VR128:$src1, f128mem:$src2),
1392 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1393 [(set VR128:$dst, (V2F64Int VR128:$src1,
1394 (memopv2f64 addr:$src2)))]>;
1398 defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1399 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1400 defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1401 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1403 //===----------------------------------------------------------------------===//
1404 // SSE packed FP Instructions
1406 // Move Instructions
1407 let neverHasSideEffects = 1 in
1408 def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1409 "movapd\t{$src, $dst|$dst, $src}", []>;
1410 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
1411 def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1412 "movapd\t{$src, $dst|$dst, $src}",
1413 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
1415 def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1416 "movapd\t{$src, $dst|$dst, $src}",
1417 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
1419 let neverHasSideEffects = 1 in
1420 def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1421 "movupd\t{$src, $dst|$dst, $src}", []>;
1422 let canFoldAsLoad = 1 in
1423 def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1424 "movupd\t{$src, $dst|$dst, $src}",
1425 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
1426 def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1427 "movupd\t{$src, $dst|$dst, $src}",
1428 [(store (v2f64 VR128:$src), addr:$dst)]>;
1430 // Intrinsic forms of MOVUPD load and store
1431 def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1432 "movupd\t{$src, $dst|$dst, $src}",
1433 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
1434 def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1435 "movupd\t{$src, $dst|$dst, $src}",
1436 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
1438 let Constraints = "$src1 = $dst" in {
1439 let AddedComplexity = 20 in {
1440 def MOVLPDrm : PDI<0x12, MRMSrcMem,
1441 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
1442 "movlpd\t{$src2, $dst|$dst, $src2}",
1444 (v2f64 (movlp VR128:$src1,
1445 (scalar_to_vector (loadf64 addr:$src2)))))]>;
1446 def MOVHPDrm : PDI<0x16, MRMSrcMem,
1447 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
1448 "movhpd\t{$src2, $dst|$dst, $src2}",
1450 (v2f64 (movhp VR128:$src1,
1451 (scalar_to_vector (loadf64 addr:$src2)))))]>;
1452 } // AddedComplexity
1453 } // Constraints = "$src1 = $dst"
1455 def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
1456 "movlpd\t{$src, $dst|$dst, $src}",
1457 [(store (f64 (vector_extract (v2f64 VR128:$src),
1458 (iPTR 0))), addr:$dst)]>;
1460 // v2f64 extract element 1 is always custom lowered to unpack high to low
1461 // and extract element 0 so the non-store version isn't too horrible.
1462 def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
1463 "movhpd\t{$src, $dst|$dst, $src}",
1464 [(store (f64 (vector_extract
1465 (v2f64 (unpckh VR128:$src, (undef))),
1466 (iPTR 0))), addr:$dst)]>;
1468 // SSE2 instructions without OpSize prefix
1469 def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1470 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1471 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1472 TB, Requires<[HasSSE2]>;
1473 def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1474 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1475 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1476 (bitconvert (memopv2i64 addr:$src))))]>,
1477 TB, Requires<[HasSSE2]>;
1479 // SSE2 instructions with XS prefix
1480 def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1481 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1482 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1483 XS, Requires<[HasSSE2]>;
1484 def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1485 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1486 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1487 (bitconvert (memopv2i64 addr:$src))))]>,
1488 XS, Requires<[HasSSE2]>;
1490 def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1491 "cvtps2dq\t{$src, $dst|$dst, $src}",
1492 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
1493 def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1494 "cvtps2dq\t{$src, $dst|$dst, $src}",
1495 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1496 (memop addr:$src)))]>;
1497 // SSE2 packed instructions with XS prefix
1498 def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1499 "cvttps2dq\t{$src, $dst|$dst, $src}",
1500 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1501 XS, Requires<[HasSSE2]>;
1502 def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1503 "cvttps2dq\t{$src, $dst|$dst, $src}",
1504 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1505 (memop addr:$src)))]>,
1506 XS, Requires<[HasSSE2]>;
1508 // SSE2 packed instructions with XD prefix
1509 def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1510 "cvtpd2dq\t{$src, $dst|$dst, $src}",
1511 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1512 XD, Requires<[HasSSE2]>;
1513 def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1514 "cvtpd2dq\t{$src, $dst|$dst, $src}",
1515 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1516 (memop addr:$src)))]>,
1517 XD, Requires<[HasSSE2]>;
1519 def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1520 "cvttpd2dq\t{$src, $dst|$dst, $src}",
1521 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
1522 def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
1523 "cvttpd2dq\t{$src, $dst|$dst, $src}",
1524 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1525 (memop addr:$src)))]>;
1527 // SSE2 instructions without OpSize prefix
1528 def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1529 "cvtps2pd\t{$src, $dst|$dst, $src}",
1530 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1531 TB, Requires<[HasSSE2]>;
1532 def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
1533 "cvtps2pd\t{$src, $dst|$dst, $src}",
1534 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1535 (load addr:$src)))]>,
1536 TB, Requires<[HasSSE2]>;
1538 def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1539 "cvtpd2ps\t{$src, $dst|$dst, $src}",
1540 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
1541 def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1542 "cvtpd2ps\t{$src, $dst|$dst, $src}",
1543 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1544 (memop addr:$src)))]>;
1546 // Match intrinsics which expect XMM operand(s).
1547 // Aliases for intrinsics
1548 let Constraints = "$src1 = $dst" in {
1549 def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
1550 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
1551 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
1552 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1554 def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
1555 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
1556 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
1557 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1558 (loadi32 addr:$src2)))]>;
1559 def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
1560 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1561 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
1562 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1564 def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
1565 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
1566 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
1567 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1568 (load addr:$src2)))]>;
1569 def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
1570 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1571 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
1572 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1573 VR128:$src2))]>, XS,
1574 Requires<[HasSSE2]>;
1575 def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
1576 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
1577 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
1578 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1579 (load addr:$src2)))]>, XS,
1580 Requires<[HasSSE2]>;
1585 /// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1587 /// In addition, we also have a special variant of the scalar form here to
1588 /// represent the associated intrinsic operation. This form is unlike the
1589 /// plain scalar form, in that it takes an entire vector (instead of a
1590 /// scalar) and leaves the top elements undefined.
1592 /// And, we have a special variant form for a full-vector intrinsic form.
1594 /// These four forms can each have a reg or a mem operand, so there are a
1595 /// total of eight "instructions".
1597 multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1601 bit Commutable = 0> {
1602 // Scalar operation, reg.
1603 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1604 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1605 [(set FR64:$dst, (OpNode FR64:$src))]> {
1606 let isCommutable = Commutable;
1609 // Scalar operation, mem.
1610 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
1611 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1612 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1614 // Vector operation, reg.
1615 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1616 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1617 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1618 let isCommutable = Commutable;
1621 // Vector operation, mem.
1622 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1623 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1624 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
1626 // Intrinsic operation, reg.
1627 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1628 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1629 [(set VR128:$dst, (F64Int VR128:$src))]> {
1630 let isCommutable = Commutable;
1633 // Intrinsic operation, mem.
1634 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
1635 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1636 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1638 // Vector intrinsic operation, reg
1639 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1640 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1641 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1642 let isCommutable = Commutable;
1645 // Vector intrinsic operation, mem
1646 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1647 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1648 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
1652 defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1653 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1655 // There is no f64 version of the reciprocal approximation instructions.
1658 let Constraints = "$src1 = $dst" in {
1659 let isCommutable = 1 in {
1660 def ANDPDrr : PDI<0x54, MRMSrcReg,
1661 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1662 "andpd\t{$src2, $dst|$dst, $src2}",
1664 (and (bc_v2i64 (v2f64 VR128:$src1)),
1665 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1666 def ORPDrr : PDI<0x56, MRMSrcReg,
1667 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1668 "orpd\t{$src2, $dst|$dst, $src2}",
1670 (or (bc_v2i64 (v2f64 VR128:$src1)),
1671 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1672 def XORPDrr : PDI<0x57, MRMSrcReg,
1673 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1674 "xorpd\t{$src2, $dst|$dst, $src2}",
1676 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1677 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1680 def ANDPDrm : PDI<0x54, MRMSrcMem,
1681 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1682 "andpd\t{$src2, $dst|$dst, $src2}",
1684 (and (bc_v2i64 (v2f64 VR128:$src1)),
1685 (memopv2i64 addr:$src2)))]>;
1686 def ORPDrm : PDI<0x56, MRMSrcMem,
1687 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1688 "orpd\t{$src2, $dst|$dst, $src2}",
1690 (or (bc_v2i64 (v2f64 VR128:$src1)),
1691 (memopv2i64 addr:$src2)))]>;
1692 def XORPDrm : PDI<0x57, MRMSrcMem,
1693 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1694 "xorpd\t{$src2, $dst|$dst, $src2}",
1696 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1697 (memopv2i64 addr:$src2)))]>;
1698 def ANDNPDrr : PDI<0x55, MRMSrcReg,
1699 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1700 "andnpd\t{$src2, $dst|$dst, $src2}",
1702 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1703 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1704 def ANDNPDrm : PDI<0x55, MRMSrcMem,
1705 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
1706 "andnpd\t{$src2, $dst|$dst, $src2}",
1708 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1709 (memopv2i64 addr:$src2)))]>;
1712 let Constraints = "$src1 = $dst" in {
1713 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
1714 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1715 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1716 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1717 VR128:$src, imm:$cc))]>;
1718 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
1719 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1720 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1721 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1722 (memop addr:$src), imm:$cc))]>;
1724 def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
1725 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
1726 def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
1727 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
1729 // Shuffle and unpack instructions
1730 let Constraints = "$src1 = $dst" in {
1731 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
1732 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1733 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1735 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
1736 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
1737 (outs VR128:$dst), (ins VR128:$src1,
1738 f128mem:$src2, i8imm:$src3),
1739 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1742 VR128:$src1, (memopv2f64 addr:$src2))))]>;
1744 let AddedComplexity = 10 in {
1745 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
1746 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1747 "unpckhpd\t{$src2, $dst|$dst, $src2}",
1749 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
1750 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
1751 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1752 "unpckhpd\t{$src2, $dst|$dst, $src2}",
1754 (v2f64 (unpckh VR128:$src1,
1755 (memopv2f64 addr:$src2))))]>;
1757 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
1758 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1759 "unpcklpd\t{$src2, $dst|$dst, $src2}",
1761 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
1762 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
1763 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1764 "unpcklpd\t{$src2, $dst|$dst, $src2}",
1766 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
1767 } // AddedComplexity
1768 } // Constraints = "$src1 = $dst"
1771 //===----------------------------------------------------------------------===//
1772 // SSE integer instructions
1774 // Move Instructions
1775 let neverHasSideEffects = 1 in
1776 def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1777 "movdqa\t{$src, $dst|$dst, $src}", []>;
1778 let canFoldAsLoad = 1, mayLoad = 1 in
1779 def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1780 "movdqa\t{$src, $dst|$dst, $src}",
1781 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
1783 def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1784 "movdqa\t{$src, $dst|$dst, $src}",
1785 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
1786 let canFoldAsLoad = 1, mayLoad = 1 in
1787 def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1788 "movdqu\t{$src, $dst|$dst, $src}",
1789 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
1790 XS, Requires<[HasSSE2]>;
1792 def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1793 "movdqu\t{$src, $dst|$dst, $src}",
1794 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
1795 XS, Requires<[HasSSE2]>;
1797 // Intrinsic forms of MOVDQU load and store
1798 let canFoldAsLoad = 1 in
1799 def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1800 "movdqu\t{$src, $dst|$dst, $src}",
1801 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1802 XS, Requires<[HasSSE2]>;
1803 def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1804 "movdqu\t{$src, $dst|$dst, $src}",
1805 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1806 XS, Requires<[HasSSE2]>;
1808 let Constraints = "$src1 = $dst" in {
1810 multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1811 bit Commutable = 0> {
1812 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1813 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1814 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1815 let isCommutable = Commutable;
1817 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1818 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1819 [(set VR128:$dst, (IntId VR128:$src1,
1820 (bitconvert (memopv2i64 addr:$src2))))]>;
1823 multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1825 Intrinsic IntId, Intrinsic IntId2> {
1826 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1827 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1828 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
1829 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1830 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1831 [(set VR128:$dst, (IntId VR128:$src1,
1832 (bitconvert (memopv2i64 addr:$src2))))]>;
1833 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
1834 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1835 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
1838 /// PDI_binop_rm - Simple SSE2 binary operator.
1839 multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1840 ValueType OpVT, bit Commutable = 0> {
1841 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1842 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1843 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1844 let isCommutable = Commutable;
1846 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1847 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1848 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
1849 (bitconvert (memopv2i64 addr:$src2)))))]>;
1852 /// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1854 /// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1855 /// to collapse (bitconvert VT to VT) into its operand.
1857 multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1858 bit Commutable = 0> {
1859 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1860 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1861 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1862 let isCommutable = Commutable;
1864 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1865 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1866 [(set VR128:$dst, (OpNode VR128:$src1,(memopv2i64 addr:$src2)))]>;
1869 } // Constraints = "$src1 = $dst"
1871 // 128-bit Integer Arithmetic
1873 defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1874 defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1875 defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1876 defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1878 defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1879 defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1880 defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1881 defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1883 defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1884 defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1885 defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1886 defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1888 defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1889 defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1890 defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1891 defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1893 defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1895 defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1896 defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1897 defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1899 defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1901 defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1902 defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1905 defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1906 defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1907 defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1908 defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1909 defm PSADBW : PDI_binop_rm_int<0xE0, "psadbw", int_x86_sse2_psad_bw, 1>;
1912 defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
1913 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
1914 defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
1915 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
1916 defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
1917 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
1919 defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
1920 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
1921 defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
1922 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
1923 defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
1924 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
1926 defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
1927 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
1928 defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
1929 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
1931 // 128-bit logical shifts.
1932 let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
1933 def PSLLDQri : PDIi8<0x73, MRM7r,
1934 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
1935 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
1936 def PSRLDQri : PDIi8<0x73, MRM3r,
1937 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
1938 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
1939 // PSRADQri doesn't exist in SSE[1-3].
1942 let Predicates = [HasSSE2] in {
1943 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1944 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1945 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1946 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1947 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
1948 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
1949 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
1950 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
1951 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1952 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1954 // Shift up / down and insert zero's.
1955 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
1956 (v2i64 (PSLLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>;
1957 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
1958 (v2i64 (PSRLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>;
1962 defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1963 defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1964 defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1966 let Constraints = "$src1 = $dst" in {
1967 def PANDNrr : PDI<0xDF, MRMSrcReg,
1968 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1969 "pandn\t{$src2, $dst|$dst, $src2}",
1970 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1973 def PANDNrm : PDI<0xDF, MRMSrcMem,
1974 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1975 "pandn\t{$src2, $dst|$dst, $src2}",
1976 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1977 (memopv2i64 addr:$src2))))]>;
1980 // SSE2 Integer comparison
1981 defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1982 defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
1983 defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
1984 defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
1985 defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
1986 defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
1988 def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
1989 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
1990 def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
1991 (PCMPEQBrm VR128:$src1, addr:$src2)>;
1992 def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
1993 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
1994 def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
1995 (PCMPEQWrm VR128:$src1, addr:$src2)>;
1996 def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
1997 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
1998 def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
1999 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2001 def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
2002 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
2003 def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
2004 (PCMPGTBrm VR128:$src1, addr:$src2)>;
2005 def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
2006 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
2007 def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
2008 (PCMPGTWrm VR128:$src1, addr:$src2)>;
2009 def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
2010 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
2011 def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
2012 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2015 // Pack instructions
2016 defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2017 defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2018 defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2020 // Shuffle and unpack instructions
2021 def PSHUFDri : PDIi8<0x70, MRMSrcReg,
2022 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
2023 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2024 [(set VR128:$dst, (v4i32 (pshufd:$src2
2025 VR128:$src1, (undef))))]>;
2026 def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
2027 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
2028 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2029 [(set VR128:$dst, (v4i32 (pshufd:$src2
2030 (bc_v4i32(memopv2i64 addr:$src1)),
2033 // SSE2 with ImmT == Imm8 and XS prefix.
2034 def PSHUFHWri : Ii8<0x70, MRMSrcReg,
2035 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
2036 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2037 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2039 XS, Requires<[HasSSE2]>;
2040 def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
2041 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
2042 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2043 [(set VR128:$dst, (v8i16 (pshufhw:$src2
2044 (bc_v8i16 (memopv2i64 addr:$src1)),
2046 XS, Requires<[HasSSE2]>;
2048 // SSE2 with ImmT == Imm8 and XD prefix.
2049 def PSHUFLWri : Ii8<0x70, MRMSrcReg,
2050 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
2051 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2052 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2054 XD, Requires<[HasSSE2]>;
2055 def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
2056 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
2057 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2058 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2059 (bc_v8i16 (memopv2i64 addr:$src1)),
2061 XD, Requires<[HasSSE2]>;
2064 let Constraints = "$src1 = $dst" in {
2065 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
2066 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2067 "punpcklbw\t{$src2, $dst|$dst, $src2}",
2069 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
2070 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
2071 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2072 "punpcklbw\t{$src2, $dst|$dst, $src2}",
2074 (unpckl VR128:$src1,
2075 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
2076 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
2077 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2078 "punpcklwd\t{$src2, $dst|$dst, $src2}",
2080 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
2081 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
2082 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2083 "punpcklwd\t{$src2, $dst|$dst, $src2}",
2085 (unpckl VR128:$src1,
2086 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
2087 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
2088 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2089 "punpckldq\t{$src2, $dst|$dst, $src2}",
2091 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
2092 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
2093 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2094 "punpckldq\t{$src2, $dst|$dst, $src2}",
2096 (unpckl VR128:$src1,
2097 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
2098 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
2099 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2100 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
2102 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
2103 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
2104 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2105 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
2107 (v2i64 (unpckl VR128:$src1,
2108 (memopv2i64 addr:$src2))))]>;
2110 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
2111 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2112 "punpckhbw\t{$src2, $dst|$dst, $src2}",
2114 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
2115 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
2116 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2117 "punpckhbw\t{$src2, $dst|$dst, $src2}",
2119 (unpckh VR128:$src1,
2120 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
2121 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
2122 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2123 "punpckhwd\t{$src2, $dst|$dst, $src2}",
2125 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
2126 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
2127 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2128 "punpckhwd\t{$src2, $dst|$dst, $src2}",
2130 (unpckh VR128:$src1,
2131 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
2132 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
2133 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2134 "punpckhdq\t{$src2, $dst|$dst, $src2}",
2136 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
2137 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
2138 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2139 "punpckhdq\t{$src2, $dst|$dst, $src2}",
2141 (unpckh VR128:$src1,
2142 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
2143 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
2144 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2145 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
2147 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
2148 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
2149 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2150 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
2152 (v2i64 (unpckh VR128:$src1,
2153 (memopv2i64 addr:$src2))))]>;
2157 def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
2158 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
2159 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2160 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
2162 let Constraints = "$src1 = $dst" in {
2163 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
2164 (outs VR128:$dst), (ins VR128:$src1,
2165 GR32:$src2, i32i8imm:$src3),
2166 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2168 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
2169 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
2170 (outs VR128:$dst), (ins VR128:$src1,
2171 i16mem:$src2, i32i8imm:$src3),
2172 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2174 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2179 def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
2180 "pmovmskb\t{$src, $dst|$dst, $src}",
2181 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2183 // Conditional store
2185 def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2186 "maskmovdqu\t{$mask, $src|$src, $mask}",
2187 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
2190 def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2191 "maskmovdqu\t{$mask, $src|$src, $mask}",
2192 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2194 // Non-temporal stores
2195 def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2196 "movntpd\t{$src, $dst|$dst, $src}",
2197 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
2198 def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2199 "movntdq\t{$src, $dst|$dst, $src}",
2200 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
2201 def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
2202 "movnti\t{$src, $dst|$dst, $src}",
2203 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2204 TB, Requires<[HasSSE2]>;
2207 def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
2208 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
2209 TB, Requires<[HasSSE2]>;
2211 // Load, store, and memory fence
2212 def LFENCE : I<0xAE, MRM5r, (outs), (ins),
2213 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
2214 def MFENCE : I<0xAE, MRM6r, (outs), (ins),
2215 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2217 //TODO: custom lower this so as to never even generate the noop
2218 def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
2220 def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2221 def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
2222 def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
2225 // Alias instructions that map zero vector to pxor / xorp* for sse.
2226 // We set canFoldAsLoad because this can be converted to a constant-pool
2227 // load of an all-ones value if folding it would be beneficial.
2228 let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1 in
2229 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
2230 "pcmpeqd\t$dst, $dst",
2231 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
2233 // FR64 to 128-bit vector conversion.
2234 let isAsCheapAsAMove = 1 in
2235 def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
2236 "movsd\t{$src, $dst|$dst, $src}",
2238 (v2f64 (scalar_to_vector FR64:$src)))]>;
2239 def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2240 "movsd\t{$src, $dst|$dst, $src}",
2242 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2244 def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2245 "movd\t{$src, $dst|$dst, $src}",
2247 (v4i32 (scalar_to_vector GR32:$src)))]>;
2248 def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2249 "movd\t{$src, $dst|$dst, $src}",
2251 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2253 def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
2254 "movd\t{$src, $dst|$dst, $src}",
2255 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2257 def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
2258 "movd\t{$src, $dst|$dst, $src}",
2259 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2261 // SSE2 instructions with XS prefix
2262 def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
2263 "movq\t{$src, $dst|$dst, $src}",
2265 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2266 Requires<[HasSSE2]>;
2267 def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
2268 "movq\t{$src, $dst|$dst, $src}",
2269 [(store (i64 (vector_extract (v2i64 VR128:$src),
2270 (iPTR 0))), addr:$dst)]>;
2272 // FIXME: may not be able to eliminate this movss with coalescing the src and
2273 // dest register classes are different. We really want to write this pattern
2275 // def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2276 // (f32 FR32:$src)>;
2277 let isAsCheapAsAMove = 1 in
2278 def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
2279 "movsd\t{$src, $dst|$dst, $src}",
2280 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2282 def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
2283 "movsd\t{$src, $dst|$dst, $src}",
2284 [(store (f64 (vector_extract (v2f64 VR128:$src),
2285 (iPTR 0))), addr:$dst)]>;
2286 def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
2287 "movd\t{$src, $dst|$dst, $src}",
2288 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2290 def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
2291 "movd\t{$src, $dst|$dst, $src}",
2292 [(store (i32 (vector_extract (v4i32 VR128:$src),
2293 (iPTR 0))), addr:$dst)]>;
2295 def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
2296 "movd\t{$src, $dst|$dst, $src}",
2297 [(set GR32:$dst, (bitconvert FR32:$src))]>;
2298 def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
2299 "movd\t{$src, $dst|$dst, $src}",
2300 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2303 // Move to lower bits of a VR128, leaving upper bits alone.
2304 // Three operand (but two address) aliases.
2305 let Constraints = "$src1 = $dst" in {
2306 let neverHasSideEffects = 1 in
2307 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
2308 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
2309 "movsd\t{$src2, $dst|$dst, $src2}", []>;
2311 let AddedComplexity = 15 in
2312 def MOVLPDrr : SDI<0x10, MRMSrcReg,
2313 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2314 "movsd\t{$src2, $dst|$dst, $src2}",
2316 (v2f64 (movl VR128:$src1, VR128:$src2)))]>;
2319 // Store / copy lower 64-bits of a XMM register.
2320 def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
2321 "movq\t{$src, $dst|$dst, $src}",
2322 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2324 // Move to lower bits of a VR128 and zeroing upper bits.
2325 // Loading from memory automatically zeroing upper bits.
2326 let AddedComplexity = 20 in {
2327 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2328 "movsd\t{$src, $dst|$dst, $src}",
2330 (v2f64 (X86vzmovl (v2f64 (scalar_to_vector
2331 (loadf64 addr:$src))))))]>;
2333 def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
2334 (MOVZSD2PDrm addr:$src)>;
2335 def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
2336 (MOVZSD2PDrm addr:$src)>;
2337 def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>;
2340 // movd / movq to XMM register zero-extends
2341 let AddedComplexity = 15 in {
2342 def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2343 "movd\t{$src, $dst|$dst, $src}",
2344 [(set VR128:$dst, (v4i32 (X86vzmovl
2345 (v4i32 (scalar_to_vector GR32:$src)))))]>;
2346 // This is X86-64 only.
2347 def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2348 "mov{d|q}\t{$src, $dst|$dst, $src}",
2349 [(set VR128:$dst, (v2i64 (X86vzmovl
2350 (v2i64 (scalar_to_vector GR64:$src)))))]>;
2353 let AddedComplexity = 20 in {
2354 def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2355 "movd\t{$src, $dst|$dst, $src}",
2357 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
2358 (loadi32 addr:$src))))))]>;
2360 def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2361 (MOVZDI2PDIrm addr:$src)>;
2362 def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2363 (MOVZDI2PDIrm addr:$src)>;
2364 def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2365 (MOVZDI2PDIrm addr:$src)>;
2367 def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
2368 "movq\t{$src, $dst|$dst, $src}",
2370 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
2371 (loadi64 addr:$src))))))]>, XS,
2372 Requires<[HasSSE2]>;
2374 def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2375 (MOVZQI2PQIrm addr:$src)>;
2376 def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2377 (MOVZQI2PQIrm addr:$src)>;
2378 def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
2381 // Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2382 // IA32 document. movq xmm1, xmm2 does clear the high bits.
2383 let AddedComplexity = 15 in
2384 def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2385 "movq\t{$src, $dst|$dst, $src}",
2386 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
2387 XS, Requires<[HasSSE2]>;
2389 let AddedComplexity = 20 in {
2390 def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2391 "movq\t{$src, $dst|$dst, $src}",
2392 [(set VR128:$dst, (v2i64 (X86vzmovl
2393 (loadv2i64 addr:$src))))]>,
2394 XS, Requires<[HasSSE2]>;
2396 def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2397 (MOVZPQILo2PQIrm addr:$src)>;
2400 //===----------------------------------------------------------------------===//
2401 // SSE3 Instructions
2402 //===----------------------------------------------------------------------===//
2404 // Move Instructions
2405 def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2406 "movshdup\t{$src, $dst|$dst, $src}",
2407 [(set VR128:$dst, (v4f32 (movshdup
2408 VR128:$src, (undef))))]>;
2409 def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
2410 "movshdup\t{$src, $dst|$dst, $src}",
2411 [(set VR128:$dst, (movshdup
2412 (memopv4f32 addr:$src), (undef)))]>;
2414 def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2415 "movsldup\t{$src, $dst|$dst, $src}",
2416 [(set VR128:$dst, (v4f32 (movsldup
2417 VR128:$src, (undef))))]>;
2418 def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
2419 "movsldup\t{$src, $dst|$dst, $src}",
2420 [(set VR128:$dst, (movsldup
2421 (memopv4f32 addr:$src), (undef)))]>;
2423 def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2424 "movddup\t{$src, $dst|$dst, $src}",
2425 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
2426 def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2427 "movddup\t{$src, $dst|$dst, $src}",
2429 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2432 def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2434 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2436 let AddedComplexity = 5 in {
2437 def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
2438 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2439 def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2440 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2441 def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2442 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2443 def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2444 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2448 let Constraints = "$src1 = $dst" in {
2449 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
2450 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2451 "addsubps\t{$src2, $dst|$dst, $src2}",
2452 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2454 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
2455 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2456 "addsubps\t{$src2, $dst|$dst, $src2}",
2457 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2458 (memop addr:$src2)))]>;
2459 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
2460 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2461 "addsubpd\t{$src2, $dst|$dst, $src2}",
2462 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2464 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
2465 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2466 "addsubpd\t{$src2, $dst|$dst, $src2}",
2467 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2468 (memop addr:$src2)))]>;
2471 def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2472 "lddqu\t{$src, $dst|$dst, $src}",
2473 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2476 class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
2477 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2478 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2479 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2480 class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
2481 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2482 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2483 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
2484 class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
2485 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2486 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2487 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2488 class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
2489 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2490 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2491 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
2493 let Constraints = "$src1 = $dst" in {
2494 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2495 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2496 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2497 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2498 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2499 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2500 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2501 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2504 // Thread synchronization
2505 def MONITOR : I<0xC8, RawFrm, (outs), (ins), "monitor",
2506 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
2507 def MWAIT : I<0xC9, RawFrm, (outs), (ins), "mwait",
2508 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2510 // vector_shuffle v1, <undef> <1, 1, 3, 3>
2511 let AddedComplexity = 15 in
2512 def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
2513 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2514 let AddedComplexity = 20 in
2515 def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
2516 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2518 // vector_shuffle v1, <undef> <0, 0, 2, 2>
2519 let AddedComplexity = 15 in
2520 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
2521 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2522 let AddedComplexity = 20 in
2523 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
2524 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2526 //===----------------------------------------------------------------------===//
2527 // SSSE3 Instructions
2528 //===----------------------------------------------------------------------===//
2530 /// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
2531 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2532 Intrinsic IntId64, Intrinsic IntId128> {
2533 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2534 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2535 [(set VR64:$dst, (IntId64 VR64:$src))]>;
2537 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2538 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2540 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2542 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2544 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2545 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2548 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2550 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2553 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
2556 /// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2557 multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2558 Intrinsic IntId64, Intrinsic IntId128> {
2559 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2561 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2562 [(set VR64:$dst, (IntId64 VR64:$src))]>;
2564 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2566 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2569 (bitconvert (memopv4i16 addr:$src))))]>;
2571 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2573 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2574 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2577 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2579 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2582 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2585 /// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2586 multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2587 Intrinsic IntId64, Intrinsic IntId128> {
2588 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2590 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2591 [(set VR64:$dst, (IntId64 VR64:$src))]>;
2593 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2595 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2598 (bitconvert (memopv2i32 addr:$src))))]>;
2600 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2602 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2603 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2606 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2608 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2611 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2614 defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2615 int_x86_ssse3_pabs_b,
2616 int_x86_ssse3_pabs_b_128>;
2617 defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2618 int_x86_ssse3_pabs_w,
2619 int_x86_ssse3_pabs_w_128>;
2620 defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2621 int_x86_ssse3_pabs_d,
2622 int_x86_ssse3_pabs_d_128>;
2624 /// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2625 let Constraints = "$src1 = $dst" in {
2626 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2627 Intrinsic IntId64, Intrinsic IntId128,
2628 bit Commutable = 0> {
2629 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2630 (ins VR64:$src1, VR64:$src2),
2631 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2632 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2633 let isCommutable = Commutable;
2635 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2636 (ins VR64:$src1, i64mem:$src2),
2637 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2639 (IntId64 VR64:$src1,
2640 (bitconvert (memopv8i8 addr:$src2))))]>;
2642 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2643 (ins VR128:$src1, VR128:$src2),
2644 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2645 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2647 let isCommutable = Commutable;
2649 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2650 (ins VR128:$src1, i128mem:$src2),
2651 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2653 (IntId128 VR128:$src1,
2654 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2658 /// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2659 let Constraints = "$src1 = $dst" in {
2660 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2661 Intrinsic IntId64, Intrinsic IntId128,
2662 bit Commutable = 0> {
2663 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2664 (ins VR64:$src1, VR64:$src2),
2665 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2666 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2667 let isCommutable = Commutable;
2669 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2670 (ins VR64:$src1, i64mem:$src2),
2671 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2673 (IntId64 VR64:$src1,
2674 (bitconvert (memopv4i16 addr:$src2))))]>;
2676 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2677 (ins VR128:$src1, VR128:$src2),
2678 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2679 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2681 let isCommutable = Commutable;
2683 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2684 (ins VR128:$src1, i128mem:$src2),
2685 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2687 (IntId128 VR128:$src1,
2688 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2692 /// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2693 let Constraints = "$src1 = $dst" in {
2694 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2695 Intrinsic IntId64, Intrinsic IntId128,
2696 bit Commutable = 0> {
2697 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2698 (ins VR64:$src1, VR64:$src2),
2699 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2700 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2701 let isCommutable = Commutable;
2703 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2704 (ins VR64:$src1, i64mem:$src2),
2705 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2707 (IntId64 VR64:$src1,
2708 (bitconvert (memopv2i32 addr:$src2))))]>;
2710 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2711 (ins VR128:$src1, VR128:$src2),
2712 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2713 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2715 let isCommutable = Commutable;
2717 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2718 (ins VR128:$src1, i128mem:$src2),
2719 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2721 (IntId128 VR128:$src1,
2722 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2726 defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2727 int_x86_ssse3_phadd_w,
2728 int_x86_ssse3_phadd_w_128>;
2729 defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2730 int_x86_ssse3_phadd_d,
2731 int_x86_ssse3_phadd_d_128>;
2732 defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2733 int_x86_ssse3_phadd_sw,
2734 int_x86_ssse3_phadd_sw_128>;
2735 defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2736 int_x86_ssse3_phsub_w,
2737 int_x86_ssse3_phsub_w_128>;
2738 defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2739 int_x86_ssse3_phsub_d,
2740 int_x86_ssse3_phsub_d_128>;
2741 defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2742 int_x86_ssse3_phsub_sw,
2743 int_x86_ssse3_phsub_sw_128>;
2744 defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2745 int_x86_ssse3_pmadd_ub_sw,
2746 int_x86_ssse3_pmadd_ub_sw_128>;
2747 defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2748 int_x86_ssse3_pmul_hr_sw,
2749 int_x86_ssse3_pmul_hr_sw_128, 1>;
2750 defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2751 int_x86_ssse3_pshuf_b,
2752 int_x86_ssse3_pshuf_b_128>;
2753 defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2754 int_x86_ssse3_psign_b,
2755 int_x86_ssse3_psign_b_128>;
2756 defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2757 int_x86_ssse3_psign_w,
2758 int_x86_ssse3_psign_w_128>;
2759 defm PSIGND : SS3I_binop_rm_int_32<0x09, "psignd",
2760 int_x86_ssse3_psign_d,
2761 int_x86_ssse3_psign_d_128>;
2763 let Constraints = "$src1 = $dst" in {
2764 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2765 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
2766 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2768 (int_x86_ssse3_palign_r
2769 VR64:$src1, VR64:$src2,
2771 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
2772 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
2773 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2775 (int_x86_ssse3_palign_r
2777 (bitconvert (memopv2i32 addr:$src2)),
2780 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2781 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
2782 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2784 (int_x86_ssse3_palign_r_128
2785 VR128:$src1, VR128:$src2,
2786 imm:$src3))]>, OpSize;
2787 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
2788 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
2789 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2791 (int_x86_ssse3_palign_r_128
2793 (bitconvert (memopv4i32 addr:$src2)),
2794 imm:$src3))]>, OpSize;
2797 def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2798 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2799 def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2800 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2802 //===----------------------------------------------------------------------===//
2803 // Non-Instruction Patterns
2804 //===----------------------------------------------------------------------===//
2806 // extload f32 -> f64. This matches load+fextend because we have a hack in
2807 // the isel (PreprocessForFPConvert) that can introduce loads after dag combine.
2808 // Since these loads aren't folded into the fextend, we have to match it
2810 let Predicates = [HasSSE2] in
2811 def : Pat<(fextend (loadf32 addr:$src)),
2812 (CVTSS2SDrm addr:$src)>;
2815 let Predicates = [HasSSE2] in {
2816 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2817 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2818 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2819 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2820 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2821 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2822 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2823 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2824 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2825 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2826 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2827 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2828 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2829 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2830 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2831 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2832 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2833 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2834 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2835 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2836 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2837 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2838 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2839 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2840 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2841 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2842 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2843 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2844 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2845 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2848 // Move scalar to XMM zero-extended
2849 // movd to XMM register zero-extends
2850 let AddedComplexity = 15 in {
2851 // Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
2852 def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
2853 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
2854 def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
2855 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE1]>;
2856 def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
2857 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
2858 def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
2859 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
2862 // Splat v2f64 / v2i64
2863 let AddedComplexity = 10 in {
2864 def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
2865 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2866 def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
2867 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2868 def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
2869 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2870 def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
2871 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2874 // Special unary SHUFPSrri case.
2875 def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
2876 (SHUFPSrri VR128:$src1, VR128:$src1,
2877 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2878 Requires<[HasSSE1]>;
2879 let AddedComplexity = 5 in
2880 def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
2881 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2882 Requires<[HasSSE2]>;
2883 // Special unary SHUFPDrri case.
2884 def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
2885 (SHUFPDrri VR128:$src1, VR128:$src1,
2886 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2887 Requires<[HasSSE2]>;
2888 // Special unary SHUFPDrri case.
2889 def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
2890 (SHUFPDrri VR128:$src1, VR128:$src1,
2891 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2892 Requires<[HasSSE2]>;
2893 // Unary v4f32 shuffle with PSHUF* in order to fold a load.
2894 def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
2895 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2896 Requires<[HasSSE2]>;
2898 // Special binary v4i32 shuffle cases with SHUFPS.
2899 def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
2900 (SHUFPSrri VR128:$src1, VR128:$src2,
2901 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2902 Requires<[HasSSE2]>;
2903 def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
2904 (SHUFPSrmi VR128:$src1, addr:$src2,
2905 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2906 Requires<[HasSSE2]>;
2907 // Special binary v2i64 shuffle cases using SHUFPDrri.
2908 def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
2909 (SHUFPDrri VR128:$src1, VR128:$src2,
2910 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2911 Requires<[HasSSE2]>;
2913 // vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2914 let AddedComplexity = 15 in {
2915 def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
2916 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2917 Requires<[OptForSpeed, HasSSE2]>;
2918 def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
2919 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2920 Requires<[OptForSpeed, HasSSE2]>;
2922 let AddedComplexity = 10 in {
2923 def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
2924 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2925 def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
2926 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2927 def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
2928 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2929 def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
2930 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2933 // vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2934 let AddedComplexity = 15 in {
2935 def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
2936 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2937 Requires<[OptForSpeed, HasSSE2]>;
2938 def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
2939 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2940 Requires<[OptForSpeed, HasSSE2]>;
2942 let AddedComplexity = 10 in {
2943 def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
2944 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2945 def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
2946 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2947 def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
2948 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2949 def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
2950 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2953 let AddedComplexity = 20 in {
2954 // vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2955 def : Pat<(v4i32 (movhp VR128:$src1, VR128:$src2)),
2956 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2958 // vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2959 def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
2960 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2962 // vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2963 def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
2964 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2965 def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
2966 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2969 let AddedComplexity = 20 in {
2970 // vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2971 // vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
2972 def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
2973 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
2974 def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
2975 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2976 def : Pat<(v4f32 (movhp VR128:$src1, (load addr:$src2))),
2977 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
2978 def : Pat<(v2f64 (movhp VR128:$src1, (load addr:$src2))),
2979 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2981 def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
2982 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2983 def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
2984 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2985 def : Pat<(v4i32 (movhp VR128:$src1, (load addr:$src2))),
2986 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
2987 def : Pat<(v2i64 (movhp VR128:$src1, (load addr:$src2))),
2988 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2991 // (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
2992 // (store (vector_shuffle (load addr), v2, <0, 1, 4, 5>), addr) using MOVHPS
2993 def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
2994 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
2995 def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
2996 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2997 def : Pat<(store (v4f32 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
2998 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
2999 def : Pat<(store (v2f64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
3000 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3002 def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3004 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
3005 def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3006 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3007 def : Pat<(store (v4i32 (movhp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3009 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
3010 def : Pat<(store (v2i64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
3011 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3014 let AddedComplexity = 15 in {
3015 // Setting the lowest element in the vector.
3016 def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
3017 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3018 def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
3019 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3021 // vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
3022 def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
3023 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3024 def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
3025 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3028 // Set lowest element and zero upper elements.
3029 let AddedComplexity = 15 in
3030 def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
3031 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
3032 def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
3033 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
3035 // Some special case pandn patterns.
3036 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3038 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3039 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3041 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3042 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3044 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3046 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3047 (memop addr:$src2))),
3048 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3049 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3050 (memop addr:$src2))),
3051 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3052 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3053 (memop addr:$src2))),
3054 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3056 // vector -> vector casts
3057 def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3058 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3059 def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3060 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
3061 def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3062 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3063 def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3064 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
3066 // Use movaps / movups for SSE integer load / store (one byte shorter).
3067 def : Pat<(alignedloadv4i32 addr:$src),
3068 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
3069 def : Pat<(loadv4i32 addr:$src),
3070 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
3071 def : Pat<(alignedloadv2i64 addr:$src),
3072 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3073 def : Pat<(loadv2i64 addr:$src),
3074 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3076 def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3077 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3078 def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3079 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3080 def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3081 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3082 def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3083 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3084 def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3085 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3086 def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3087 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3088 def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3089 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3090 def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3091 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3093 //===----------------------------------------------------------------------===//
3094 // SSE4.1 Instructions
3095 //===----------------------------------------------------------------------===//
3097 multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
3100 Intrinsic V2F64Int> {
3101 // Intrinsic operation, reg.
3102 // Vector intrinsic operation, reg
3103 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
3104 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
3105 !strconcat(OpcodeStr,
3106 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3107 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3110 // Vector intrinsic operation, mem
3111 def PSm_Int : SS4AIi8<opcps, MRMSrcMem,
3112 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
3113 !strconcat(OpcodeStr,
3114 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3116 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
3119 // Vector intrinsic operation, reg
3120 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
3121 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
3122 !strconcat(OpcodeStr,
3123 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3124 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3127 // Vector intrinsic operation, mem
3128 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
3129 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
3130 !strconcat(OpcodeStr,
3131 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3133 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
3137 let Constraints = "$src1 = $dst" in {
3138 multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3142 // Intrinsic operation, reg.
3143 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
3145 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3146 !strconcat(OpcodeStr,
3147 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3149 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3152 // Intrinsic operation, mem.
3153 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3155 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
3156 !strconcat(OpcodeStr,
3157 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3159 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3162 // Intrinsic operation, reg.
3163 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
3165 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3166 !strconcat(OpcodeStr,
3167 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3169 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3172 // Intrinsic operation, mem.
3173 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
3175 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3176 !strconcat(OpcodeStr,
3177 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3179 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3184 // FP round - roundss, roundps, roundsd, roundpd
3185 defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3186 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3187 defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3188 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
3190 // SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3191 multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3192 Intrinsic IntId128> {
3193 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3195 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3196 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3197 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3199 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3202 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3205 defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3206 int_x86_sse41_phminposuw>;
3208 /// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
3209 let Constraints = "$src1 = $dst" in {
3210 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3211 Intrinsic IntId128, bit Commutable = 0> {
3212 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3213 (ins VR128:$src1, VR128:$src2),
3214 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3215 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3217 let isCommutable = Commutable;
3219 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3220 (ins VR128:$src1, i128mem:$src2),
3221 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3223 (IntId128 VR128:$src1,
3224 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3228 defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3229 int_x86_sse41_pcmpeqq, 1>;
3230 defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3231 int_x86_sse41_packusdw, 0>;
3232 defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3233 int_x86_sse41_pminsb, 1>;
3234 defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3235 int_x86_sse41_pminsd, 1>;
3236 defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3237 int_x86_sse41_pminud, 1>;
3238 defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3239 int_x86_sse41_pminuw, 1>;
3240 defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3241 int_x86_sse41_pmaxsb, 1>;
3242 defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3243 int_x86_sse41_pmaxsd, 1>;
3244 defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3245 int_x86_sse41_pmaxud, 1>;
3246 defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3247 int_x86_sse41_pmaxuw, 1>;
3249 defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3251 def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3252 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3253 def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3254 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3256 /// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
3257 let Constraints = "$src1 = $dst" in {
3258 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3259 SDNode OpNode, Intrinsic IntId128,
3260 bit Commutable = 0> {
3261 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3262 (ins VR128:$src1, VR128:$src2),
3263 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3264 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3265 VR128:$src2))]>, OpSize {
3266 let isCommutable = Commutable;
3268 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3269 (ins VR128:$src1, VR128:$src2),
3270 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3271 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3273 let isCommutable = Commutable;
3275 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3276 (ins VR128:$src1, i128mem:$src2),
3277 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3279 (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize;
3280 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3281 (ins VR128:$src1, i128mem:$src2),
3282 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3284 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
3288 defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
3289 int_x86_sse41_pmulld, 1>;
3291 /// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
3292 let Constraints = "$src1 = $dst" in {
3293 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3294 Intrinsic IntId128, bit Commutable = 0> {
3295 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3296 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3297 !strconcat(OpcodeStr,
3298 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3300 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3302 let isCommutable = Commutable;
3304 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3305 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3306 !strconcat(OpcodeStr,
3307 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3309 (IntId128 VR128:$src1,
3310 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3315 defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3316 int_x86_sse41_blendps, 0>;
3317 defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3318 int_x86_sse41_blendpd, 0>;
3319 defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3320 int_x86_sse41_pblendw, 0>;
3321 defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3322 int_x86_sse41_dpps, 1>;
3323 defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3324 int_x86_sse41_dppd, 1>;
3325 defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
3326 int_x86_sse41_mpsadbw, 1>;
3329 /// SS41I_ternary_int - SSE 4.1 ternary operator
3330 let Uses = [XMM0], Constraints = "$src1 = $dst" in {
3331 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3332 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3333 (ins VR128:$src1, VR128:$src2),
3334 !strconcat(OpcodeStr,
3335 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3336 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3339 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3340 (ins VR128:$src1, i128mem:$src2),
3341 !strconcat(OpcodeStr,
3342 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3345 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3349 defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3350 defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3351 defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3354 multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3355 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3356 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3357 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3359 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3360 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3362 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3366 defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3367 defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3368 defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3369 defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3370 defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3371 defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3373 // Common patterns involving scalar load.
3374 def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3375 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3376 def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3377 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3379 def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3380 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3381 def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3382 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3384 def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3385 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3386 def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3387 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3389 def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3390 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3391 def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3392 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3394 def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3395 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3396 def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3397 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3399 def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3400 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3401 def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3402 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3405 multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3406 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3407 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3408 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3410 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3411 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3413 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3417 defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3418 defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3419 defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3420 defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3422 // Common patterns involving scalar load
3423 def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
3424 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
3425 def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
3426 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
3428 def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
3429 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
3430 def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
3431 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
3434 multiclass SS41I_binop_rm_int2<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 // Expecting a i16 load any extended to i32 value.
3440 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3441 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3442 [(set VR128:$dst, (IntId (bitconvert
3443 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3447 defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
3448 defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovsxbq", int_x86_sse41_pmovzxbq>;
3450 // Common patterns involving scalar load
3451 def : Pat<(int_x86_sse41_pmovsxbq
3452 (bitconvert (v4i32 (X86vzmovl
3453 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
3454 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
3456 def : Pat<(int_x86_sse41_pmovzxbq
3457 (bitconvert (v4i32 (X86vzmovl
3458 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
3459 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
3462 /// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3463 multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
3464 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
3465 (ins VR128:$src1, i32i8imm:$src2),
3466 !strconcat(OpcodeStr,
3467 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3468 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3470 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3471 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
3472 !strconcat(OpcodeStr,
3473 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3476 // There's an AssertZext in the way of writing the store pattern
3477 // (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3480 defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
3483 /// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3484 multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
3485 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3486 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
3487 !strconcat(OpcodeStr,
3488 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3491 // There's an AssertZext in the way of writing the store pattern
3492 // (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3495 defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3498 /// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3499 multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
3500 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
3501 (ins VR128:$src1, i32i8imm:$src2),
3502 !strconcat(OpcodeStr,
3503 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3505 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
3506 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3507 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
3508 !strconcat(OpcodeStr,
3509 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3510 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3511 addr:$dst)]>, OpSize;
3514 defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
3517 /// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3519 multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
3520 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
3521 (ins VR128:$src1, i32i8imm:$src2),
3522 !strconcat(OpcodeStr,
3523 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3525 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
3527 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3528 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
3529 !strconcat(OpcodeStr,
3530 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3531 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
3532 addr:$dst)]>, OpSize;
3535 defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
3537 // Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3538 def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3541 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3542 Requires<[HasSSE41]>;
3544 let Constraints = "$src1 = $dst" in {
3545 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
3546 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3547 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
3548 !strconcat(OpcodeStr,
3549 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3551 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
3552 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3553 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3554 !strconcat(OpcodeStr,
3555 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3557 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3558 imm:$src3))]>, OpSize;
3562 defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3564 let Constraints = "$src1 = $dst" in {
3565 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
3566 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3567 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
3568 !strconcat(OpcodeStr,
3569 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3571 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3573 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3574 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3575 !strconcat(OpcodeStr,
3576 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3578 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3579 imm:$src3)))]>, OpSize;
3583 defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3585 let Constraints = "$src1 = $dst" in {
3586 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
3587 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3588 (ins VR128:$src1, FR32:$src2, i32i8imm:$src3),
3589 !strconcat(OpcodeStr,
3590 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3592 (X86insrtps VR128:$src1, FR32:$src2, imm:$src3))]>, OpSize;
3593 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3594 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3595 !strconcat(OpcodeStr,
3596 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3598 (X86insrtps VR128:$src1, (loadf32 addr:$src2),
3599 imm:$src3))]>, OpSize;
3603 defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
3605 let Defs = [EFLAGS] in {
3606 def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
3607 "ptest \t{$src2, $src1|$src1, $src2}", []>, OpSize;
3608 def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
3609 "ptest \t{$src2, $src1|$src1, $src2}", []>, OpSize;
3612 def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3613 "movntdqa\t{$src, $dst|$dst, $src}",
3614 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>;
3616 /// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3617 let Constraints = "$src1 = $dst" in {
3618 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3619 Intrinsic IntId128, bit Commutable = 0> {
3620 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3621 (ins VR128:$src1, VR128:$src2),
3622 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3623 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3625 let isCommutable = Commutable;
3627 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3628 (ins VR128:$src1, i128mem:$src2),
3629 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3631 (IntId128 VR128:$src1,
3632 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3636 defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
3638 def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3639 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3640 def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3641 (PCMPGTQrm VR128:$src1, addr:$src2)>;