1 //====- X86InstrSSE.td - Describe the X86 Instruction Set --*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the X86 SSE instruction set, defining the instructions,
11 // and properties of the instructions which are needed for code generation,
12 // machine code emission, and analysis.
14 //===----------------------------------------------------------------------===//
17 //===----------------------------------------------------------------------===//
18 // SSE specific DAG Nodes.
19 //===----------------------------------------------------------------------===//
21 def SDTX86FPShiftOp : SDTypeProfile<1, 2, [ SDTCisSameAs<0, 1>,
22 SDTCisFP<0>, SDTCisInt<2> ]>;
23 def SDTX86VFCMP : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<1, 2>,
24 SDTCisFP<1>, SDTCisVT<3, i8>]>;
26 def X86fmin : SDNode<"X86ISD::FMIN", SDTFPBinOp>;
27 def X86fmax : SDNode<"X86ISD::FMAX", SDTFPBinOp>;
28 def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
29 [SDNPCommutative, SDNPAssociative]>;
30 def X86for : SDNode<"X86ISD::FOR", SDTFPBinOp,
31 [SDNPCommutative, SDNPAssociative]>;
32 def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
33 [SDNPCommutative, SDNPAssociative]>;
34 def X86frsqrt : SDNode<"X86ISD::FRSQRT", SDTFPUnaryOp>;
35 def X86frcp : SDNode<"X86ISD::FRCP", SDTFPUnaryOp>;
36 def X86fsrl : SDNode<"X86ISD::FSRL", SDTX86FPShiftOp>;
37 def X86comi : SDNode<"X86ISD::COMI", SDTX86CmpTest>;
38 def X86ucomi : SDNode<"X86ISD::UCOMI", SDTX86CmpTest>;
39 def X86pshufb : SDNode<"X86ISD::PSHUFB",
40 SDTypeProfile<1, 2, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
42 def X86pextrb : SDNode<"X86ISD::PEXTRB",
43 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
44 def X86pextrw : SDNode<"X86ISD::PEXTRW",
45 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
46 def X86pinsrb : SDNode<"X86ISD::PINSRB",
47 SDTypeProfile<1, 3, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
48 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
49 def X86pinsrw : SDNode<"X86ISD::PINSRW",
50 SDTypeProfile<1, 3, [SDTCisVT<0, v8i16>, SDTCisSameAs<0,1>,
51 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
52 def X86insrtps : SDNode<"X86ISD::INSERTPS",
53 SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, SDTCisSameAs<0,1>,
54 SDTCisVT<2, v4f32>, SDTCisPtrTy<3>]>>;
55 def X86vzmovl : SDNode<"X86ISD::VZEXT_MOVL",
56 SDTypeProfile<1, 1, [SDTCisSameAs<0,1>]>>;
57 def X86vzload : SDNode<"X86ISD::VZEXT_LOAD", SDTLoad,
58 [SDNPHasChain, SDNPMayLoad]>;
59 def X86vshl : SDNode<"X86ISD::VSHL", SDTIntShiftOp>;
60 def X86vshr : SDNode<"X86ISD::VSRL", SDTIntShiftOp>;
61 def X86cmpps : SDNode<"X86ISD::CMPPS", SDTX86VFCMP>;
62 def X86cmppd : SDNode<"X86ISD::CMPPD", SDTX86VFCMP>;
63 def X86pcmpeqb : SDNode<"X86ISD::PCMPEQB", SDTIntBinOp, [SDNPCommutative]>;
64 def X86pcmpeqw : SDNode<"X86ISD::PCMPEQW", SDTIntBinOp, [SDNPCommutative]>;
65 def X86pcmpeqd : SDNode<"X86ISD::PCMPEQD", SDTIntBinOp, [SDNPCommutative]>;
66 def X86pcmpeqq : SDNode<"X86ISD::PCMPEQQ", SDTIntBinOp, [SDNPCommutative]>;
67 def X86pcmpgtb : SDNode<"X86ISD::PCMPGTB", SDTIntBinOp>;
68 def X86pcmpgtw : SDNode<"X86ISD::PCMPGTW", SDTIntBinOp>;
69 def X86pcmpgtd : SDNode<"X86ISD::PCMPGTD", SDTIntBinOp>;
70 def X86pcmpgtq : SDNode<"X86ISD::PCMPGTQ", SDTIntBinOp>;
72 def SDTX86CmpPTest : SDTypeProfile<0, 2, [SDTCisVT<0, v4f32>, SDTCisVT<1, v4f32>]>;
73 def X86ptest : SDNode<"X86ISD::PTEST", SDTX86CmpPTest>;
75 //===----------------------------------------------------------------------===//
76 // SSE Complex Patterns
77 //===----------------------------------------------------------------------===//
79 // These are 'extloads' from a scalar to the low element of a vector, zeroing
80 // the top elements. These are used for the SSE 'ss' and 'sd' instruction
82 def sse_load_f32 : ComplexPattern<v4f32, 5, "SelectScalarSSELoad", [],
83 [SDNPHasChain, SDNPMayLoad]>;
84 def sse_load_f64 : ComplexPattern<v2f64, 5, "SelectScalarSSELoad", [],
85 [SDNPHasChain, SDNPMayLoad]>;
87 def ssmem : Operand<v4f32> {
88 let PrintMethod = "printf32mem";
89 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
91 def sdmem : Operand<v2f64> {
92 let PrintMethod = "printf64mem";
93 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
96 //===----------------------------------------------------------------------===//
97 // SSE pattern fragments
98 //===----------------------------------------------------------------------===//
100 def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
101 def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
102 def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
103 def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
105 // Like 'store', but always requires vector alignment.
106 def alignedstore : PatFrag<(ops node:$val, node:$ptr),
107 (store node:$val, node:$ptr), [{
108 return cast<StoreSDNode>(N)->getAlignment() >= 16;
111 // Like 'load', but always requires vector alignment.
112 def alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
113 return cast<LoadSDNode>(N)->getAlignment() >= 16;
116 def alignedloadfsf32 : PatFrag<(ops node:$ptr), (f32 (alignedload node:$ptr))>;
117 def alignedloadfsf64 : PatFrag<(ops node:$ptr), (f64 (alignedload node:$ptr))>;
118 def alignedloadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (alignedload node:$ptr))>;
119 def alignedloadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (alignedload node:$ptr))>;
120 def alignedloadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (alignedload node:$ptr))>;
121 def alignedloadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (alignedload node:$ptr))>;
123 // Like 'load', but uses special alignment checks suitable for use in
124 // memory operands in most SSE instructions, which are required to
125 // be naturally aligned on some targets but not on others.
126 // FIXME: Actually implement support for targets that don't require the
127 // alignment. This probably wants a subtarget predicate.
128 def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{
129 return cast<LoadSDNode>(N)->getAlignment() >= 16;
132 def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
133 def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
134 def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
135 def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
136 def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
137 def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
138 def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
140 // SSSE3 uses MMX registers for some instructions. They aren't aligned on a
142 // FIXME: 8 byte alignment for mmx reads is not required
143 def memop64 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
144 return cast<LoadSDNode>(N)->getAlignment() >= 8;
147 def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
148 def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
149 def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
150 def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
152 def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
153 def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
154 def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
155 def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
156 def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
157 def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
159 def vzmovl_v2i64 : PatFrag<(ops node:$src),
160 (bitconvert (v2i64 (X86vzmovl
161 (v2i64 (scalar_to_vector (loadi64 node:$src))))))>;
162 def vzmovl_v4i32 : PatFrag<(ops node:$src),
163 (bitconvert (v4i32 (X86vzmovl
164 (v4i32 (scalar_to_vector (loadi32 node:$src))))))>;
166 def vzload_v2i64 : PatFrag<(ops node:$src),
167 (bitconvert (v2i64 (X86vzload node:$src)))>;
170 def fp32imm0 : PatLeaf<(f32 fpimm), [{
171 return N->isExactlyValue(+0.0);
174 def PSxLDQ_imm : SDNodeXForm<imm, [{
175 // Transformation function: imm >> 3
176 return getI32Imm(N->getZExtValue() >> 3);
179 // SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
181 def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
182 return getI8Imm(X86::getShuffleSHUFImmediate(N));
185 // SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
187 def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{
188 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
191 // SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
193 def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{
194 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
197 def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
198 (vector_shuffle node:$lhs, node:$rhs), [{
199 ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
200 return SVOp->isSplat() && SVOp->getSplatIndex() == 0;
203 def movddup : PatFrag<(ops node:$lhs, node:$rhs),
204 (vector_shuffle node:$lhs, node:$rhs), [{
205 return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N));
208 def movhlps : PatFrag<(ops node:$lhs, node:$rhs),
209 (vector_shuffle node:$lhs, node:$rhs), [{
210 return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N));
213 def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs),
214 (vector_shuffle node:$lhs, node:$rhs), [{
215 return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
218 def movhp : PatFrag<(ops node:$lhs, node:$rhs),
219 (vector_shuffle node:$lhs, node:$rhs), [{
220 return X86::isMOVHPMask(cast<ShuffleVectorSDNode>(N));
223 def movlp : PatFrag<(ops node:$lhs, node:$rhs),
224 (vector_shuffle node:$lhs, node:$rhs), [{
225 return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N));
228 def movl : PatFrag<(ops node:$lhs, node:$rhs),
229 (vector_shuffle node:$lhs, node:$rhs), [{
230 return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N));
233 def movshdup : PatFrag<(ops node:$lhs, node:$rhs),
234 (vector_shuffle node:$lhs, node:$rhs), [{
235 return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N));
238 def movsldup : PatFrag<(ops node:$lhs, node:$rhs),
239 (vector_shuffle node:$lhs, node:$rhs), [{
240 return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N));
243 def unpckl : PatFrag<(ops node:$lhs, node:$rhs),
244 (vector_shuffle node:$lhs, node:$rhs), [{
245 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
248 def unpckh : PatFrag<(ops node:$lhs, node:$rhs),
249 (vector_shuffle node:$lhs, node:$rhs), [{
250 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
253 def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
254 (vector_shuffle node:$lhs, node:$rhs), [{
255 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
258 def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
259 (vector_shuffle node:$lhs, node:$rhs), [{
260 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
263 def pshufd : PatFrag<(ops node:$lhs, node:$rhs),
264 (vector_shuffle node:$lhs, node:$rhs), [{
265 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
266 }], SHUFFLE_get_shuf_imm>;
268 def shufp : PatFrag<(ops node:$lhs, node:$rhs),
269 (vector_shuffle node:$lhs, node:$rhs), [{
270 return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N));
271 }], SHUFFLE_get_shuf_imm>;
273 def pshufhw : PatFrag<(ops node:$lhs, node:$rhs),
274 (vector_shuffle node:$lhs, node:$rhs), [{
275 return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N));
276 }], SHUFFLE_get_pshufhw_imm>;
278 def pshuflw : PatFrag<(ops node:$lhs, node:$rhs),
279 (vector_shuffle node:$lhs, node:$rhs), [{
280 return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N));
281 }], SHUFFLE_get_pshuflw_imm>;
283 //===----------------------------------------------------------------------===//
284 // SSE scalar FP Instructions
285 //===----------------------------------------------------------------------===//
287 // CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
288 // scheduler into a branch sequence.
289 // These are expanded by the scheduler.
290 let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
291 def CMOV_FR32 : I<0, Pseudo,
292 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
293 "#CMOV_FR32 PSEUDO!",
294 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
296 def CMOV_FR64 : I<0, Pseudo,
297 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
298 "#CMOV_FR64 PSEUDO!",
299 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
301 def CMOV_V4F32 : I<0, Pseudo,
302 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
303 "#CMOV_V4F32 PSEUDO!",
305 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
307 def CMOV_V2F64 : I<0, Pseudo,
308 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
309 "#CMOV_V2F64 PSEUDO!",
311 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
313 def CMOV_V2I64 : I<0, Pseudo,
314 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
315 "#CMOV_V2I64 PSEUDO!",
317 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
321 //===----------------------------------------------------------------------===//
323 //===----------------------------------------------------------------------===//
326 let neverHasSideEffects = 1 in
327 def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
328 "movss\t{$src, $dst|$dst, $src}", []>;
329 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
330 def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
331 "movss\t{$src, $dst|$dst, $src}",
332 [(set FR32:$dst, (loadf32 addr:$src))]>;
333 def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
334 "movss\t{$src, $dst|$dst, $src}",
335 [(store FR32:$src, addr:$dst)]>;
337 // Conversion instructions
338 def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
339 "cvttss2si\t{$src, $dst|$dst, $src}",
340 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
341 def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
342 "cvttss2si\t{$src, $dst|$dst, $src}",
343 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
344 def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
345 "cvtsi2ss\t{$src, $dst|$dst, $src}",
346 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
347 def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
348 "cvtsi2ss\t{$src, $dst|$dst, $src}",
349 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
351 // Match intrinsics which expect XMM operand(s).
352 def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
353 "cvtss2si\t{$src, $dst|$dst, $src}",
354 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
355 def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
356 "cvtss2si\t{$src, $dst|$dst, $src}",
357 [(set GR32:$dst, (int_x86_sse_cvtss2si
358 (load addr:$src)))]>;
360 // Match intrinisics which expect MM and XMM operand(s).
361 def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
362 "cvtps2pi\t{$src, $dst|$dst, $src}",
363 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
364 def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
365 "cvtps2pi\t{$src, $dst|$dst, $src}",
366 [(set VR64:$dst, (int_x86_sse_cvtps2pi
367 (load addr:$src)))]>;
368 def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
369 "cvttps2pi\t{$src, $dst|$dst, $src}",
370 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
371 def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
372 "cvttps2pi\t{$src, $dst|$dst, $src}",
373 [(set VR64:$dst, (int_x86_sse_cvttps2pi
374 (load addr:$src)))]>;
375 let Constraints = "$src1 = $dst" in {
376 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
377 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
378 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
379 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
381 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
382 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
383 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
384 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
385 (load addr:$src2)))]>;
388 // Aliases for intrinsics
389 def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
390 "cvttss2si\t{$src, $dst|$dst, $src}",
392 (int_x86_sse_cvttss2si VR128:$src))]>;
393 def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
394 "cvttss2si\t{$src, $dst|$dst, $src}",
396 (int_x86_sse_cvttss2si(load addr:$src)))]>;
398 let Constraints = "$src1 = $dst" in {
399 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
400 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
401 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
402 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
404 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
405 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
406 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
407 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
408 (loadi32 addr:$src2)))]>;
411 // Comparison instructions
412 let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
413 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
414 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
415 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
417 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
418 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
419 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
422 let Defs = [EFLAGS] in {
423 def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
424 "ucomiss\t{$src2, $src1|$src1, $src2}",
425 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
426 def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
427 "ucomiss\t{$src2, $src1|$src1, $src2}",
428 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
432 // Aliases to match intrinsics which expect XMM operand(s).
433 let Constraints = "$src1 = $dst" in {
434 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
435 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
437 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
438 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
439 VR128:$src, imm:$cc))]>;
440 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
441 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src,
443 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
444 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
445 (load addr:$src), imm:$cc))]>;
448 let Defs = [EFLAGS] in {
449 def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
450 "ucomiss\t{$src2, $src1|$src1, $src2}",
451 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
453 def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
454 "ucomiss\t{$src2, $src1|$src1, $src2}",
455 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
458 def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
459 "comiss\t{$src2, $src1|$src1, $src2}",
460 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
462 def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
463 "comiss\t{$src2, $src1|$src1, $src2}",
464 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
468 // Aliases of packed SSE1 instructions for scalar use. These all have names
469 // that start with 'Fs'.
471 // Alias instructions that map fld0 to pxor for sse.
472 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
473 def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
474 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
475 Requires<[HasSSE1]>, TB, OpSize;
477 // Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
479 let neverHasSideEffects = 1 in
480 def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
481 "movaps\t{$src, $dst|$dst, $src}", []>;
483 // Alias instruction to load FR32 from f128mem using movaps. Upper bits are
485 let canFoldAsLoad = 1 in
486 def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
487 "movaps\t{$src, $dst|$dst, $src}",
488 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
490 // Alias bitwise logical operations using SSE logical ops on packed FP values.
491 let Constraints = "$src1 = $dst" in {
492 let isCommutable = 1 in {
493 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
494 (ins FR32:$src1, FR32:$src2),
495 "andps\t{$src2, $dst|$dst, $src2}",
496 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
497 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
498 (ins FR32:$src1, FR32:$src2),
499 "orps\t{$src2, $dst|$dst, $src2}",
500 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
501 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
502 (ins FR32:$src1, FR32:$src2),
503 "xorps\t{$src2, $dst|$dst, $src2}",
504 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
507 def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
508 (ins FR32:$src1, f128mem:$src2),
509 "andps\t{$src2, $dst|$dst, $src2}",
510 [(set FR32:$dst, (X86fand FR32:$src1,
511 (memopfsf32 addr:$src2)))]>;
512 def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
513 (ins FR32:$src1, f128mem:$src2),
514 "orps\t{$src2, $dst|$dst, $src2}",
515 [(set FR32:$dst, (X86for FR32:$src1,
516 (memopfsf32 addr:$src2)))]>;
517 def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
518 (ins FR32:$src1, f128mem:$src2),
519 "xorps\t{$src2, $dst|$dst, $src2}",
520 [(set FR32:$dst, (X86fxor FR32:$src1,
521 (memopfsf32 addr:$src2)))]>;
523 let neverHasSideEffects = 1 in {
524 def FsANDNPSrr : PSI<0x55, MRMSrcReg,
525 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
526 "andnps\t{$src2, $dst|$dst, $src2}", []>;
528 def FsANDNPSrm : PSI<0x55, MRMSrcMem,
529 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
530 "andnps\t{$src2, $dst|$dst, $src2}", []>;
534 /// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
536 /// In addition, we also have a special variant of the scalar form here to
537 /// represent the associated intrinsic operation. This form is unlike the
538 /// plain scalar form, in that it takes an entire vector (instead of a scalar)
539 /// and leaves the top elements unmodified (therefore these cannot be commuted).
541 /// These three forms can each be reg+reg or reg+mem, so there are a total of
542 /// six "instructions".
544 let Constraints = "$src1 = $dst" in {
545 multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
546 SDNode OpNode, Intrinsic F32Int,
547 bit Commutable = 0> {
548 // Scalar operation, reg+reg.
549 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
550 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
551 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
552 let isCommutable = Commutable;
555 // Scalar operation, reg+mem.
556 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
557 (ins FR32:$src1, f32mem:$src2),
558 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
559 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
561 // Vector operation, reg+reg.
562 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
563 (ins VR128:$src1, VR128:$src2),
564 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
565 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
566 let isCommutable = Commutable;
569 // Vector operation, reg+mem.
570 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
571 (ins VR128:$src1, f128mem:$src2),
572 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
573 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
575 // Intrinsic operation, reg+reg.
576 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
577 (ins VR128:$src1, VR128:$src2),
578 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
579 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
581 // Intrinsic operation, reg+mem.
582 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
583 (ins VR128:$src1, ssmem:$src2),
584 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
585 [(set VR128:$dst, (F32Int VR128:$src1,
586 sse_load_f32:$src2))]>;
590 // Arithmetic instructions
591 defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
592 defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
593 defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
594 defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
596 /// sse1_fp_binop_rm - Other SSE1 binops
598 /// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
599 /// instructions for a full-vector intrinsic form. Operations that map
600 /// onto C operators don't use this form since they just use the plain
601 /// vector form instead of having a separate vector intrinsic form.
603 /// This provides a total of eight "instructions".
605 let Constraints = "$src1 = $dst" in {
606 multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
610 bit Commutable = 0> {
612 // Scalar operation, reg+reg.
613 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
614 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
615 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
616 let isCommutable = Commutable;
619 // Scalar operation, reg+mem.
620 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
621 (ins FR32:$src1, f32mem:$src2),
622 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
623 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
625 // Vector operation, reg+reg.
626 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
627 (ins VR128:$src1, VR128:$src2),
628 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
629 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
630 let isCommutable = Commutable;
633 // Vector operation, reg+mem.
634 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
635 (ins VR128:$src1, f128mem:$src2),
636 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
637 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
639 // Intrinsic operation, reg+reg.
640 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
641 (ins VR128:$src1, VR128:$src2),
642 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
643 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
644 let isCommutable = Commutable;
647 // Intrinsic operation, reg+mem.
648 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
649 (ins VR128:$src1, ssmem:$src2),
650 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
651 [(set VR128:$dst, (F32Int VR128:$src1,
652 sse_load_f32:$src2))]>;
654 // Vector intrinsic operation, reg+reg.
655 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
656 (ins VR128:$src1, VR128:$src2),
657 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
658 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
659 let isCommutable = Commutable;
662 // Vector intrinsic operation, reg+mem.
663 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
664 (ins VR128:$src1, f128mem:$src2),
665 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
666 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
670 defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
671 int_x86_sse_max_ss, int_x86_sse_max_ps>;
672 defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
673 int_x86_sse_min_ss, int_x86_sse_min_ps>;
675 //===----------------------------------------------------------------------===//
676 // SSE packed FP Instructions
679 let neverHasSideEffects = 1 in
680 def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
681 "movaps\t{$src, $dst|$dst, $src}", []>;
682 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
683 def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
684 "movaps\t{$src, $dst|$dst, $src}",
685 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
687 def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
688 "movaps\t{$src, $dst|$dst, $src}",
689 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
691 let neverHasSideEffects = 1 in
692 def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
693 "movups\t{$src, $dst|$dst, $src}", []>;
694 let canFoldAsLoad = 1 in
695 def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
696 "movups\t{$src, $dst|$dst, $src}",
697 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
698 def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
699 "movups\t{$src, $dst|$dst, $src}",
700 [(store (v4f32 VR128:$src), addr:$dst)]>;
702 // Intrinsic forms of MOVUPS load and store
703 let canFoldAsLoad = 1 in
704 def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
705 "movups\t{$src, $dst|$dst, $src}",
706 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
707 def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
708 "movups\t{$src, $dst|$dst, $src}",
709 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
711 let Constraints = "$src1 = $dst" in {
712 let AddedComplexity = 20 in {
713 def MOVLPSrm : PSI<0x12, MRMSrcMem,
714 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
715 "movlps\t{$src2, $dst|$dst, $src2}",
718 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
719 def MOVHPSrm : PSI<0x16, MRMSrcMem,
720 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
721 "movhps\t{$src2, $dst|$dst, $src2}",
724 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
726 } // Constraints = "$src1 = $dst"
729 def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
730 "movlps\t{$src, $dst|$dst, $src}",
731 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
732 (iPTR 0))), addr:$dst)]>;
734 // v2f64 extract element 1 is always custom lowered to unpack high to low
735 // and extract element 0 so the non-store version isn't too horrible.
736 def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
737 "movhps\t{$src, $dst|$dst, $src}",
738 [(store (f64 (vector_extract
739 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
740 (undef)), (iPTR 0))), addr:$dst)]>;
742 let Constraints = "$src1 = $dst" in {
743 let AddedComplexity = 20 in {
744 def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
745 (ins VR128:$src1, VR128:$src2),
746 "movlhps\t{$src2, $dst|$dst, $src2}",
748 (v4f32 (movhp VR128:$src1, VR128:$src2)))]>;
750 def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
751 (ins VR128:$src1, VR128:$src2),
752 "movhlps\t{$src2, $dst|$dst, $src2}",
754 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
756 } // Constraints = "$src1 = $dst"
758 let AddedComplexity = 20 in {
759 def : Pat<(v4f32 (movddup VR128:$src, (undef))),
760 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
761 def : Pat<(v2i64 (movddup VR128:$src, (undef))),
762 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
769 /// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
771 /// In addition, we also have a special variant of the scalar form here to
772 /// represent the associated intrinsic operation. This form is unlike the
773 /// plain scalar form, in that it takes an entire vector (instead of a
774 /// scalar) and leaves the top elements undefined.
776 /// And, we have a special variant form for a full-vector intrinsic form.
778 /// These four forms can each have a reg or a mem operand, so there are a
779 /// total of eight "instructions".
781 multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
785 bit Commutable = 0> {
786 // Scalar operation, reg.
787 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
788 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
789 [(set FR32:$dst, (OpNode FR32:$src))]> {
790 let isCommutable = Commutable;
793 // Scalar operation, mem.
794 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
795 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
796 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
798 // Vector operation, reg.
799 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
800 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
801 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
802 let isCommutable = Commutable;
805 // Vector operation, mem.
806 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
807 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
808 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
810 // Intrinsic operation, reg.
811 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
812 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
813 [(set VR128:$dst, (F32Int VR128:$src))]> {
814 let isCommutable = Commutable;
817 // Intrinsic operation, mem.
818 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
819 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
820 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
822 // Vector intrinsic operation, reg
823 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
824 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
825 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
826 let isCommutable = Commutable;
829 // Vector intrinsic operation, mem
830 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
831 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
832 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
836 defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
837 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
839 // Reciprocal approximations. Note that these typically require refinement
840 // in order to obtain suitable precision.
841 defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
842 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
843 defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
844 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
847 let Constraints = "$src1 = $dst" in {
848 let isCommutable = 1 in {
849 def ANDPSrr : PSI<0x54, MRMSrcReg,
850 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
851 "andps\t{$src2, $dst|$dst, $src2}",
852 [(set VR128:$dst, (v2i64
853 (and VR128:$src1, VR128:$src2)))]>;
854 def ORPSrr : PSI<0x56, MRMSrcReg,
855 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
856 "orps\t{$src2, $dst|$dst, $src2}",
857 [(set VR128:$dst, (v2i64
858 (or VR128:$src1, VR128:$src2)))]>;
859 def XORPSrr : PSI<0x57, MRMSrcReg,
860 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
861 "xorps\t{$src2, $dst|$dst, $src2}",
862 [(set VR128:$dst, (v2i64
863 (xor VR128:$src1, VR128:$src2)))]>;
866 def ANDPSrm : PSI<0x54, MRMSrcMem,
867 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
868 "andps\t{$src2, $dst|$dst, $src2}",
869 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
870 (memopv2i64 addr:$src2)))]>;
871 def ORPSrm : PSI<0x56, MRMSrcMem,
872 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
873 "orps\t{$src2, $dst|$dst, $src2}",
874 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
875 (memopv2i64 addr:$src2)))]>;
876 def XORPSrm : PSI<0x57, MRMSrcMem,
877 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
878 "xorps\t{$src2, $dst|$dst, $src2}",
879 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
880 (memopv2i64 addr:$src2)))]>;
881 def ANDNPSrr : PSI<0x55, MRMSrcReg,
882 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
883 "andnps\t{$src2, $dst|$dst, $src2}",
885 (v2i64 (and (xor VR128:$src1,
886 (bc_v2i64 (v4i32 immAllOnesV))),
888 def ANDNPSrm : PSI<0x55, MRMSrcMem,
889 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
890 "andnps\t{$src2, $dst|$dst, $src2}",
892 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
893 (bc_v2i64 (v4i32 immAllOnesV))),
894 (memopv2i64 addr:$src2))))]>;
897 let Constraints = "$src1 = $dst" in {
898 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
899 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
900 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
901 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
902 VR128:$src, imm:$cc))]>;
903 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
904 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
905 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
906 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
907 (memop addr:$src), imm:$cc))]>;
909 def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
910 (CMPPSrri VR128:$src1, VR128:$src2, imm:$cc)>;
911 def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
912 (CMPPSrmi VR128:$src1, addr:$src2, imm:$cc)>;
914 // Shuffle and unpack instructions
915 let Constraints = "$src1 = $dst" in {
916 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
917 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
918 (outs VR128:$dst), (ins VR128:$src1,
919 VR128:$src2, i8imm:$src3),
920 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
922 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
923 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
924 (outs VR128:$dst), (ins VR128:$src1,
925 f128mem:$src2, i8imm:$src3),
926 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
929 VR128:$src1, (memopv4f32 addr:$src2))))]>;
931 let AddedComplexity = 10 in {
932 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
933 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
934 "unpckhps\t{$src2, $dst|$dst, $src2}",
936 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
937 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
938 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
939 "unpckhps\t{$src2, $dst|$dst, $src2}",
941 (v4f32 (unpckh VR128:$src1,
942 (memopv4f32 addr:$src2))))]>;
944 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
945 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
946 "unpcklps\t{$src2, $dst|$dst, $src2}",
948 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
949 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
950 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
951 "unpcklps\t{$src2, $dst|$dst, $src2}",
953 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
955 } // Constraints = "$src1 = $dst"
958 def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
959 "movmskps\t{$src, $dst|$dst, $src}",
960 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
961 def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
962 "movmskpd\t{$src, $dst|$dst, $src}",
963 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
965 // Prefetch intrinsic.
966 def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
967 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
968 def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
969 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
970 def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
971 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
972 def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
973 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
975 // Non-temporal stores
976 def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
977 "movntps\t{$src, $dst|$dst, $src}",
978 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
980 // Load, store, and memory fence
981 def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
984 def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
985 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
986 def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
987 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
989 // Alias instructions that map zero vector to pxor / xorp* for sse.
990 // We set canFoldAsLoad because this can be converted to a constant-pool
991 // load of an all-zeros value if folding it would be beneficial.
992 let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1 in
993 def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
995 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
997 let Predicates = [HasSSE1] in {
998 def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
999 def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1000 def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1001 def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1002 def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
1005 // FR32 to 128-bit vector conversion.
1006 let isAsCheapAsAMove = 1 in
1007 def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
1008 "movss\t{$src, $dst|$dst, $src}",
1010 (v4f32 (scalar_to_vector FR32:$src)))]>;
1011 def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
1012 "movss\t{$src, $dst|$dst, $src}",
1014 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
1016 // FIXME: may not be able to eliminate this movss with coalescing the src and
1017 // dest register classes are different. We really want to write this pattern
1019 // def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1020 // (f32 FR32:$src)>;
1021 let isAsCheapAsAMove = 1 in
1022 def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
1023 "movss\t{$src, $dst|$dst, $src}",
1024 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
1026 def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
1027 "movss\t{$src, $dst|$dst, $src}",
1028 [(store (f32 (vector_extract (v4f32 VR128:$src),
1029 (iPTR 0))), addr:$dst)]>;
1032 // Move to lower bits of a VR128, leaving upper bits alone.
1033 // Three operand (but two address) aliases.
1034 let Constraints = "$src1 = $dst" in {
1035 let neverHasSideEffects = 1 in
1036 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
1037 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
1038 "movss\t{$src2, $dst|$dst, $src2}", []>;
1040 let AddedComplexity = 15 in
1041 def MOVLPSrr : SSI<0x10, MRMSrcReg,
1042 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1043 "movss\t{$src2, $dst|$dst, $src2}",
1045 (v4f32 (movl VR128:$src1, VR128:$src2)))]>;
1048 // Move to lower bits of a VR128 and zeroing upper bits.
1049 // Loading from memory automatically zeroing upper bits.
1050 let AddedComplexity = 20 in
1051 def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
1052 "movss\t{$src, $dst|$dst, $src}",
1053 [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector
1054 (loadf32 addr:$src))))))]>;
1056 def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
1057 (MOVZSS2PSrm addr:$src)>;
1059 //===---------------------------------------------------------------------===//
1060 // SSE2 Instructions
1061 //===---------------------------------------------------------------------===//
1063 // Move Instructions
1064 let neverHasSideEffects = 1 in
1065 def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1066 "movsd\t{$src, $dst|$dst, $src}", []>;
1067 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
1068 def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
1069 "movsd\t{$src, $dst|$dst, $src}",
1070 [(set FR64:$dst, (loadf64 addr:$src))]>;
1071 def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
1072 "movsd\t{$src, $dst|$dst, $src}",
1073 [(store FR64:$src, addr:$dst)]>;
1075 // Conversion instructions
1076 def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
1077 "cvttsd2si\t{$src, $dst|$dst, $src}",
1078 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
1079 def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
1080 "cvttsd2si\t{$src, $dst|$dst, $src}",
1081 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
1082 def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
1083 "cvtsd2ss\t{$src, $dst|$dst, $src}",
1084 [(set FR32:$dst, (fround FR64:$src))]>;
1085 def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
1086 "cvtsd2ss\t{$src, $dst|$dst, $src}",
1087 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
1088 def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
1089 "cvtsi2sd\t{$src, $dst|$dst, $src}",
1090 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
1091 def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
1092 "cvtsi2sd\t{$src, $dst|$dst, $src}",
1093 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1095 // SSE2 instructions with XS prefix
1096 def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
1097 "cvtss2sd\t{$src, $dst|$dst, $src}",
1098 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1099 Requires<[HasSSE2]>;
1100 def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
1101 "cvtss2sd\t{$src, $dst|$dst, $src}",
1102 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1103 Requires<[HasSSE2]>;
1105 // Match intrinsics which expect XMM operand(s).
1106 def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
1107 "cvtsd2si\t{$src, $dst|$dst, $src}",
1108 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
1109 def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
1110 "cvtsd2si\t{$src, $dst|$dst, $src}",
1111 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1112 (load addr:$src)))]>;
1114 // Match intrinisics which expect MM and XMM operand(s).
1115 def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1116 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1117 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1118 def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1119 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1120 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
1121 (memop addr:$src)))]>;
1122 def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1123 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1124 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1125 def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1126 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1127 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
1128 (memop addr:$src)))]>;
1129 def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1130 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1131 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1132 def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1133 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1134 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
1135 (load addr:$src)))]>;
1137 // Aliases for intrinsics
1138 def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
1139 "cvttsd2si\t{$src, $dst|$dst, $src}",
1141 (int_x86_sse2_cvttsd2si VR128:$src))]>;
1142 def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
1143 "cvttsd2si\t{$src, $dst|$dst, $src}",
1144 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1145 (load addr:$src)))]>;
1147 // Comparison instructions
1148 let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
1149 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
1150 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
1151 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
1153 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
1154 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
1155 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
1158 let Defs = [EFLAGS] in {
1159 def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
1160 "ucomisd\t{$src2, $src1|$src1, $src2}",
1161 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
1162 def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
1163 "ucomisd\t{$src2, $src1|$src1, $src2}",
1164 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
1165 (implicit EFLAGS)]>;
1166 } // Defs = [EFLAGS]
1168 // Aliases to match intrinsics which expect XMM operand(s).
1169 let Constraints = "$src1 = $dst" in {
1170 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
1171 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
1173 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
1174 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1175 VR128:$src, imm:$cc))]>;
1176 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
1177 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src,
1179 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
1180 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1181 (load addr:$src), imm:$cc))]>;
1184 let Defs = [EFLAGS] in {
1185 def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1186 "ucomisd\t{$src2, $src1|$src1, $src2}",
1187 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1188 (implicit EFLAGS)]>;
1189 def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
1190 "ucomisd\t{$src2, $src1|$src1, $src2}",
1191 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1192 (implicit EFLAGS)]>;
1194 def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1195 "comisd\t{$src2, $src1|$src1, $src2}",
1196 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1197 (implicit EFLAGS)]>;
1198 def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1199 "comisd\t{$src2, $src1|$src1, $src2}",
1200 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
1201 (implicit EFLAGS)]>;
1202 } // Defs = [EFLAGS]
1204 // Aliases of packed SSE2 instructions for scalar use. These all have names
1205 // that start with 'Fs'.
1207 // Alias instructions that map fld0 to pxor for sse.
1208 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1209 def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
1210 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
1211 Requires<[HasSSE2]>, TB, OpSize;
1213 // Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1215 let neverHasSideEffects = 1 in
1216 def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1217 "movapd\t{$src, $dst|$dst, $src}", []>;
1219 // Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1221 let canFoldAsLoad = 1 in
1222 def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
1223 "movapd\t{$src, $dst|$dst, $src}",
1224 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
1226 // Alias bitwise logical operations using SSE logical ops on packed FP values.
1227 let Constraints = "$src1 = $dst" in {
1228 let isCommutable = 1 in {
1229 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1230 (ins FR64:$src1, FR64:$src2),
1231 "andpd\t{$src2, $dst|$dst, $src2}",
1232 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
1233 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1234 (ins FR64:$src1, FR64:$src2),
1235 "orpd\t{$src2, $dst|$dst, $src2}",
1236 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
1237 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1238 (ins FR64:$src1, FR64:$src2),
1239 "xorpd\t{$src2, $dst|$dst, $src2}",
1240 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1243 def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1244 (ins FR64:$src1, f128mem:$src2),
1245 "andpd\t{$src2, $dst|$dst, $src2}",
1246 [(set FR64:$dst, (X86fand FR64:$src1,
1247 (memopfsf64 addr:$src2)))]>;
1248 def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1249 (ins FR64:$src1, f128mem:$src2),
1250 "orpd\t{$src2, $dst|$dst, $src2}",
1251 [(set FR64:$dst, (X86for FR64:$src1,
1252 (memopfsf64 addr:$src2)))]>;
1253 def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1254 (ins FR64:$src1, f128mem:$src2),
1255 "xorpd\t{$src2, $dst|$dst, $src2}",
1256 [(set FR64:$dst, (X86fxor FR64:$src1,
1257 (memopfsf64 addr:$src2)))]>;
1259 let neverHasSideEffects = 1 in {
1260 def FsANDNPDrr : PDI<0x55, MRMSrcReg,
1261 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1262 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
1264 def FsANDNPDrm : PDI<0x55, MRMSrcMem,
1265 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
1266 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
1270 /// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1272 /// In addition, we also have a special variant of the scalar form here to
1273 /// represent the associated intrinsic operation. This form is unlike the
1274 /// plain scalar form, in that it takes an entire vector (instead of a scalar)
1275 /// and leaves the top elements unmodified (therefore these cannot be commuted).
1277 /// These three forms can each be reg+reg or reg+mem, so there are a total of
1278 /// six "instructions".
1280 let Constraints = "$src1 = $dst" in {
1281 multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1282 SDNode OpNode, Intrinsic F64Int,
1283 bit Commutable = 0> {
1284 // Scalar operation, reg+reg.
1285 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1286 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1287 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1288 let isCommutable = Commutable;
1291 // Scalar operation, reg+mem.
1292 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1293 (ins FR64:$src1, f64mem:$src2),
1294 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1295 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1297 // Vector operation, reg+reg.
1298 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1299 (ins VR128:$src1, VR128:$src2),
1300 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1301 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1302 let isCommutable = Commutable;
1305 // Vector operation, reg+mem.
1306 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1307 (ins VR128:$src1, f128mem:$src2),
1308 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1309 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
1311 // Intrinsic operation, reg+reg.
1312 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1313 (ins VR128:$src1, VR128:$src2),
1314 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1315 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
1317 // Intrinsic operation, reg+mem.
1318 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1319 (ins VR128:$src1, sdmem:$src2),
1320 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1321 [(set VR128:$dst, (F64Int VR128:$src1,
1322 sse_load_f64:$src2))]>;
1326 // Arithmetic instructions
1327 defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1328 defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1329 defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1330 defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1332 /// sse2_fp_binop_rm - Other SSE2 binops
1334 /// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1335 /// instructions for a full-vector intrinsic form. Operations that map
1336 /// onto C operators don't use this form since they just use the plain
1337 /// vector form instead of having a separate vector intrinsic form.
1339 /// This provides a total of eight "instructions".
1341 let Constraints = "$src1 = $dst" in {
1342 multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1346 bit Commutable = 0> {
1348 // Scalar operation, reg+reg.
1349 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1350 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1351 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1352 let isCommutable = Commutable;
1355 // Scalar operation, reg+mem.
1356 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1357 (ins FR64:$src1, f64mem:$src2),
1358 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1359 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1361 // Vector operation, reg+reg.
1362 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1363 (ins VR128:$src1, VR128:$src2),
1364 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1365 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1366 let isCommutable = Commutable;
1369 // Vector operation, reg+mem.
1370 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1371 (ins VR128:$src1, f128mem:$src2),
1372 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1373 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
1375 // Intrinsic operation, reg+reg.
1376 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1377 (ins VR128:$src1, VR128:$src2),
1378 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1379 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1380 let isCommutable = Commutable;
1383 // Intrinsic operation, reg+mem.
1384 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1385 (ins VR128:$src1, sdmem:$src2),
1386 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
1387 [(set VR128:$dst, (F64Int VR128:$src1,
1388 sse_load_f64:$src2))]>;
1390 // Vector intrinsic operation, reg+reg.
1391 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1392 (ins VR128:$src1, VR128:$src2),
1393 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1394 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1395 let isCommutable = Commutable;
1398 // Vector intrinsic operation, reg+mem.
1399 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1400 (ins VR128:$src1, f128mem:$src2),
1401 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
1402 [(set VR128:$dst, (V2F64Int VR128:$src1,
1403 (memopv2f64 addr:$src2)))]>;
1407 defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1408 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1409 defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1410 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1412 //===---------------------------------------------------------------------===//
1413 // SSE packed FP Instructions
1415 // Move Instructions
1416 let neverHasSideEffects = 1 in
1417 def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1418 "movapd\t{$src, $dst|$dst, $src}", []>;
1419 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
1420 def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1421 "movapd\t{$src, $dst|$dst, $src}",
1422 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
1424 def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1425 "movapd\t{$src, $dst|$dst, $src}",
1426 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
1428 let neverHasSideEffects = 1 in
1429 def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1430 "movupd\t{$src, $dst|$dst, $src}", []>;
1431 let canFoldAsLoad = 1 in
1432 def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1433 "movupd\t{$src, $dst|$dst, $src}",
1434 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
1435 def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1436 "movupd\t{$src, $dst|$dst, $src}",
1437 [(store (v2f64 VR128:$src), addr:$dst)]>;
1439 // Intrinsic forms of MOVUPD load and store
1440 def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1441 "movupd\t{$src, $dst|$dst, $src}",
1442 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
1443 def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1444 "movupd\t{$src, $dst|$dst, $src}",
1445 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
1447 let Constraints = "$src1 = $dst" in {
1448 let AddedComplexity = 20 in {
1449 def MOVLPDrm : PDI<0x12, MRMSrcMem,
1450 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
1451 "movlpd\t{$src2, $dst|$dst, $src2}",
1453 (v2f64 (movlp VR128:$src1,
1454 (scalar_to_vector (loadf64 addr:$src2)))))]>;
1455 def MOVHPDrm : PDI<0x16, MRMSrcMem,
1456 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
1457 "movhpd\t{$src2, $dst|$dst, $src2}",
1459 (v2f64 (movhp VR128:$src1,
1460 (scalar_to_vector (loadf64 addr:$src2)))))]>;
1461 } // AddedComplexity
1462 } // Constraints = "$src1 = $dst"
1464 def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
1465 "movlpd\t{$src, $dst|$dst, $src}",
1466 [(store (f64 (vector_extract (v2f64 VR128:$src),
1467 (iPTR 0))), addr:$dst)]>;
1469 // v2f64 extract element 1 is always custom lowered to unpack high to low
1470 // and extract element 0 so the non-store version isn't too horrible.
1471 def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
1472 "movhpd\t{$src, $dst|$dst, $src}",
1473 [(store (f64 (vector_extract
1474 (v2f64 (unpckh VR128:$src, (undef))),
1475 (iPTR 0))), addr:$dst)]>;
1477 // SSE2 instructions without OpSize prefix
1478 def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1479 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1480 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1481 TB, Requires<[HasSSE2]>;
1482 def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1483 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1484 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1485 (bitconvert (memopv2i64 addr:$src))))]>,
1486 TB, Requires<[HasSSE2]>;
1488 // SSE2 instructions with XS prefix
1489 def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1490 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1491 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1492 XS, Requires<[HasSSE2]>;
1493 def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1494 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1495 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1496 (bitconvert (memopv2i64 addr:$src))))]>,
1497 XS, Requires<[HasSSE2]>;
1499 def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1500 "cvtps2dq\t{$src, $dst|$dst, $src}",
1501 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
1502 def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1503 "cvtps2dq\t{$src, $dst|$dst, $src}",
1504 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1505 (memop addr:$src)))]>;
1506 // SSE2 packed instructions with XS prefix
1507 def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1508 "cvttps2dq\t{$src, $dst|$dst, $src}",
1509 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1510 XS, Requires<[HasSSE2]>;
1511 def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1512 "cvttps2dq\t{$src, $dst|$dst, $src}",
1513 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1514 (memop addr:$src)))]>,
1515 XS, Requires<[HasSSE2]>;
1517 // SSE2 packed instructions with XD prefix
1518 def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1519 "cvtpd2dq\t{$src, $dst|$dst, $src}",
1520 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1521 XD, Requires<[HasSSE2]>;
1522 def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1523 "cvtpd2dq\t{$src, $dst|$dst, $src}",
1524 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1525 (memop addr:$src)))]>,
1526 XD, Requires<[HasSSE2]>;
1528 def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1529 "cvttpd2dq\t{$src, $dst|$dst, $src}",
1530 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
1531 def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
1532 "cvttpd2dq\t{$src, $dst|$dst, $src}",
1533 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1534 (memop addr:$src)))]>;
1536 // SSE2 instructions without OpSize prefix
1537 def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1538 "cvtps2pd\t{$src, $dst|$dst, $src}",
1539 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1540 TB, Requires<[HasSSE2]>;
1541 def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
1542 "cvtps2pd\t{$src, $dst|$dst, $src}",
1543 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1544 (load addr:$src)))]>,
1545 TB, Requires<[HasSSE2]>;
1547 def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1548 "cvtpd2ps\t{$src, $dst|$dst, $src}",
1549 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
1550 def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1551 "cvtpd2ps\t{$src, $dst|$dst, $src}",
1552 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1553 (memop addr:$src)))]>;
1555 // Match intrinsics which expect XMM operand(s).
1556 // Aliases for intrinsics
1557 let Constraints = "$src1 = $dst" in {
1558 def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
1559 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
1560 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
1561 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1563 def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
1564 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
1565 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
1566 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1567 (loadi32 addr:$src2)))]>;
1568 def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
1569 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1570 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
1571 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1573 def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
1574 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
1575 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
1576 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1577 (load addr:$src2)))]>;
1578 def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
1579 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1580 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
1581 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1582 VR128:$src2))]>, XS,
1583 Requires<[HasSSE2]>;
1584 def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
1585 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
1586 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
1587 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1588 (load addr:$src2)))]>, XS,
1589 Requires<[HasSSE2]>;
1594 /// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1596 /// In addition, we also have a special variant of the scalar form here to
1597 /// represent the associated intrinsic operation. This form is unlike the
1598 /// plain scalar form, in that it takes an entire vector (instead of a
1599 /// scalar) and leaves the top elements undefined.
1601 /// And, we have a special variant form for a full-vector intrinsic form.
1603 /// These four forms can each have a reg or a mem operand, so there are a
1604 /// total of eight "instructions".
1606 multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1610 bit Commutable = 0> {
1611 // Scalar operation, reg.
1612 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1613 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1614 [(set FR64:$dst, (OpNode FR64:$src))]> {
1615 let isCommutable = Commutable;
1618 // Scalar operation, mem.
1619 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
1620 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1621 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1623 // Vector operation, reg.
1624 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1625 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1626 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1627 let isCommutable = Commutable;
1630 // Vector operation, mem.
1631 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1632 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1633 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
1635 // Intrinsic operation, reg.
1636 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1637 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1638 [(set VR128:$dst, (F64Int VR128:$src))]> {
1639 let isCommutable = Commutable;
1642 // Intrinsic operation, mem.
1643 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
1644 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1645 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1647 // Vector intrinsic operation, reg
1648 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1649 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1650 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1651 let isCommutable = Commutable;
1654 // Vector intrinsic operation, mem
1655 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1656 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1657 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
1661 defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1662 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1664 // There is no f64 version of the reciprocal approximation instructions.
1667 let Constraints = "$src1 = $dst" in {
1668 let isCommutable = 1 in {
1669 def ANDPDrr : PDI<0x54, MRMSrcReg,
1670 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1671 "andpd\t{$src2, $dst|$dst, $src2}",
1673 (and (bc_v2i64 (v2f64 VR128:$src1)),
1674 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1675 def ORPDrr : PDI<0x56, MRMSrcReg,
1676 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1677 "orpd\t{$src2, $dst|$dst, $src2}",
1679 (or (bc_v2i64 (v2f64 VR128:$src1)),
1680 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1681 def XORPDrr : PDI<0x57, MRMSrcReg,
1682 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1683 "xorpd\t{$src2, $dst|$dst, $src2}",
1685 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1686 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1689 def ANDPDrm : PDI<0x54, MRMSrcMem,
1690 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1691 "andpd\t{$src2, $dst|$dst, $src2}",
1693 (and (bc_v2i64 (v2f64 VR128:$src1)),
1694 (memopv2i64 addr:$src2)))]>;
1695 def ORPDrm : PDI<0x56, MRMSrcMem,
1696 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1697 "orpd\t{$src2, $dst|$dst, $src2}",
1699 (or (bc_v2i64 (v2f64 VR128:$src1)),
1700 (memopv2i64 addr:$src2)))]>;
1701 def XORPDrm : PDI<0x57, MRMSrcMem,
1702 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1703 "xorpd\t{$src2, $dst|$dst, $src2}",
1705 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1706 (memopv2i64 addr:$src2)))]>;
1707 def ANDNPDrr : PDI<0x55, MRMSrcReg,
1708 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1709 "andnpd\t{$src2, $dst|$dst, $src2}",
1711 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1712 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1713 def ANDNPDrm : PDI<0x55, MRMSrcMem,
1714 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
1715 "andnpd\t{$src2, $dst|$dst, $src2}",
1717 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1718 (memopv2i64 addr:$src2)))]>;
1721 let Constraints = "$src1 = $dst" in {
1722 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
1723 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1724 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1725 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1726 VR128:$src, imm:$cc))]>;
1727 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
1728 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1729 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1730 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1731 (memop addr:$src), imm:$cc))]>;
1733 def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
1734 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
1735 def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
1736 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
1738 // Shuffle and unpack instructions
1739 let Constraints = "$src1 = $dst" in {
1740 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
1741 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1742 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1744 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
1745 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
1746 (outs VR128:$dst), (ins VR128:$src1,
1747 f128mem:$src2, i8imm:$src3),
1748 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1751 VR128:$src1, (memopv2f64 addr:$src2))))]>;
1753 let AddedComplexity = 10 in {
1754 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
1755 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1756 "unpckhpd\t{$src2, $dst|$dst, $src2}",
1758 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
1759 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
1760 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1761 "unpckhpd\t{$src2, $dst|$dst, $src2}",
1763 (v2f64 (unpckh VR128:$src1,
1764 (memopv2f64 addr:$src2))))]>;
1766 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
1767 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1768 "unpcklpd\t{$src2, $dst|$dst, $src2}",
1770 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
1771 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
1772 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
1773 "unpcklpd\t{$src2, $dst|$dst, $src2}",
1775 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
1776 } // AddedComplexity
1777 } // Constraints = "$src1 = $dst"
1780 //===---------------------------------------------------------------------===//
1781 // SSE integer instructions
1783 // Move Instructions
1784 let neverHasSideEffects = 1 in
1785 def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1786 "movdqa\t{$src, $dst|$dst, $src}", []>;
1787 let canFoldAsLoad = 1, mayLoad = 1 in
1788 def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1789 "movdqa\t{$src, $dst|$dst, $src}",
1790 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
1792 def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1793 "movdqa\t{$src, $dst|$dst, $src}",
1794 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
1795 let canFoldAsLoad = 1, mayLoad = 1 in
1796 def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1797 "movdqu\t{$src, $dst|$dst, $src}",
1798 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
1799 XS, Requires<[HasSSE2]>;
1801 def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1802 "movdqu\t{$src, $dst|$dst, $src}",
1803 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
1804 XS, Requires<[HasSSE2]>;
1806 // Intrinsic forms of MOVDQU load and store
1807 let canFoldAsLoad = 1 in
1808 def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1809 "movdqu\t{$src, $dst|$dst, $src}",
1810 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1811 XS, Requires<[HasSSE2]>;
1812 def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1813 "movdqu\t{$src, $dst|$dst, $src}",
1814 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1815 XS, Requires<[HasSSE2]>;
1817 let Constraints = "$src1 = $dst" in {
1819 multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1820 bit Commutable = 0> {
1821 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1822 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1823 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1824 let isCommutable = Commutable;
1826 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1827 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1828 [(set VR128:$dst, (IntId VR128:$src1,
1829 (bitconvert (memopv2i64 addr:$src2))))]>;
1832 multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1834 Intrinsic IntId, Intrinsic IntId2> {
1835 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1837 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1838 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
1839 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1841 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1842 [(set VR128:$dst, (IntId VR128:$src1,
1843 (bitconvert (memopv2i64 addr:$src2))))]>;
1844 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1,
1846 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1847 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
1850 /// PDI_binop_rm - Simple SSE2 binary operator.
1851 multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1852 ValueType OpVT, bit Commutable = 0> {
1853 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1855 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1856 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1857 let isCommutable = Commutable;
1859 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1861 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1862 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
1863 (bitconvert (memopv2i64 addr:$src2)))))]>;
1866 /// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1868 /// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1869 /// to collapse (bitconvert VT to VT) into its operand.
1871 multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1872 bit Commutable = 0> {
1873 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1874 (ins VR128:$src1, VR128:$src2),
1875 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1876 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1877 let isCommutable = Commutable;
1879 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1880 (ins VR128:$src1, i128mem:$src2),
1881 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1882 [(set VR128:$dst, (OpNode VR128:$src1,
1883 (memopv2i64 addr:$src2)))]>;
1886 } // Constraints = "$src1 = $dst"
1888 // 128-bit Integer Arithmetic
1890 defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1891 defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1892 defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1893 defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1895 defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1896 defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1897 defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1898 defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1900 defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1901 defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1902 defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1903 defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1905 defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1906 defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1907 defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1908 defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1910 defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1912 defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1913 defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1914 defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1916 defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1918 defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1919 defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1922 defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1923 defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1924 defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1925 defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1926 defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
1929 defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
1930 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
1931 defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
1932 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
1933 defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
1934 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
1936 defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
1937 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
1938 defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
1939 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
1940 defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
1941 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
1943 defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
1944 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
1945 defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
1946 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
1948 // 128-bit logical shifts.
1949 let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
1950 def PSLLDQri : PDIi8<0x73, MRM7r,
1951 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
1952 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
1953 def PSRLDQri : PDIi8<0x73, MRM3r,
1954 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
1955 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
1956 // PSRADQri doesn't exist in SSE[1-3].
1959 let Predicates = [HasSSE2] in {
1960 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1961 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1962 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1963 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1964 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
1965 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
1966 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
1967 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
1968 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1969 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1971 // Shift up / down and insert zero's.
1972 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
1973 (v2i64 (PSLLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>;
1974 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
1975 (v2i64 (PSRLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>;
1979 defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1980 defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1981 defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1983 let Constraints = "$src1 = $dst" in {
1984 def PANDNrr : PDI<0xDF, MRMSrcReg,
1985 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
1986 "pandn\t{$src2, $dst|$dst, $src2}",
1987 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1990 def PANDNrm : PDI<0xDF, MRMSrcMem,
1991 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
1992 "pandn\t{$src2, $dst|$dst, $src2}",
1993 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1994 (memopv2i64 addr:$src2))))]>;
1997 // SSE2 Integer comparison
1998 defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1999 defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2000 defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2001 defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2002 defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2003 defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
2005 def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
2006 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
2007 def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
2008 (PCMPEQBrm VR128:$src1, addr:$src2)>;
2009 def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
2010 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
2011 def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
2012 (PCMPEQWrm VR128:$src1, addr:$src2)>;
2013 def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
2014 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
2015 def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
2016 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2018 def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
2019 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
2020 def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
2021 (PCMPGTBrm VR128:$src1, addr:$src2)>;
2022 def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
2023 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
2024 def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
2025 (PCMPGTWrm VR128:$src1, addr:$src2)>;
2026 def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
2027 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
2028 def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
2029 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2032 // Pack instructions
2033 defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2034 defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2035 defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2037 // Shuffle and unpack instructions
2038 def PSHUFDri : PDIi8<0x70, MRMSrcReg,
2039 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
2040 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2041 [(set VR128:$dst, (v4i32 (pshufd:$src2
2042 VR128:$src1, (undef))))]>;
2043 def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
2044 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
2045 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2046 [(set VR128:$dst, (v4i32 (pshufd:$src2
2047 (bc_v4i32(memopv2i64 addr:$src1)),
2050 // SSE2 with ImmT == Imm8 and XS prefix.
2051 def PSHUFHWri : Ii8<0x70, MRMSrcReg,
2052 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
2053 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2054 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2056 XS, Requires<[HasSSE2]>;
2057 def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
2058 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
2059 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2060 [(set VR128:$dst, (v8i16 (pshufhw:$src2
2061 (bc_v8i16 (memopv2i64 addr:$src1)),
2063 XS, Requires<[HasSSE2]>;
2065 // SSE2 with ImmT == Imm8 and XD prefix.
2066 def PSHUFLWri : Ii8<0x70, MRMSrcReg,
2067 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
2068 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2069 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2071 XD, Requires<[HasSSE2]>;
2072 def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
2073 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
2074 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2075 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2076 (bc_v8i16 (memopv2i64 addr:$src1)),
2078 XD, Requires<[HasSSE2]>;
2081 let Constraints = "$src1 = $dst" in {
2082 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
2083 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2084 "punpcklbw\t{$src2, $dst|$dst, $src2}",
2086 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
2087 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
2088 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2089 "punpcklbw\t{$src2, $dst|$dst, $src2}",
2091 (unpckl VR128:$src1,
2092 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
2093 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
2094 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2095 "punpcklwd\t{$src2, $dst|$dst, $src2}",
2097 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
2098 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
2099 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2100 "punpcklwd\t{$src2, $dst|$dst, $src2}",
2102 (unpckl VR128:$src1,
2103 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
2104 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
2105 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2106 "punpckldq\t{$src2, $dst|$dst, $src2}",
2108 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
2109 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
2110 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2111 "punpckldq\t{$src2, $dst|$dst, $src2}",
2113 (unpckl VR128:$src1,
2114 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
2115 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
2116 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2117 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
2119 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
2120 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
2121 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2122 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
2124 (v2i64 (unpckl VR128:$src1,
2125 (memopv2i64 addr:$src2))))]>;
2127 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
2128 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2129 "punpckhbw\t{$src2, $dst|$dst, $src2}",
2131 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
2132 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
2133 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2134 "punpckhbw\t{$src2, $dst|$dst, $src2}",
2136 (unpckh VR128:$src1,
2137 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
2138 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
2139 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2140 "punpckhwd\t{$src2, $dst|$dst, $src2}",
2142 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
2143 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
2144 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2145 "punpckhwd\t{$src2, $dst|$dst, $src2}",
2147 (unpckh VR128:$src1,
2148 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
2149 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
2150 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2151 "punpckhdq\t{$src2, $dst|$dst, $src2}",
2153 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
2154 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
2155 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2156 "punpckhdq\t{$src2, $dst|$dst, $src2}",
2158 (unpckh VR128:$src1,
2159 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
2160 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
2161 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2162 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
2164 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
2165 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
2166 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2167 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
2169 (v2i64 (unpckh VR128:$src1,
2170 (memopv2i64 addr:$src2))))]>;
2174 def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
2175 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
2176 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2177 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
2179 let Constraints = "$src1 = $dst" in {
2180 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
2181 (outs VR128:$dst), (ins VR128:$src1,
2182 GR32:$src2, i32i8imm:$src3),
2183 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2185 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
2186 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
2187 (outs VR128:$dst), (ins VR128:$src1,
2188 i16mem:$src2, i32i8imm:$src3),
2189 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2191 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2196 def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
2197 "pmovmskb\t{$src, $dst|$dst, $src}",
2198 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2200 // Conditional store
2202 def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2203 "maskmovdqu\t{$mask, $src|$src, $mask}",
2204 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
2207 def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2208 "maskmovdqu\t{$mask, $src|$src, $mask}",
2209 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2211 // Non-temporal stores
2212 def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2213 "movntpd\t{$src, $dst|$dst, $src}",
2214 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
2215 def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2216 "movntdq\t{$src, $dst|$dst, $src}",
2217 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
2218 def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
2219 "movnti\t{$src, $dst|$dst, $src}",
2220 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2221 TB, Requires<[HasSSE2]>;
2224 def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
2225 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
2226 TB, Requires<[HasSSE2]>;
2228 // Load, store, and memory fence
2229 def LFENCE : I<0xAE, MRM5r, (outs), (ins),
2230 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
2231 def MFENCE : I<0xAE, MRM6r, (outs), (ins),
2232 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2234 //TODO: custom lower this so as to never even generate the noop
2235 def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
2237 def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2238 def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
2239 def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
2242 // Alias instructions that map zero vector to pxor / xorp* for sse.
2243 // We set canFoldAsLoad because this can be converted to a constant-pool
2244 // load of an all-ones value if folding it would be beneficial.
2245 let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1 in
2246 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
2247 "pcmpeqd\t$dst, $dst",
2248 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
2250 // FR64 to 128-bit vector conversion.
2251 let isAsCheapAsAMove = 1 in
2252 def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
2253 "movsd\t{$src, $dst|$dst, $src}",
2255 (v2f64 (scalar_to_vector FR64:$src)))]>;
2256 def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2257 "movsd\t{$src, $dst|$dst, $src}",
2259 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2261 def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2262 "movd\t{$src, $dst|$dst, $src}",
2264 (v4i32 (scalar_to_vector GR32:$src)))]>;
2265 def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2266 "movd\t{$src, $dst|$dst, $src}",
2268 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2270 def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
2271 "movd\t{$src, $dst|$dst, $src}",
2272 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2274 def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
2275 "movd\t{$src, $dst|$dst, $src}",
2276 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2278 // SSE2 instructions with XS prefix
2279 def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
2280 "movq\t{$src, $dst|$dst, $src}",
2282 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2283 Requires<[HasSSE2]>;
2284 def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
2285 "movq\t{$src, $dst|$dst, $src}",
2286 [(store (i64 (vector_extract (v2i64 VR128:$src),
2287 (iPTR 0))), addr:$dst)]>;
2289 // FIXME: may not be able to eliminate this movss with coalescing the src and
2290 // dest register classes are different. We really want to write this pattern
2292 // def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2293 // (f32 FR32:$src)>;
2294 let isAsCheapAsAMove = 1 in
2295 def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
2296 "movsd\t{$src, $dst|$dst, $src}",
2297 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2299 def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
2300 "movsd\t{$src, $dst|$dst, $src}",
2301 [(store (f64 (vector_extract (v2f64 VR128:$src),
2302 (iPTR 0))), addr:$dst)]>;
2303 def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
2304 "movd\t{$src, $dst|$dst, $src}",
2305 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2307 def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
2308 "movd\t{$src, $dst|$dst, $src}",
2309 [(store (i32 (vector_extract (v4i32 VR128:$src),
2310 (iPTR 0))), addr:$dst)]>;
2312 def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
2313 "movd\t{$src, $dst|$dst, $src}",
2314 [(set GR32:$dst, (bitconvert FR32:$src))]>;
2315 def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
2316 "movd\t{$src, $dst|$dst, $src}",
2317 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2320 // Move to lower bits of a VR128, leaving upper bits alone.
2321 // Three operand (but two address) aliases.
2322 let Constraints = "$src1 = $dst" in {
2323 let neverHasSideEffects = 1 in
2324 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
2325 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
2326 "movsd\t{$src2, $dst|$dst, $src2}", []>;
2328 let AddedComplexity = 15 in
2329 def MOVLPDrr : SDI<0x10, MRMSrcReg,
2330 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2331 "movsd\t{$src2, $dst|$dst, $src2}",
2333 (v2f64 (movl VR128:$src1, VR128:$src2)))]>;
2336 // Store / copy lower 64-bits of a XMM register.
2337 def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
2338 "movq\t{$src, $dst|$dst, $src}",
2339 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2341 // Move to lower bits of a VR128 and zeroing upper bits.
2342 // Loading from memory automatically zeroing upper bits.
2343 let AddedComplexity = 20 in {
2344 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2345 "movsd\t{$src, $dst|$dst, $src}",
2347 (v2f64 (X86vzmovl (v2f64 (scalar_to_vector
2348 (loadf64 addr:$src))))))]>;
2350 def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
2351 (MOVZSD2PDrm addr:$src)>;
2352 def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
2353 (MOVZSD2PDrm addr:$src)>;
2354 def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>;
2357 // movd / movq to XMM register zero-extends
2358 let AddedComplexity = 15 in {
2359 def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2360 "movd\t{$src, $dst|$dst, $src}",
2361 [(set VR128:$dst, (v4i32 (X86vzmovl
2362 (v4i32 (scalar_to_vector GR32:$src)))))]>;
2363 // This is X86-64 only.
2364 def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2365 "mov{d|q}\t{$src, $dst|$dst, $src}",
2366 [(set VR128:$dst, (v2i64 (X86vzmovl
2367 (v2i64 (scalar_to_vector GR64:$src)))))]>;
2370 let AddedComplexity = 20 in {
2371 def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2372 "movd\t{$src, $dst|$dst, $src}",
2374 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
2375 (loadi32 addr:$src))))))]>;
2377 def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2378 (MOVZDI2PDIrm addr:$src)>;
2379 def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2380 (MOVZDI2PDIrm addr:$src)>;
2381 def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2382 (MOVZDI2PDIrm addr:$src)>;
2384 def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
2385 "movq\t{$src, $dst|$dst, $src}",
2387 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
2388 (loadi64 addr:$src))))))]>, XS,
2389 Requires<[HasSSE2]>;
2391 def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2392 (MOVZQI2PQIrm addr:$src)>;
2393 def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2394 (MOVZQI2PQIrm addr:$src)>;
2395 def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
2398 // Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2399 // IA32 document. movq xmm1, xmm2 does clear the high bits.
2400 let AddedComplexity = 15 in
2401 def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2402 "movq\t{$src, $dst|$dst, $src}",
2403 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
2404 XS, Requires<[HasSSE2]>;
2406 let AddedComplexity = 20 in {
2407 def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2408 "movq\t{$src, $dst|$dst, $src}",
2409 [(set VR128:$dst, (v2i64 (X86vzmovl
2410 (loadv2i64 addr:$src))))]>,
2411 XS, Requires<[HasSSE2]>;
2413 def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2414 (MOVZPQILo2PQIrm addr:$src)>;
2417 //===---------------------------------------------------------------------===//
2418 // SSE3 Instructions
2419 //===---------------------------------------------------------------------===//
2421 // Move Instructions
2422 def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2423 "movshdup\t{$src, $dst|$dst, $src}",
2424 [(set VR128:$dst, (v4f32 (movshdup
2425 VR128:$src, (undef))))]>;
2426 def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
2427 "movshdup\t{$src, $dst|$dst, $src}",
2428 [(set VR128:$dst, (movshdup
2429 (memopv4f32 addr:$src), (undef)))]>;
2431 def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2432 "movsldup\t{$src, $dst|$dst, $src}",
2433 [(set VR128:$dst, (v4f32 (movsldup
2434 VR128:$src, (undef))))]>;
2435 def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
2436 "movsldup\t{$src, $dst|$dst, $src}",
2437 [(set VR128:$dst, (movsldup
2438 (memopv4f32 addr:$src), (undef)))]>;
2440 def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2441 "movddup\t{$src, $dst|$dst, $src}",
2442 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
2443 def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2444 "movddup\t{$src, $dst|$dst, $src}",
2446 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2449 def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2451 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2453 let AddedComplexity = 5 in {
2454 def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
2455 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2456 def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2457 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2458 def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2459 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2460 def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2461 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2465 let Constraints = "$src1 = $dst" in {
2466 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
2467 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2468 "addsubps\t{$src2, $dst|$dst, $src2}",
2469 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2471 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
2472 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2473 "addsubps\t{$src2, $dst|$dst, $src2}",
2474 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2475 (memop addr:$src2)))]>;
2476 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
2477 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2478 "addsubpd\t{$src2, $dst|$dst, $src2}",
2479 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2481 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
2482 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2483 "addsubpd\t{$src2, $dst|$dst, $src2}",
2484 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2485 (memop addr:$src2)))]>;
2488 def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2489 "lddqu\t{$src, $dst|$dst, $src}",
2490 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2493 class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
2494 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2495 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2496 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2497 class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
2498 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2499 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2500 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
2501 class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
2502 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2503 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2504 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2505 class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
2506 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
2507 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2508 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
2510 let Constraints = "$src1 = $dst" in {
2511 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2512 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2513 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2514 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2515 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2516 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2517 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2518 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2521 // Thread synchronization
2522 def MONITOR : I<0x01, MRM1r, (outs), (ins), "monitor",
2523 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
2524 def MWAIT : I<0x01, MRM1r, (outs), (ins), "mwait",
2525 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2527 // vector_shuffle v1, <undef> <1, 1, 3, 3>
2528 let AddedComplexity = 15 in
2529 def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
2530 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2531 let AddedComplexity = 20 in
2532 def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
2533 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2535 // vector_shuffle v1, <undef> <0, 0, 2, 2>
2536 let AddedComplexity = 15 in
2537 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
2538 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2539 let AddedComplexity = 20 in
2540 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
2541 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2543 //===---------------------------------------------------------------------===//
2544 // SSSE3 Instructions
2545 //===---------------------------------------------------------------------===//
2547 /// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
2548 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2549 Intrinsic IntId64, Intrinsic IntId128> {
2550 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2551 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2552 [(set VR64:$dst, (IntId64 VR64:$src))]>;
2554 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2555 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2557 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2559 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2561 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2562 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2565 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2567 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2570 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
2573 /// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2574 multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2575 Intrinsic IntId64, Intrinsic IntId128> {
2576 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2578 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2579 [(set VR64:$dst, (IntId64 VR64:$src))]>;
2581 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2583 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2586 (bitconvert (memopv4i16 addr:$src))))]>;
2588 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2590 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2591 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2594 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2596 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2599 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2602 /// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2603 multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2604 Intrinsic IntId64, Intrinsic IntId128> {
2605 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2607 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2608 [(set VR64:$dst, (IntId64 VR64:$src))]>;
2610 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2612 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2615 (bitconvert (memopv2i32 addr:$src))))]>;
2617 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2619 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2620 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2623 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2625 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2628 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2631 defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2632 int_x86_ssse3_pabs_b,
2633 int_x86_ssse3_pabs_b_128>;
2634 defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2635 int_x86_ssse3_pabs_w,
2636 int_x86_ssse3_pabs_w_128>;
2637 defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2638 int_x86_ssse3_pabs_d,
2639 int_x86_ssse3_pabs_d_128>;
2641 /// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2642 let Constraints = "$src1 = $dst" in {
2643 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2644 Intrinsic IntId64, Intrinsic IntId128,
2645 bit Commutable = 0> {
2646 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2647 (ins VR64:$src1, VR64:$src2),
2648 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2649 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2650 let isCommutable = Commutable;
2652 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2653 (ins VR64:$src1, i64mem:$src2),
2654 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2656 (IntId64 VR64:$src1,
2657 (bitconvert (memopv8i8 addr:$src2))))]>;
2659 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2660 (ins VR128:$src1, VR128:$src2),
2661 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2662 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2664 let isCommutable = Commutable;
2666 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2667 (ins VR128:$src1, i128mem:$src2),
2668 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2670 (IntId128 VR128:$src1,
2671 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2675 /// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2676 let Constraints = "$src1 = $dst" in {
2677 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2678 Intrinsic IntId64, Intrinsic IntId128,
2679 bit Commutable = 0> {
2680 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2681 (ins VR64:$src1, VR64:$src2),
2682 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2683 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2684 let isCommutable = Commutable;
2686 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2687 (ins VR64:$src1, i64mem:$src2),
2688 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2690 (IntId64 VR64:$src1,
2691 (bitconvert (memopv4i16 addr:$src2))))]>;
2693 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2694 (ins VR128:$src1, VR128:$src2),
2695 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2696 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2698 let isCommutable = Commutable;
2700 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2701 (ins VR128:$src1, i128mem:$src2),
2702 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2704 (IntId128 VR128:$src1,
2705 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2709 /// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2710 let Constraints = "$src1 = $dst" in {
2711 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2712 Intrinsic IntId64, Intrinsic IntId128,
2713 bit Commutable = 0> {
2714 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2715 (ins VR64:$src1, VR64:$src2),
2716 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2717 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2718 let isCommutable = Commutable;
2720 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2721 (ins VR64:$src1, i64mem:$src2),
2722 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2724 (IntId64 VR64:$src1,
2725 (bitconvert (memopv2i32 addr:$src2))))]>;
2727 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2728 (ins VR128:$src1, VR128:$src2),
2729 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2730 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2732 let isCommutable = Commutable;
2734 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2735 (ins VR128:$src1, i128mem:$src2),
2736 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2738 (IntId128 VR128:$src1,
2739 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2743 defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2744 int_x86_ssse3_phadd_w,
2745 int_x86_ssse3_phadd_w_128>;
2746 defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2747 int_x86_ssse3_phadd_d,
2748 int_x86_ssse3_phadd_d_128>;
2749 defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2750 int_x86_ssse3_phadd_sw,
2751 int_x86_ssse3_phadd_sw_128>;
2752 defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2753 int_x86_ssse3_phsub_w,
2754 int_x86_ssse3_phsub_w_128>;
2755 defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2756 int_x86_ssse3_phsub_d,
2757 int_x86_ssse3_phsub_d_128>;
2758 defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2759 int_x86_ssse3_phsub_sw,
2760 int_x86_ssse3_phsub_sw_128>;
2761 defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2762 int_x86_ssse3_pmadd_ub_sw,
2763 int_x86_ssse3_pmadd_ub_sw_128>;
2764 defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2765 int_x86_ssse3_pmul_hr_sw,
2766 int_x86_ssse3_pmul_hr_sw_128, 1>;
2767 defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2768 int_x86_ssse3_pshuf_b,
2769 int_x86_ssse3_pshuf_b_128>;
2770 defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2771 int_x86_ssse3_psign_b,
2772 int_x86_ssse3_psign_b_128>;
2773 defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2774 int_x86_ssse3_psign_w,
2775 int_x86_ssse3_psign_w_128>;
2776 defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
2777 int_x86_ssse3_psign_d,
2778 int_x86_ssse3_psign_d_128>;
2780 let Constraints = "$src1 = $dst" in {
2781 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2782 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
2783 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2785 (int_x86_ssse3_palign_r
2786 VR64:$src1, VR64:$src2,
2788 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
2789 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
2790 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2792 (int_x86_ssse3_palign_r
2794 (bitconvert (memopv2i32 addr:$src2)),
2797 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2798 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
2799 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2801 (int_x86_ssse3_palign_r_128
2802 VR128:$src1, VR128:$src2,
2803 imm:$src3))]>, OpSize;
2804 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
2805 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
2806 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2808 (int_x86_ssse3_palign_r_128
2810 (bitconvert (memopv4i32 addr:$src2)),
2811 imm:$src3))]>, OpSize;
2814 def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2815 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2816 def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2817 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2819 //===---------------------------------------------------------------------===//
2820 // Non-Instruction Patterns
2821 //===---------------------------------------------------------------------===//
2823 // extload f32 -> f64. This matches load+fextend because we have a hack in
2824 // the isel (PreprocessForFPConvert) that can introduce loads after dag
2826 // Since these loads aren't folded into the fextend, we have to match it
2828 let Predicates = [HasSSE2] in
2829 def : Pat<(fextend (loadf32 addr:$src)),
2830 (CVTSS2SDrm addr:$src)>;
2833 let Predicates = [HasSSE2] in {
2834 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2835 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2836 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2837 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2838 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2839 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2840 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2841 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2842 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2843 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2844 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2845 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2846 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2847 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2848 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2849 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2850 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2851 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2852 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2853 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2854 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2855 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2856 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2857 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2858 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2859 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2860 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2861 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2862 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2863 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2866 // Move scalar to XMM zero-extended
2867 // movd to XMM register zero-extends
2868 let AddedComplexity = 15 in {
2869 // Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
2870 def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
2871 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
2872 def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
2873 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE1]>;
2874 def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
2875 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
2876 def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
2877 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
2880 // Splat v2f64 / v2i64
2881 let AddedComplexity = 10 in {
2882 def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
2883 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2884 def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
2885 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2886 def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
2887 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2888 def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
2889 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2892 // Special unary SHUFPSrri case.
2893 def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
2894 (SHUFPSrri VR128:$src1, VR128:$src1,
2895 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2896 Requires<[HasSSE1]>;
2897 let AddedComplexity = 5 in
2898 def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
2899 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2900 Requires<[HasSSE2]>;
2901 // Special unary SHUFPDrri case.
2902 def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
2903 (SHUFPDrri VR128:$src1, VR128:$src1,
2904 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2905 Requires<[HasSSE2]>;
2906 // Special unary SHUFPDrri case.
2907 def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
2908 (SHUFPDrri VR128:$src1, VR128:$src1,
2909 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2910 Requires<[HasSSE2]>;
2911 // Unary v4f32 shuffle with PSHUF* in order to fold a load.
2912 def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
2913 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2914 Requires<[HasSSE2]>;
2916 // Special binary v4i32 shuffle cases with SHUFPS.
2917 def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
2918 (SHUFPSrri VR128:$src1, VR128:$src2,
2919 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2920 Requires<[HasSSE2]>;
2921 def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
2922 (SHUFPSrmi VR128:$src1, addr:$src2,
2923 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2924 Requires<[HasSSE2]>;
2925 // Special binary v2i64 shuffle cases using SHUFPDrri.
2926 def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
2927 (SHUFPDrri VR128:$src1, VR128:$src2,
2928 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2929 Requires<[HasSSE2]>;
2931 // vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2932 let AddedComplexity = 15 in {
2933 def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
2934 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2935 Requires<[OptForSpeed, HasSSE2]>;
2936 def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
2937 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2938 Requires<[OptForSpeed, HasSSE2]>;
2940 let AddedComplexity = 10 in {
2941 def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
2942 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2943 def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
2944 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2945 def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
2946 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2947 def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
2948 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2951 // vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2952 let AddedComplexity = 15 in {
2953 def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
2954 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2955 Requires<[OptForSpeed, HasSSE2]>;
2956 def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
2957 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2958 Requires<[OptForSpeed, HasSSE2]>;
2960 let AddedComplexity = 10 in {
2961 def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
2962 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2963 def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
2964 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2965 def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
2966 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2967 def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
2968 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2971 let AddedComplexity = 20 in {
2972 // vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2973 def : Pat<(v4i32 (movhp VR128:$src1, VR128:$src2)),
2974 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2976 // vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2977 def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
2978 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2980 // vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2981 def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
2982 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2983 def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
2984 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2987 let AddedComplexity = 20 in {
2988 // vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2989 // vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
2990 def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
2991 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
2992 def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
2993 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2994 def : Pat<(v4f32 (movhp VR128:$src1, (load addr:$src2))),
2995 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
2996 def : Pat<(v2f64 (movhp VR128:$src1, (load addr:$src2))),
2997 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2999 def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
3000 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3001 def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
3002 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3003 def : Pat<(v4i32 (movhp VR128:$src1, (load addr:$src2))),
3004 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
3005 def : Pat<(v2i64 (movhp VR128:$src1, (load addr:$src2))),
3006 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3009 // (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
3010 // (store (vector_shuffle (load addr), v2, <0, 1, 4, 5>), addr) using MOVHPS
3011 def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3012 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
3013 def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3014 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3015 def : Pat<(store (v4f32 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
3016 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
3017 def : Pat<(store (v2f64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
3018 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3020 def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3022 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
3023 def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3024 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3025 def : Pat<(store (v4i32 (movhp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3027 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
3028 def : Pat<(store (v2i64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
3029 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3032 let AddedComplexity = 15 in {
3033 // Setting the lowest element in the vector.
3034 def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
3035 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3036 def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
3037 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3039 // vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
3040 def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
3041 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3042 def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
3043 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3046 // vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3047 // fall back to this for SSE1)
3048 def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
3049 (SHUFPSrri VR128:$src2, VR128:$src1,
3050 (SHUFFLE_get_shuf_imm VR128:$src3))>, Requires<[HasSSE1]>;
3052 // Set lowest element and zero upper elements.
3053 let AddedComplexity = 15 in
3054 def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
3055 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
3056 def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
3057 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
3059 // Some special case pandn patterns.
3060 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3062 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3063 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3065 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3066 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3068 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3070 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3071 (memop addr:$src2))),
3072 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3073 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3074 (memop addr:$src2))),
3075 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3076 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3077 (memop addr:$src2))),
3078 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3080 // vector -> vector casts
3081 def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3082 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3083 def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3084 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
3085 def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3086 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3087 def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3088 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
3090 // Use movaps / movups for SSE integer load / store (one byte shorter).
3091 def : Pat<(alignedloadv4i32 addr:$src),
3092 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
3093 def : Pat<(loadv4i32 addr:$src),
3094 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
3095 def : Pat<(alignedloadv2i64 addr:$src),
3096 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3097 def : Pat<(loadv2i64 addr:$src),
3098 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3100 def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3101 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3102 def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3103 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3104 def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3105 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3106 def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3107 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3108 def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3109 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3110 def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3111 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3112 def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3113 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3114 def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3115 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3117 //===----------------------------------------------------------------------===//
3118 // SSE4.1 Instructions
3119 //===----------------------------------------------------------------------===//
3121 multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
3124 Intrinsic V2F64Int> {
3125 // Intrinsic operation, reg.
3126 // Vector intrinsic operation, reg
3127 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
3128 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
3129 !strconcat(OpcodeStr,
3130 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3131 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3134 // Vector intrinsic operation, mem
3135 def PSm_Int : SS4AIi8<opcps, MRMSrcMem,
3136 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
3137 !strconcat(OpcodeStr,
3138 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3140 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
3143 // Vector intrinsic operation, reg
3144 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
3145 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
3146 !strconcat(OpcodeStr,
3147 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3148 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3151 // Vector intrinsic operation, mem
3152 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
3153 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
3154 !strconcat(OpcodeStr,
3155 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3157 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
3161 let Constraints = "$src1 = $dst" in {
3162 multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3166 // Intrinsic operation, reg.
3167 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
3169 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3170 !strconcat(OpcodeStr,
3171 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3173 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3176 // Intrinsic operation, mem.
3177 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3179 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
3180 !strconcat(OpcodeStr,
3181 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3183 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3186 // Intrinsic operation, reg.
3187 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
3189 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3190 !strconcat(OpcodeStr,
3191 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3193 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3196 // Intrinsic operation, mem.
3197 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
3199 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3200 !strconcat(OpcodeStr,
3201 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3203 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3208 // FP round - roundss, roundps, roundsd, roundpd
3209 defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3210 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3211 defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3212 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
3214 // SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3215 multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3216 Intrinsic IntId128> {
3217 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3219 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3220 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3221 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3223 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3226 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3229 defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3230 int_x86_sse41_phminposuw>;
3232 /// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
3233 let Constraints = "$src1 = $dst" in {
3234 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3235 Intrinsic IntId128, bit Commutable = 0> {
3236 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3237 (ins VR128:$src1, VR128:$src2),
3238 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3239 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3241 let isCommutable = Commutable;
3243 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3244 (ins VR128:$src1, i128mem:$src2),
3245 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3247 (IntId128 VR128:$src1,
3248 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3252 defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3253 int_x86_sse41_pcmpeqq, 1>;
3254 defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3255 int_x86_sse41_packusdw, 0>;
3256 defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3257 int_x86_sse41_pminsb, 1>;
3258 defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3259 int_x86_sse41_pminsd, 1>;
3260 defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3261 int_x86_sse41_pminud, 1>;
3262 defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3263 int_x86_sse41_pminuw, 1>;
3264 defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3265 int_x86_sse41_pmaxsb, 1>;
3266 defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3267 int_x86_sse41_pmaxsd, 1>;
3268 defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3269 int_x86_sse41_pmaxud, 1>;
3270 defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3271 int_x86_sse41_pmaxuw, 1>;
3273 defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3275 def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3276 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3277 def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3278 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3280 /// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
3281 let Constraints = "$src1 = $dst" in {
3282 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3283 SDNode OpNode, Intrinsic IntId128,
3284 bit Commutable = 0> {
3285 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3286 (ins VR128:$src1, VR128:$src2),
3287 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3288 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3289 VR128:$src2))]>, OpSize {
3290 let isCommutable = Commutable;
3292 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3293 (ins VR128:$src1, VR128:$src2),
3294 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3295 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3297 let isCommutable = Commutable;
3299 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3300 (ins VR128:$src1, i128mem:$src2),
3301 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3303 (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize;
3304 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3305 (ins VR128:$src1, i128mem:$src2),
3306 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3308 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
3312 defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
3313 int_x86_sse41_pmulld, 1>;
3315 /// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
3316 let Constraints = "$src1 = $dst" in {
3317 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3318 Intrinsic IntId128, bit Commutable = 0> {
3319 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3320 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3321 !strconcat(OpcodeStr,
3322 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3324 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3326 let isCommutable = Commutable;
3328 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3329 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3330 !strconcat(OpcodeStr,
3331 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3333 (IntId128 VR128:$src1,
3334 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3339 defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3340 int_x86_sse41_blendps, 0>;
3341 defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3342 int_x86_sse41_blendpd, 0>;
3343 defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3344 int_x86_sse41_pblendw, 0>;
3345 defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3346 int_x86_sse41_dpps, 1>;
3347 defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3348 int_x86_sse41_dppd, 1>;
3349 defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
3350 int_x86_sse41_mpsadbw, 1>;
3353 /// SS41I_ternary_int - SSE 4.1 ternary operator
3354 let Uses = [XMM0], Constraints = "$src1 = $dst" in {
3355 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3356 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3357 (ins VR128:$src1, VR128:$src2),
3358 !strconcat(OpcodeStr,
3359 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3360 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3363 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3364 (ins VR128:$src1, i128mem:$src2),
3365 !strconcat(OpcodeStr,
3366 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3369 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3373 defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3374 defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3375 defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3378 multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3379 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3380 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3381 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3383 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3384 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3386 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3390 defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3391 defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3392 defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3393 defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3394 defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3395 defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3397 // Common patterns involving scalar load.
3398 def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3399 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3400 def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3401 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3403 def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3404 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3405 def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3406 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3408 def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3409 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3410 def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3411 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3413 def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3414 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3415 def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3416 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3418 def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3419 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3420 def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3421 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3423 def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3424 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3425 def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3426 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3429 multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3430 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3431 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3432 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3434 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3435 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3437 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3441 defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3442 defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3443 defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3444 defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3446 // Common patterns involving scalar load
3447 def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
3448 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
3449 def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
3450 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
3452 def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
3453 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
3454 def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
3455 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
3458 multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3459 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3460 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3461 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3463 // Expecting a i16 load any extended to i32 value.
3464 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3465 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3466 [(set VR128:$dst, (IntId (bitconvert
3467 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3471 defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
3472 defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
3474 // Common patterns involving scalar load
3475 def : Pat<(int_x86_sse41_pmovsxbq
3476 (bitconvert (v4i32 (X86vzmovl
3477 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
3478 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
3480 def : Pat<(int_x86_sse41_pmovzxbq
3481 (bitconvert (v4i32 (X86vzmovl
3482 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
3483 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
3486 /// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3487 multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
3488 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
3489 (ins VR128:$src1, i32i8imm:$src2),
3490 !strconcat(OpcodeStr,
3491 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3492 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3494 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3495 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
3496 !strconcat(OpcodeStr,
3497 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3500 // There's an AssertZext in the way of writing the store pattern
3501 // (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3504 defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
3507 /// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3508 multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
3509 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3510 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
3511 !strconcat(OpcodeStr,
3512 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3515 // There's an AssertZext in the way of writing the store pattern
3516 // (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3519 defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3522 /// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3523 multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
3524 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
3525 (ins VR128:$src1, i32i8imm:$src2),
3526 !strconcat(OpcodeStr,
3527 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3529 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
3530 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3531 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
3532 !strconcat(OpcodeStr,
3533 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3534 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3535 addr:$dst)]>, OpSize;
3538 defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
3541 /// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3543 multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
3544 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
3545 (ins VR128:$src1, i32i8imm:$src2),
3546 !strconcat(OpcodeStr,
3547 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3549 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
3551 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3552 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
3553 !strconcat(OpcodeStr,
3554 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3555 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
3556 addr:$dst)]>, OpSize;
3559 defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
3561 // Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3562 def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3565 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3566 Requires<[HasSSE41]>;
3568 let Constraints = "$src1 = $dst" in {
3569 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
3570 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3571 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
3572 !strconcat(OpcodeStr,
3573 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3575 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
3576 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3577 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3578 !strconcat(OpcodeStr,
3579 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3581 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3582 imm:$src3))]>, OpSize;
3586 defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3588 let Constraints = "$src1 = $dst" in {
3589 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
3590 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3591 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
3592 !strconcat(OpcodeStr,
3593 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3595 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3597 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3598 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3599 !strconcat(OpcodeStr,
3600 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3602 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3603 imm:$src3)))]>, OpSize;
3607 defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3609 // insertps has a few different modes, there's the first two here below which
3610 // are optimized inserts that won't zero arbitrary elements in the destination
3611 // vector. The next one matches the intrinsic and could zero arbitrary elements
3612 // in the target vector.
3613 let Constraints = "$src1 = $dst" in {
3614 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
3615 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3616 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3617 !strconcat(OpcodeStr,
3618 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3620 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
3622 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3623 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3624 !strconcat(OpcodeStr,
3625 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3627 (X86insrtps VR128:$src1,
3628 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
3629 imm:$src3))]>, OpSize;
3633 defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
3635 def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3636 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3638 // ptest instruction we'll lower to this in X86ISelLowering primarily from
3639 // the intel intrinsic that corresponds to this.
3640 let Defs = [EFLAGS] in {
3641 def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
3642 "ptest \t{$src2, $src1|$src1, $src2}",
3643 [(X86ptest VR128:$src1, VR128:$src2),
3644 (implicit EFLAGS)]>, OpSize;
3645 def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
3646 "ptest \t{$src2, $src1|$src1, $src2}",
3647 [(X86ptest VR128:$src1, (load addr:$src2)),
3648 (implicit EFLAGS)]>, OpSize;
3651 def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3652 "movntdqa\t{$src, $dst|$dst, $src}",
3653 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>;
3655 /// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3656 let Constraints = "$src1 = $dst" in {
3657 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3658 Intrinsic IntId128, bit Commutable = 0> {
3659 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3660 (ins VR128:$src1, VR128:$src2),
3661 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3662 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3664 let isCommutable = Commutable;
3666 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3667 (ins VR128:$src1, i128mem:$src2),
3668 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3670 (IntId128 VR128:$src1,
3671 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3675 defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
3677 def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3678 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3679 def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3680 (PCMPGTQrm VR128:$src1, addr:$src2)>;