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 scalar FP Instructions
19 //===----------------------------------------------------------------------===//
21 // CMOV* - Used to implement the SSE SELECT DAG operation. Expanded after
22 // instruction selection into a branch sequence.
23 let Uses = [EFLAGS], usesCustomInserter = 1 in {
24 def CMOV_FR32 : I<0, Pseudo,
25 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
27 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
29 def CMOV_FR64 : I<0, Pseudo,
30 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
32 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
34 def CMOV_V4F32 : I<0, Pseudo,
35 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
36 "#CMOV_V4F32 PSEUDO!",
38 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
40 def CMOV_V2F64 : I<0, Pseudo,
41 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
42 "#CMOV_V2F64 PSEUDO!",
44 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
46 def CMOV_V2I64 : I<0, Pseudo,
47 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
48 "#CMOV_V2I64 PSEUDO!",
50 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
54 //===----------------------------------------------------------------------===//
55 // SSE 1 & 2 Instructions Classes
56 //===----------------------------------------------------------------------===//
58 /// sse12_fp_scalar - SSE 1 & 2 scalar instructions class
59 multiclass sse12_fp_scalar<bits<8> opc, string OpcodeStr, SDNode OpNode,
60 RegisterClass RC, X86MemOperand x86memop,
62 let isCommutable = 1 in {
63 def rr : SI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
65 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
66 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
67 [(set RC:$dst, (OpNode RC:$src1, RC:$src2))]>;
69 def rm : SI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, x86memop:$src2),
71 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
72 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
73 [(set RC:$dst, (OpNode RC:$src1, (load addr:$src2)))]>;
76 /// sse12_fp_scalar_int - SSE 1 & 2 scalar instructions intrinsics class
77 multiclass sse12_fp_scalar_int<bits<8> opc, string OpcodeStr, RegisterClass RC,
78 string asm, string SSEVer, string FPSizeStr,
79 Operand memopr, ComplexPattern mem_cpat,
81 def rr_Int : SI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
83 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
84 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
85 [(set RC:$dst, (!nameconcat<Intrinsic>("int_x86_sse",
86 !strconcat(SSEVer, !strconcat("_",
87 !strconcat(OpcodeStr, FPSizeStr))))
88 RC:$src1, RC:$src2))]>;
89 def rm_Int : SI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, memopr:$src2),
91 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
92 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
93 [(set RC:$dst, (!nameconcat<Intrinsic>("int_x86_sse",
94 !strconcat(SSEVer, !strconcat("_",
95 !strconcat(OpcodeStr, FPSizeStr))))
96 RC:$src1, mem_cpat:$src2))]>;
99 /// sse12_fp_packed - SSE 1 & 2 packed instructions class
100 multiclass sse12_fp_packed<bits<8> opc, string OpcodeStr, SDNode OpNode,
101 RegisterClass RC, ValueType vt,
102 X86MemOperand x86memop, PatFrag mem_frag,
103 Domain d, bit Is2Addr = 1> {
104 let isCommutable = 1 in
105 def rr : PI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
107 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
108 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
109 [(set RC:$dst, (vt (OpNode RC:$src1, RC:$src2)))], d>;
111 def rm : PI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, x86memop:$src2),
113 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
114 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
115 [(set RC:$dst, (OpNode RC:$src1, (mem_frag addr:$src2)))], d>;
118 /// sse12_fp_packed_logical_rm - SSE 1 & 2 packed instructions class
119 multiclass sse12_fp_packed_logical_rm<bits<8> opc, RegisterClass RC, Domain d,
120 string OpcodeStr, X86MemOperand x86memop,
121 list<dag> pat_rr, list<dag> pat_rm,
123 let isCommutable = 1 in
124 def rr : PI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
126 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
127 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
129 def rm : PI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, x86memop:$src2),
131 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
132 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
136 /// sse12_fp_packed_int - SSE 1 & 2 packed instructions intrinsics class
137 multiclass sse12_fp_packed_int<bits<8> opc, string OpcodeStr, RegisterClass RC,
138 string asm, string SSEVer, string FPSizeStr,
139 X86MemOperand x86memop, PatFrag mem_frag,
140 Domain d, bit Is2Addr = 1> {
141 def rr_Int : PI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
143 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
144 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
145 [(set RC:$dst, (!nameconcat<Intrinsic>("int_x86_sse",
146 !strconcat(SSEVer, !strconcat("_",
147 !strconcat(OpcodeStr, FPSizeStr))))
148 RC:$src1, RC:$src2))], d>;
149 def rm_Int : PI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1,x86memop:$src2),
151 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
152 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
153 [(set RC:$dst, (!nameconcat<Intrinsic>("int_x86_sse",
154 !strconcat(SSEVer, !strconcat("_",
155 !strconcat(OpcodeStr, FPSizeStr))))
156 RC:$src1, (mem_frag addr:$src2)))], d>;
159 //===----------------------------------------------------------------------===//
160 // SSE 1 & 2 - Move Instructions
161 //===----------------------------------------------------------------------===//
163 class sse12_move_rr<RegisterClass RC, ValueType vt, string asm> :
164 SI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, RC:$src2), asm,
165 [(set (vt VR128:$dst), (movl VR128:$src1, (scalar_to_vector RC:$src2)))]>;
167 // Loading from memory automatically zeroing upper bits.
168 class sse12_move_rm<RegisterClass RC, X86MemOperand x86memop,
169 PatFrag mem_pat, string OpcodeStr> :
170 SI<0x10, MRMSrcMem, (outs RC:$dst), (ins x86memop:$src),
171 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
172 [(set RC:$dst, (mem_pat addr:$src))]>;
174 // Move Instructions. Register-to-register movss/movsd is not used for FR32/64
175 // register copies because it's a partial register update; FsMOVAPSrr/FsMOVAPDrr
176 // is used instead. Register-to-register movss/movsd is not modeled as an
177 // INSERT_SUBREG because INSERT_SUBREG requires that the insert be implementable
178 // in terms of a copy, and just mentioned, we don't use movss/movsd for copies.
179 let isAsmParserOnly = 1 in {
180 def VMOVSSrr : sse12_move_rr<FR32, v4f32,
181 "movss\t{$src2, $src1, $dst|$dst, $src1, $src2}">, XS, VEX_4V;
182 def VMOVSDrr : sse12_move_rr<FR64, v2f64,
183 "movsd\t{$src2, $src1, $dst|$dst, $src1, $src2}">, XD, VEX_4V;
185 let canFoldAsLoad = 1, isReMaterializable = 1 in {
186 def VMOVSSrm : sse12_move_rm<FR32, f32mem, loadf32, "movss">, XS, VEX;
188 let AddedComplexity = 20 in
189 def VMOVSDrm : sse12_move_rm<FR64, f64mem, loadf64, "movsd">, XD, VEX;
193 let Constraints = "$src1 = $dst" in {
194 def MOVSSrr : sse12_move_rr<FR32, v4f32,
195 "movss\t{$src2, $dst|$dst, $src2}">, XS;
196 def MOVSDrr : sse12_move_rr<FR64, v2f64,
197 "movsd\t{$src2, $dst|$dst, $src2}">, XD;
200 let canFoldAsLoad = 1, isReMaterializable = 1 in {
201 def MOVSSrm : sse12_move_rm<FR32, f32mem, loadf32, "movss">, XS;
203 let AddedComplexity = 20 in
204 def MOVSDrm : sse12_move_rm<FR64, f64mem, loadf64, "movsd">, XD;
207 let AddedComplexity = 15 in {
208 // Extract the low 32-bit value from one vector and insert it into another.
209 def : Pat<(v4f32 (movl VR128:$src1, VR128:$src2)),
210 (MOVSSrr (v4f32 VR128:$src1),
211 (EXTRACT_SUBREG (v4f32 VR128:$src2), sub_ss))>;
212 // Extract the low 64-bit value from one vector and insert it into another.
213 def : Pat<(v2f64 (movl VR128:$src1, VR128:$src2)),
214 (MOVSDrr (v2f64 VR128:$src1),
215 (EXTRACT_SUBREG (v2f64 VR128:$src2), sub_sd))>;
218 // Implicitly promote a 32-bit scalar to a vector.
219 def : Pat<(v4f32 (scalar_to_vector FR32:$src)),
220 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FR32:$src, sub_ss)>;
221 // Implicitly promote a 64-bit scalar to a vector.
222 def : Pat<(v2f64 (scalar_to_vector FR64:$src)),
223 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FR64:$src, sub_sd)>;
225 let AddedComplexity = 20 in {
226 // MOVSSrm zeros the high parts of the register; represent this
227 // with SUBREG_TO_REG.
228 def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector (loadf32 addr:$src))))),
229 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), sub_ss)>;
230 def : Pat<(v4f32 (scalar_to_vector (loadf32 addr:$src))),
231 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), sub_ss)>;
232 def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
233 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), sub_ss)>;
234 // MOVSDrm zeros the high parts of the register; represent this
235 // with SUBREG_TO_REG.
236 def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector (loadf64 addr:$src))))),
237 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
238 def : Pat<(v2f64 (scalar_to_vector (loadf64 addr:$src))),
239 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
240 def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
241 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
242 def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
243 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
244 def : Pat<(v2f64 (X86vzload addr:$src)),
245 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
248 // Store scalar value to memory.
249 def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
250 "movss\t{$src, $dst|$dst, $src}",
251 [(store FR32:$src, addr:$dst)]>;
252 def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
253 "movsd\t{$src, $dst|$dst, $src}",
254 [(store FR64:$src, addr:$dst)]>;
256 let isAsmParserOnly = 1 in {
257 def VMOVSSmr : SI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
258 "movss\t{$src, $dst|$dst, $src}",
259 [(store FR32:$src, addr:$dst)]>, XS, VEX_4V;
260 def VMOVSDmr : SI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
261 "movsd\t{$src, $dst|$dst, $src}",
262 [(store FR64:$src, addr:$dst)]>, XD, VEX_4V;
265 // Extract and store.
266 def : Pat<(store (f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
269 (EXTRACT_SUBREG (v4f32 VR128:$src), sub_ss))>;
270 def : Pat<(store (f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
273 (EXTRACT_SUBREG (v2f64 VR128:$src), sub_sd))>;
275 // Move Aligned/Unaligned floating point values
276 multiclass sse12_mov_packed<bits<8> opc, RegisterClass RC,
277 X86MemOperand x86memop, PatFrag ld_frag,
278 string asm, Domain d,
279 bit IsReMaterializable = 1> {
280 let neverHasSideEffects = 1 in
281 def rr : PI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src),
282 !strconcat(asm, "\t{$src, $dst|$dst, $src}"), [], d>;
283 let canFoldAsLoad = 1, isReMaterializable = IsReMaterializable in
284 def rm : PI<opc, MRMSrcMem, (outs RC:$dst), (ins x86memop:$src),
285 !strconcat(asm, "\t{$src, $dst|$dst, $src}"),
286 [(set RC:$dst, (ld_frag addr:$src))], d>;
289 let isAsmParserOnly = 1 in {
290 defm VMOVAPS : sse12_mov_packed<0x28, VR128, f128mem, alignedloadv4f32,
291 "movaps", SSEPackedSingle>, VEX;
292 defm VMOVAPD : sse12_mov_packed<0x28, VR128, f128mem, alignedloadv2f64,
293 "movapd", SSEPackedDouble>, OpSize, VEX;
294 defm VMOVUPS : sse12_mov_packed<0x10, VR128, f128mem, loadv4f32,
295 "movups", SSEPackedSingle>, VEX;
296 defm VMOVUPD : sse12_mov_packed<0x10, VR128, f128mem, loadv2f64,
297 "movupd", SSEPackedDouble, 0>, OpSize, VEX;
299 defm VMOVAPSY : sse12_mov_packed<0x28, VR256, f256mem, alignedloadv8f32,
300 "movaps", SSEPackedSingle>, VEX;
301 defm VMOVAPDY : sse12_mov_packed<0x28, VR256, f256mem, alignedloadv4f64,
302 "movapd", SSEPackedDouble>, OpSize, VEX;
303 defm VMOVUPSY : sse12_mov_packed<0x10, VR256, f256mem, loadv8f32,
304 "movups", SSEPackedSingle>, VEX;
305 defm VMOVUPDY : sse12_mov_packed<0x10, VR256, f256mem, loadv4f64,
306 "movupd", SSEPackedDouble, 0>, OpSize, VEX;
308 defm MOVAPS : sse12_mov_packed<0x28, VR128, f128mem, alignedloadv4f32,
309 "movaps", SSEPackedSingle>, TB;
310 defm MOVAPD : sse12_mov_packed<0x28, VR128, f128mem, alignedloadv2f64,
311 "movapd", SSEPackedDouble>, TB, OpSize;
312 defm MOVUPS : sse12_mov_packed<0x10, VR128, f128mem, loadv4f32,
313 "movups", SSEPackedSingle>, TB;
314 defm MOVUPD : sse12_mov_packed<0x10, VR128, f128mem, loadv2f64,
315 "movupd", SSEPackedDouble, 0>, TB, OpSize;
317 let isAsmParserOnly = 1 in {
318 def VMOVAPSmr : VPSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
319 "movaps\t{$src, $dst|$dst, $src}",
320 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>, VEX;
321 def VMOVAPDmr : VPDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
322 "movapd\t{$src, $dst|$dst, $src}",
323 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>, VEX;
324 def VMOVUPSmr : VPSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
325 "movups\t{$src, $dst|$dst, $src}",
326 [(store (v4f32 VR128:$src), addr:$dst)]>, VEX;
327 def VMOVUPDmr : VPDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
328 "movupd\t{$src, $dst|$dst, $src}",
329 [(store (v2f64 VR128:$src), addr:$dst)]>, VEX;
330 def VMOVAPSYmr : VPSI<0x29, MRMDestMem, (outs), (ins f256mem:$dst, VR256:$src),
331 "movaps\t{$src, $dst|$dst, $src}",
332 [(alignedstore (v8f32 VR256:$src), addr:$dst)]>, VEX;
333 def VMOVAPDYmr : VPDI<0x29, MRMDestMem, (outs), (ins f256mem:$dst, VR256:$src),
334 "movapd\t{$src, $dst|$dst, $src}",
335 [(alignedstore (v4f64 VR256:$src), addr:$dst)]>, VEX;
336 def VMOVUPSYmr : VPSI<0x11, MRMDestMem, (outs), (ins f256mem:$dst, VR256:$src),
337 "movups\t{$src, $dst|$dst, $src}",
338 [(store (v8f32 VR256:$src), addr:$dst)]>, VEX;
339 def VMOVUPDYmr : VPDI<0x11, MRMDestMem, (outs), (ins f256mem:$dst, VR256:$src),
340 "movupd\t{$src, $dst|$dst, $src}",
341 [(store (v4f64 VR256:$src), addr:$dst)]>, VEX;
343 def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
344 "movaps\t{$src, $dst|$dst, $src}",
345 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
346 def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
347 "movapd\t{$src, $dst|$dst, $src}",
348 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
349 def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
350 "movups\t{$src, $dst|$dst, $src}",
351 [(store (v4f32 VR128:$src), addr:$dst)]>;
352 def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
353 "movupd\t{$src, $dst|$dst, $src}",
354 [(store (v2f64 VR128:$src), addr:$dst)]>;
356 // Intrinsic forms of MOVUPS/D load and store
357 let isAsmParserOnly = 1 in {
358 let canFoldAsLoad = 1, isReMaterializable = 1 in
359 def VMOVUPSrm_Int : VPSI<0x10, MRMSrcMem, (outs VR128:$dst),
361 "movups\t{$src, $dst|$dst, $src}",
362 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>, VEX;
363 def VMOVUPDrm_Int : VPDI<0x10, MRMSrcMem, (outs VR128:$dst),
365 "movupd\t{$src, $dst|$dst, $src}",
366 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>, VEX;
367 def VMOVUPSmr_Int : VPSI<0x11, MRMDestMem, (outs),
368 (ins f128mem:$dst, VR128:$src),
369 "movups\t{$src, $dst|$dst, $src}",
370 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>, VEX;
371 def VMOVUPDmr_Int : VPDI<0x11, MRMDestMem, (outs),
372 (ins f128mem:$dst, VR128:$src),
373 "movupd\t{$src, $dst|$dst, $src}",
374 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>, VEX;
376 let canFoldAsLoad = 1, isReMaterializable = 1 in
377 def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
378 "movups\t{$src, $dst|$dst, $src}",
379 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
380 def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
381 "movupd\t{$src, $dst|$dst, $src}",
382 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
384 def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
385 "movups\t{$src, $dst|$dst, $src}",
386 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
387 def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
388 "movupd\t{$src, $dst|$dst, $src}",
389 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
391 // Move Low/High packed floating point values
392 multiclass sse12_mov_hilo_packed<bits<8>opc, RegisterClass RC,
393 PatFrag mov_frag, string base_opc,
395 def PSrm : PI<opc, MRMSrcMem,
396 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
397 !strconcat(!strconcat(base_opc,"s"), asm_opr),
400 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))],
401 SSEPackedSingle>, TB;
403 def PDrm : PI<opc, MRMSrcMem,
404 (outs RC:$dst), (ins RC:$src1, f64mem:$src2),
405 !strconcat(!strconcat(base_opc,"d"), asm_opr),
406 [(set RC:$dst, (v2f64 (mov_frag RC:$src1,
407 (scalar_to_vector (loadf64 addr:$src2)))))],
408 SSEPackedDouble>, TB, OpSize;
411 let isAsmParserOnly = 1, AddedComplexity = 20 in {
412 defm VMOVL : sse12_mov_hilo_packed<0x12, VR128, movlp, "movlp",
413 "\t{$src2, $src1, $dst|$dst, $src1, $src2}">, VEX_4V;
414 defm VMOVH : sse12_mov_hilo_packed<0x16, VR128, movlhps, "movhp",
415 "\t{$src2, $src1, $dst|$dst, $src1, $src2}">, VEX_4V;
417 let Constraints = "$src1 = $dst", AddedComplexity = 20 in {
418 defm MOVL : sse12_mov_hilo_packed<0x12, VR128, movlp, "movlp",
419 "\t{$src2, $dst|$dst, $src2}">;
420 defm MOVH : sse12_mov_hilo_packed<0x16, VR128, movlhps, "movhp",
421 "\t{$src2, $dst|$dst, $src2}">;
424 let isAsmParserOnly = 1 in {
425 def VMOVLPSmr : VPSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
426 "movlps\t{$src, $dst|$dst, $src}",
427 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
428 (iPTR 0))), addr:$dst)]>, VEX;
429 def VMOVLPDmr : VPDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
430 "movlpd\t{$src, $dst|$dst, $src}",
431 [(store (f64 (vector_extract (v2f64 VR128:$src),
432 (iPTR 0))), addr:$dst)]>, VEX;
434 def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
435 "movlps\t{$src, $dst|$dst, $src}",
436 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
437 (iPTR 0))), addr:$dst)]>;
438 def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
439 "movlpd\t{$src, $dst|$dst, $src}",
440 [(store (f64 (vector_extract (v2f64 VR128:$src),
441 (iPTR 0))), addr:$dst)]>;
443 // v2f64 extract element 1 is always custom lowered to unpack high to low
444 // and extract element 0 so the non-store version isn't too horrible.
445 let isAsmParserOnly = 1 in {
446 def VMOVHPSmr : VPSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
447 "movhps\t{$src, $dst|$dst, $src}",
448 [(store (f64 (vector_extract
449 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
450 (undef)), (iPTR 0))), addr:$dst)]>,
452 def VMOVHPDmr : VPDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
453 "movhpd\t{$src, $dst|$dst, $src}",
454 [(store (f64 (vector_extract
455 (v2f64 (unpckh VR128:$src, (undef))),
456 (iPTR 0))), addr:$dst)]>,
459 def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
460 "movhps\t{$src, $dst|$dst, $src}",
461 [(store (f64 (vector_extract
462 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
463 (undef)), (iPTR 0))), addr:$dst)]>;
464 def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
465 "movhpd\t{$src, $dst|$dst, $src}",
466 [(store (f64 (vector_extract
467 (v2f64 (unpckh VR128:$src, (undef))),
468 (iPTR 0))), addr:$dst)]>;
470 let isAsmParserOnly = 1, AddedComplexity = 20 in {
471 def VMOVLHPSrr : VPSI<0x16, MRMSrcReg, (outs VR128:$dst),
472 (ins VR128:$src1, VR128:$src2),
473 "movlhps\t{$src2, $src1, $dst|$dst, $src1, $src2}",
475 (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>,
477 def VMOVHLPSrr : VPSI<0x12, MRMSrcReg, (outs VR128:$dst),
478 (ins VR128:$src1, VR128:$src2),
479 "movhlps\t{$src2, $src1, $dst|$dst, $src1, $src2}",
481 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>,
484 let Constraints = "$src1 = $dst", AddedComplexity = 20 in {
485 def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
486 (ins VR128:$src1, VR128:$src2),
487 "movlhps\t{$src2, $dst|$dst, $src2}",
489 (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>;
490 def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
491 (ins VR128:$src1, VR128:$src2),
492 "movhlps\t{$src2, $dst|$dst, $src2}",
494 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
497 def : Pat<(movlhps VR128:$src1, (bc_v4i32 (v2i64 (X86vzload addr:$src2)))),
498 (MOVHPSrm (v4i32 VR128:$src1), addr:$src2)>;
499 let AddedComplexity = 20 in {
500 def : Pat<(v4f32 (movddup VR128:$src, (undef))),
501 (MOVLHPSrr (v4f32 VR128:$src), (v4f32 VR128:$src))>;
502 def : Pat<(v2i64 (movddup VR128:$src, (undef))),
503 (MOVLHPSrr (v2i64 VR128:$src), (v2i64 VR128:$src))>;
506 //===----------------------------------------------------------------------===//
507 // SSE 1 & 2 - Conversion Instructions
508 //===----------------------------------------------------------------------===//
510 multiclass sse12_cvt_s<bits<8> opc, RegisterClass SrcRC, RegisterClass DstRC,
511 SDNode OpNode, X86MemOperand x86memop, PatFrag ld_frag,
513 def rr : SI<opc, MRMSrcReg, (outs DstRC:$dst), (ins SrcRC:$src), asm,
514 [(set DstRC:$dst, (OpNode SrcRC:$src))]>;
515 def rm : SI<opc, MRMSrcMem, (outs DstRC:$dst), (ins x86memop:$src), asm,
516 [(set DstRC:$dst, (OpNode (ld_frag addr:$src)))]>;
519 multiclass sse12_cvt_p<bits<8> opc, RegisterClass SrcRC, RegisterClass DstRC,
520 SDNode OpNode, X86MemOperand x86memop, PatFrag ld_frag,
521 string asm, Domain d> {
522 def rr : PI<opc, MRMSrcReg, (outs DstRC:$dst), (ins SrcRC:$src), asm,
523 [(set DstRC:$dst, (OpNode SrcRC:$src))], d>;
524 def rm : PI<opc, MRMSrcMem, (outs DstRC:$dst), (ins x86memop:$src), asm,
525 [(set DstRC:$dst, (OpNode (ld_frag addr:$src)))], d>;
528 multiclass sse12_vcvt_avx<bits<8> opc, RegisterClass SrcRC, RegisterClass DstRC,
529 SDNode OpNode, X86MemOperand x86memop, PatFrag ld_frag,
531 def rr : SI<opc, MRMSrcReg, (outs DstRC:$dst), (ins DstRC:$src1, SrcRC:$src),
533 def rm : SI<opc, MRMSrcMem, (outs DstRC:$dst),
534 (ins DstRC:$src1, x86memop:$src), asm, []>;
537 let isAsmParserOnly = 1 in {
538 defm VCVTTSS2SI : sse12_cvt_s<0x2C, FR32, GR32, fp_to_sint, f32mem, loadf32,
539 "cvttss2si\t{$src, $dst|$dst, $src}">, XS, VEX;
540 defm VCVTTSD2SI : sse12_cvt_s<0x2C, FR64, GR32, fp_to_sint, f64mem, loadf64,
541 "cvttsd2si\t{$src, $dst|$dst, $src}">, XD, VEX;
542 defm VCVTSI2SS : sse12_vcvt_avx<0x2A, GR32, FR32, sint_to_fp, i32mem, loadi32,
543 "cvtsi2ss\t{$src, $src1, $dst|$dst, $src1, $src}">, XS,
545 defm VCVTSI2SD : sse12_vcvt_avx<0x2A, GR32, FR64, sint_to_fp, i32mem, loadi32,
546 "cvtsi2sd\t{$src, $src1, $dst|$dst, $src1, $src}">, XD,
550 defm CVTTSS2SI : sse12_cvt_s<0x2C, FR32, GR32, fp_to_sint, f32mem, loadf32,
551 "cvttss2si\t{$src, $dst|$dst, $src}">, XS;
552 defm CVTTSD2SI : sse12_cvt_s<0x2C, FR64, GR32, fp_to_sint, f64mem, loadf64,
553 "cvttsd2si\t{$src, $dst|$dst, $src}">, XD;
554 defm CVTSI2SS : sse12_cvt_s<0x2A, GR32, FR32, sint_to_fp, i32mem, loadi32,
555 "cvtsi2ss\t{$src, $dst|$dst, $src}">, XS;
556 defm CVTSI2SD : sse12_cvt_s<0x2A, GR32, FR64, sint_to_fp, i32mem, loadi32,
557 "cvtsi2sd\t{$src, $dst|$dst, $src}">, XD;
559 // Conversion Instructions Intrinsics - Match intrinsics which expect MM
560 // and/or XMM operand(s).
561 multiclass sse12_cvt_pint<bits<8> opc, RegisterClass SrcRC, RegisterClass DstRC,
562 Intrinsic Int, X86MemOperand x86memop, PatFrag ld_frag,
563 string asm, Domain d> {
564 def rr : PI<opc, MRMSrcReg, (outs DstRC:$dst), (ins SrcRC:$src), asm,
565 [(set DstRC:$dst, (Int SrcRC:$src))], d>;
566 def rm : PI<opc, MRMSrcMem, (outs DstRC:$dst), (ins x86memop:$src), asm,
567 [(set DstRC:$dst, (Int (ld_frag addr:$src)))], d>;
570 multiclass sse12_cvt_sint<bits<8> opc, RegisterClass SrcRC, RegisterClass DstRC,
571 Intrinsic Int, X86MemOperand x86memop, PatFrag ld_frag,
573 def rr : SI<opc, MRMSrcReg, (outs DstRC:$dst), (ins SrcRC:$src), asm,
574 [(set DstRC:$dst, (Int SrcRC:$src))]>;
575 def rm : SI<opc, MRMSrcMem, (outs DstRC:$dst), (ins x86memop:$src), asm,
576 [(set DstRC:$dst, (Int (ld_frag addr:$src)))]>;
579 multiclass sse12_cvt_pint_3addr<bits<8> opc, RegisterClass SrcRC,
580 RegisterClass DstRC, Intrinsic Int, X86MemOperand x86memop,
581 PatFrag ld_frag, string asm, Domain d> {
582 def rr : PI<opc, MRMSrcReg, (outs DstRC:$dst), (ins DstRC:$src1, SrcRC:$src2),
583 asm, [(set DstRC:$dst, (Int DstRC:$src1, SrcRC:$src2))], d>;
584 def rm : PI<opc, MRMSrcMem, (outs DstRC:$dst),
585 (ins DstRC:$src1, x86memop:$src2), asm,
586 [(set DstRC:$dst, (Int DstRC:$src1, (ld_frag addr:$src2)))], d>;
589 multiclass sse12_cvt_sint_3addr<bits<8> opc, RegisterClass SrcRC,
590 RegisterClass DstRC, Intrinsic Int, X86MemOperand x86memop,
591 PatFrag ld_frag, string asm> {
592 def rr : SI<opc, MRMSrcReg, (outs DstRC:$dst), (ins DstRC:$src1, SrcRC:$src2),
593 asm, [(set DstRC:$dst, (Int DstRC:$src1, SrcRC:$src2))]>;
594 def rm : SI<opc, MRMSrcMem, (outs DstRC:$dst),
595 (ins DstRC:$src1, x86memop:$src2), asm,
596 [(set DstRC:$dst, (Int DstRC:$src1, (ld_frag addr:$src2)))]>;
599 let isAsmParserOnly = 1 in {
600 defm Int_VCVTSS2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse_cvtss2si,
601 f32mem, load, "cvtss2si\t{$src, $dst|$dst, $src}">, XS,
603 defm Int_VCVTSD2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse2_cvtsd2si,
604 f128mem, load, "cvtsd2si\t{$src, $dst|$dst, $src}">, XD,
607 defm Int_CVTSS2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse_cvtss2si,
608 f32mem, load, "cvtss2si\t{$src, $dst|$dst, $src}">, XS;
609 defm Int_CVTSD2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse2_cvtsd2si,
610 f128mem, load, "cvtsd2si\t{$src, $dst|$dst, $src}">, XD;
613 let Constraints = "$src1 = $dst" in {
614 defm Int_CVTSI2SS : sse12_cvt_sint_3addr<0x2A, GR32, VR128,
615 int_x86_sse_cvtsi2ss, i32mem, loadi32,
616 "cvtsi2ss\t{$src2, $dst|$dst, $src2}">, XS;
617 defm Int_CVTSI2SD : sse12_cvt_sint_3addr<0x2A, GR32, VR128,
618 int_x86_sse2_cvtsi2sd, i32mem, loadi32,
619 "cvtsi2ss\t{$src2, $dst|$dst, $src2}">, XD;
622 // Instructions below don't have an AVX form.
623 defm Int_CVTPS2PI : sse12_cvt_pint<0x2D, VR128, VR64, int_x86_sse_cvtps2pi,
624 f64mem, load, "cvtps2pi\t{$src, $dst|$dst, $src}",
625 SSEPackedSingle>, TB;
626 defm Int_CVTPD2PI : sse12_cvt_pint<0x2D, VR128, VR64, int_x86_sse_cvtpd2pi,
627 f128mem, memop, "cvtpd2pi\t{$src, $dst|$dst, $src}",
628 SSEPackedDouble>, TB, OpSize;
629 defm Int_CVTTPS2PI : sse12_cvt_pint<0x2C, VR128, VR64, int_x86_sse_cvttps2pi,
630 f64mem, load, "cvttps2pi\t{$src, $dst|$dst, $src}",
631 SSEPackedSingle>, TB;
632 defm Int_CVTTPD2PI : sse12_cvt_pint<0x2C, VR128, VR64, int_x86_sse_cvttpd2pi,
633 f128mem, memop, "cvttpd2pi\t{$src, $dst|$dst, $src}",
634 SSEPackedDouble>, TB, OpSize;
635 defm Int_CVTPI2PD : sse12_cvt_pint<0x2A, VR64, VR128, int_x86_sse_cvtpi2pd,
636 i64mem, load, "cvtpi2pd\t{$src, $dst|$dst, $src}",
637 SSEPackedDouble>, TB, OpSize;
638 let Constraints = "$src1 = $dst" in {
639 defm Int_CVTPI2PS : sse12_cvt_pint_3addr<0x2A, VR64, VR128,
640 int_x86_sse_cvtpi2ps,
641 i64mem, load, "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
642 SSEPackedSingle>, TB;
647 // Aliases for intrinsics
648 let isAsmParserOnly = 1, Pattern = []<dag> in {
649 defm Int_VCVTTSS2SI : sse12_cvt_sint_3addr<0x2C, VR128, GR32,
650 int_x86_sse_cvttss2si, f32mem, load,
651 "cvttss2si\t{$src2, $src1, $dst|$dst, $src1, $src2}">, XS;
652 defm Int_VCVTTSD2SI : sse12_cvt_sint_3addr<0x2C, VR128, GR32,
653 int_x86_sse2_cvttsd2si, f128mem, load,
654 "cvttss2si\t{$src2, $src1, $dst|$dst, $src1, $src2}">, XD;
656 defm Int_CVTTSS2SI : sse12_cvt_sint<0x2C, VR128, GR32, int_x86_sse_cvttss2si,
657 f32mem, load, "cvttss2si\t{$src, $dst|$dst, $src}">,
659 defm Int_CVTTSD2SI : sse12_cvt_sint<0x2C, VR128, GR32, int_x86_sse2_cvttsd2si,
660 f128mem, load, "cvttss2si\t{$src, $dst|$dst, $src}">,
663 let isAsmParserOnly = 1, Pattern = []<dag> in {
664 defm VCVTSS2SI : sse12_cvt_s<0x2D, FR32, GR32, undef, f32mem, load,
665 "cvtss2si{l}\t{$src, $dst|$dst, $src}">, XS, VEX;
666 defm VCVTDQ2PS : sse12_cvt_p<0x5B, VR128, VR128, undef, f128mem, load,
667 "cvtdq2ps\t{$src, $dst|$dst, $src}",
668 SSEPackedSingle>, TB, VEX;
670 let Pattern = []<dag> in {
671 defm CVTSS2SI : sse12_cvt_s<0x2D, FR32, GR32, undef, f32mem, load /*dummy*/,
672 "cvtss2si{l}\t{$src, $dst|$dst, $src}">, XS;
673 defm CVTDQ2PS : sse12_cvt_p<0x5B, VR128, VR128, undef, f128mem, load /*dummy*/,
674 "cvtdq2ps\t{$src, $dst|$dst, $src}",
675 SSEPackedSingle>, TB; /* PD SSE3 form is avaiable */
680 // Convert scalar double to scalar single
681 let isAsmParserOnly = 1 in {
682 def VCVTSD2SSrr : VSDI<0x5A, MRMSrcReg, (outs FR32:$dst),
683 (ins FR64:$src1, FR64:$src2),
684 "cvtsd2ss\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>,
686 def VCVTSD2SSrm : I<0x5A, MRMSrcMem, (outs FR32:$dst),
687 (ins FR64:$src1, f64mem:$src2),
688 "vcvtsd2ss\t{$src2, $src1, $dst|$dst, $src1, $src2}",
689 []>, XD, Requires<[HasAVX, OptForSize]>, VEX_4V;
691 def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
692 "cvtsd2ss\t{$src, $dst|$dst, $src}",
693 [(set FR32:$dst, (fround FR64:$src))]>;
694 def CVTSD2SSrm : I<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
695 "cvtsd2ss\t{$src, $dst|$dst, $src}",
696 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>, XD,
697 Requires<[HasSSE2, OptForSize]>;
699 let isAsmParserOnly = 1 in
700 defm Int_VCVTSD2SS: sse12_cvt_sint_3addr<0x5A, VR128, VR128,
701 int_x86_sse2_cvtsd2ss, f64mem, load,
702 "cvtsd2ss\t{$src2, $src1, $dst|$dst, $src1, $src2}">,
704 let Constraints = "$src1 = $dst" in
705 defm Int_CVTSD2SS: sse12_cvt_sint_3addr<0x5A, VR128, VR128,
706 int_x86_sse2_cvtsd2ss, f64mem, load,
707 "cvtsd2ss\t{$src2, $dst|$dst, $src2}">, XS;
709 // Convert scalar single to scalar double
710 let isAsmParserOnly = 1 in { // SSE2 instructions with XS prefix
711 def VCVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst),
712 (ins FR32:$src1, FR32:$src2),
713 "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
714 []>, XS, Requires<[HasAVX]>, VEX_4V;
715 def VCVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst),
716 (ins FR32:$src1, f32mem:$src2),
717 "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
718 []>, XS, VEX_4V, Requires<[HasAVX, OptForSize]>;
720 def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
721 "cvtss2sd\t{$src, $dst|$dst, $src}",
722 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
724 def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
725 "cvtss2sd\t{$src, $dst|$dst, $src}",
726 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
727 Requires<[HasSSE2, OptForSize]>;
729 let isAsmParserOnly = 1 in {
730 def Int_VCVTSS2SDrr: I<0x5A, MRMSrcReg,
731 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
732 "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
733 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
734 VR128:$src2))]>, XS, VEX_4V,
736 def Int_VCVTSS2SDrm: I<0x5A, MRMSrcMem,
737 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
738 "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
739 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
740 (load addr:$src2)))]>, XS, VEX_4V,
743 let Constraints = "$src1 = $dst" in { // SSE2 instructions with XS prefix
744 def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
745 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
746 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
747 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
750 def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
751 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
752 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
753 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
754 (load addr:$src2)))]>, XS,
758 def : Pat<(extloadf32 addr:$src),
759 (CVTSS2SDrr (MOVSSrm addr:$src))>,
760 Requires<[HasSSE2, OptForSpeed]>;
762 // Convert doubleword to packed single/double fp
763 let isAsmParserOnly = 1 in { // SSE2 instructions without OpSize prefix
764 def Int_VCVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
765 "vcvtdq2ps\t{$src, $dst|$dst, $src}",
766 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
767 TB, VEX, Requires<[HasAVX]>;
768 def Int_VCVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
769 "vcvtdq2ps\t{$src, $dst|$dst, $src}",
770 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
771 (bitconvert (memopv2i64 addr:$src))))]>,
772 TB, VEX, Requires<[HasAVX]>;
774 def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
775 "cvtdq2ps\t{$src, $dst|$dst, $src}",
776 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
777 TB, Requires<[HasSSE2]>;
778 def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
779 "cvtdq2ps\t{$src, $dst|$dst, $src}",
780 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
781 (bitconvert (memopv2i64 addr:$src))))]>,
782 TB, Requires<[HasSSE2]>;
784 // FIXME: why the non-intrinsic version is described as SSE3?
785 let isAsmParserOnly = 1 in { // SSE2 instructions with XS prefix
786 def Int_VCVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
787 "vcvtdq2pd\t{$src, $dst|$dst, $src}",
788 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
789 XS, VEX, Requires<[HasAVX]>;
790 def Int_VCVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
791 "vcvtdq2pd\t{$src, $dst|$dst, $src}",
792 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
793 (bitconvert (memopv2i64 addr:$src))))]>,
794 XS, VEX, Requires<[HasAVX]>;
796 def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
797 "cvtdq2pd\t{$src, $dst|$dst, $src}",
798 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
799 XS, Requires<[HasSSE2]>;
800 def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
801 "cvtdq2pd\t{$src, $dst|$dst, $src}",
802 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
803 (bitconvert (memopv2i64 addr:$src))))]>,
804 XS, Requires<[HasSSE2]>;
806 // Convert packed single/double fp to doubleword
807 let isAsmParserOnly = 1 in {
808 def VCVTPS2DQrr : VPDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
809 "cvtps2dq\t{$src, $dst|$dst, $src}", []>, VEX;
810 def VCVTPS2DQrm : VPDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
811 "cvtps2dq\t{$src, $dst|$dst, $src}", []>, VEX;
813 def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
814 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
815 def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
816 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
818 let isAsmParserOnly = 1 in {
819 def Int_VCVTPS2DQrr : VPDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
820 "cvtps2dq\t{$src, $dst|$dst, $src}",
821 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>,
823 def Int_VCVTPS2DQrm : VPDI<0x5B, MRMSrcMem, (outs VR128:$dst),
825 "cvtps2dq\t{$src, $dst|$dst, $src}",
826 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
827 (memop addr:$src)))]>, VEX;
829 def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
830 "cvtps2dq\t{$src, $dst|$dst, $src}",
831 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
832 def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
833 "cvtps2dq\t{$src, $dst|$dst, $src}",
834 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
835 (memop addr:$src)))]>;
837 let isAsmParserOnly = 1 in { // SSE2 packed instructions with XD prefix
838 def Int_VCVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
839 "vcvtpd2dq\t{$src, $dst|$dst, $src}",
840 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
841 XD, VEX, Requires<[HasAVX]>;
842 def Int_VCVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
843 "vcvtpd2dq\t{$src, $dst|$dst, $src}",
844 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
845 (memop addr:$src)))]>,
846 XD, VEX, Requires<[HasAVX]>;
848 def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
849 "cvtpd2dq\t{$src, $dst|$dst, $src}",
850 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
851 XD, Requires<[HasSSE2]>;
852 def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
853 "cvtpd2dq\t{$src, $dst|$dst, $src}",
854 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
855 (memop addr:$src)))]>,
856 XD, Requires<[HasSSE2]>;
859 // Convert with truncation packed single/double fp to doubleword
860 let isAsmParserOnly = 1 in { // SSE2 packed instructions with XS prefix
861 def VCVTTPS2DQrr : VSSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
862 "cvttps2dq\t{$src, $dst|$dst, $src}", []>, VEX;
863 def VCVTTPS2DQrm : VSSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
864 "cvttps2dq\t{$src, $dst|$dst, $src}", []>, VEX;
866 def CVTTPS2DQrr : SSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
867 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
868 def CVTTPS2DQrm : SSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
869 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
872 let isAsmParserOnly = 1 in {
873 def Int_VCVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
874 "vcvttps2dq\t{$src, $dst|$dst, $src}",
876 (int_x86_sse2_cvttps2dq VR128:$src))]>,
877 XS, VEX, Requires<[HasAVX]>;
878 def Int_VCVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
879 "vcvttps2dq\t{$src, $dst|$dst, $src}",
880 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
881 (memop addr:$src)))]>,
882 XS, VEX, Requires<[HasAVX]>;
884 def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
885 "cvttps2dq\t{$src, $dst|$dst, $src}",
887 (int_x86_sse2_cvttps2dq VR128:$src))]>,
888 XS, Requires<[HasSSE2]>;
889 def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
890 "cvttps2dq\t{$src, $dst|$dst, $src}",
891 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
892 (memop addr:$src)))]>,
893 XS, Requires<[HasSSE2]>;
895 let isAsmParserOnly = 1 in {
896 def Int_VCVTTPD2DQrr : VPDI<0xE6, MRMSrcReg, (outs VR128:$dst),
898 "cvttpd2dq\t{$src, $dst|$dst, $src}",
899 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>,
901 def Int_VCVTTPD2DQrm : VPDI<0xE6, MRMSrcMem, (outs VR128:$dst),
903 "cvttpd2dq\t{$src, $dst|$dst, $src}",
904 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
905 (memop addr:$src)))]>, VEX;
907 def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
908 "cvttpd2dq\t{$src, $dst|$dst, $src}",
909 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
910 def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
911 "cvttpd2dq\t{$src, $dst|$dst, $src}",
912 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
913 (memop addr:$src)))]>;
915 // Convert packed single to packed double
916 let isAsmParserOnly = 1 in { // SSE2 instructions without OpSize prefix
917 def VCVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
918 "vcvtps2pd\t{$src, $dst|$dst, $src}", []>, VEX,
920 def VCVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
921 "vcvtps2pd\t{$src, $dst|$dst, $src}", []>, VEX,
924 def CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
925 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
926 def CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
927 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
929 let isAsmParserOnly = 1 in {
930 def Int_VCVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
931 "cvtps2pd\t{$src, $dst|$dst, $src}",
932 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
933 VEX, Requires<[HasAVX]>;
934 def Int_VCVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
935 "cvtps2pd\t{$src, $dst|$dst, $src}",
936 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
937 (load addr:$src)))]>,
938 VEX, Requires<[HasAVX]>;
940 def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
941 "cvtps2pd\t{$src, $dst|$dst, $src}",
942 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
943 TB, Requires<[HasSSE2]>;
944 def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
945 "cvtps2pd\t{$src, $dst|$dst, $src}",
946 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
947 (load addr:$src)))]>,
948 TB, Requires<[HasSSE2]>;
950 // Convert packed double to packed single
951 let isAsmParserOnly = 1 in {
952 def VCVTPD2PSrr : VPDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
953 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>, VEX;
954 // FIXME: the memory form of this instruction should described using
955 // use extra asm syntax
957 def CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
958 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
959 def CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
960 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
963 let isAsmParserOnly = 1 in {
964 def Int_VCVTPD2PSrr : VPDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
965 "cvtpd2ps\t{$src, $dst|$dst, $src}",
966 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
967 def Int_VCVTPD2PSrm : VPDI<0x5A, MRMSrcMem, (outs VR128:$dst),
969 "cvtpd2ps\t{$src, $dst|$dst, $src}",
970 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
971 (memop addr:$src)))]>;
973 def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
974 "cvtpd2ps\t{$src, $dst|$dst, $src}",
975 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
976 def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
977 "cvtpd2ps\t{$src, $dst|$dst, $src}",
978 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
979 (memop addr:$src)))]>;
981 //===----------------------------------------------------------------------===//
982 // SSE 1 & 2 - Compare Instructions
983 //===----------------------------------------------------------------------===//
985 // sse12_cmp_scalar - sse 1 & 2 compare scalar instructions
986 multiclass sse12_cmp_scalar<RegisterClass RC, X86MemOperand x86memop,
987 string asm, string asm_alt> {
988 def rr : SIi8<0xC2, MRMSrcReg,
989 (outs RC:$dst), (ins RC:$src1, RC:$src, SSECC:$cc),
992 def rm : SIi8<0xC2, MRMSrcMem,
993 (outs RC:$dst), (ins RC:$src1, x86memop:$src, SSECC:$cc),
995 // Accept explicit immediate argument form instead of comparison code.
996 let isAsmParserOnly = 1 in {
997 def rr_alt : SIi8<0xC2, MRMSrcReg,
998 (outs RC:$dst), (ins RC:$src1, RC:$src, i8imm:$src2),
1001 def rm_alt : SIi8<0xC2, MRMSrcMem,
1002 (outs RC:$dst), (ins RC:$src1, x86memop:$src, i8imm:$src2),
1007 let neverHasSideEffects = 1, isAsmParserOnly = 1 in {
1008 defm VCMPSS : sse12_cmp_scalar<FR32, f32mem,
1009 "cmp${cc}ss\t{$src, $src1, $dst|$dst, $src1, $src}",
1010 "cmpss\t{$src2, $src, $src1, $dst|$dst, $src1, $src, $src2}">,
1012 defm VCMPSD : sse12_cmp_scalar<FR64, f64mem,
1013 "cmp${cc}sd\t{$src, $src1, $dst|$dst, $src1, $src}",
1014 "cmpsd\t{$src2, $src, $src1, $dst|$dst, $src1, $src, $src2}">,
1018 let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
1019 defm CMPSS : sse12_cmp_scalar<FR32, f32mem,
1020 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
1021 "cmpss\t{$src2, $src, $dst|$dst, $src, $src2}">, XS;
1022 defm CMPSD : sse12_cmp_scalar<FR64, f64mem,
1023 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
1024 "cmpsd\t{$src2, $src, $dst|$dst, $src, $src2}">, XD;
1027 multiclass sse12_cmp_scalar_int<RegisterClass RC, X86MemOperand x86memop,
1028 Intrinsic Int, string asm> {
1029 def rr : SIi8<0xC2, MRMSrcReg, (outs VR128:$dst),
1030 (ins VR128:$src1, VR128:$src, SSECC:$cc), asm,
1031 [(set VR128:$dst, (Int VR128:$src1,
1032 VR128:$src, imm:$cc))]>;
1033 def rm : SIi8<0xC2, MRMSrcMem, (outs VR128:$dst),
1034 (ins VR128:$src1, f32mem:$src, SSECC:$cc), asm,
1035 [(set VR128:$dst, (Int VR128:$src1,
1036 (load addr:$src), imm:$cc))]>;
1039 // Aliases to match intrinsics which expect XMM operand(s).
1040 let isAsmParserOnly = 1 in {
1041 defm Int_VCMPSS : sse12_cmp_scalar_int<VR128, f32mem, int_x86_sse_cmp_ss,
1042 "cmp${cc}ss\t{$src, $src1, $dst|$dst, $src1, $src}">,
1044 defm Int_VCMPSD : sse12_cmp_scalar_int<VR128, f64mem, int_x86_sse2_cmp_sd,
1045 "cmp${cc}sd\t{$src, $src1, $dst|$dst, $src1, $src}">,
1048 let Constraints = "$src1 = $dst" in {
1049 defm Int_CMPSS : sse12_cmp_scalar_int<VR128, f32mem, int_x86_sse_cmp_ss,
1050 "cmp${cc}ss\t{$src, $dst|$dst, $src}">, XS;
1051 defm Int_CMPSD : sse12_cmp_scalar_int<VR128, f64mem, int_x86_sse2_cmp_sd,
1052 "cmp${cc}sd\t{$src, $dst|$dst, $src}">, XD;
1056 // sse12_ord_cmp - Unordered/Ordered scalar fp compare and set EFLAGS
1057 multiclass sse12_ord_cmp<bits<8> opc, RegisterClass RC, SDNode OpNode,
1058 ValueType vt, X86MemOperand x86memop,
1059 PatFrag ld_frag, string OpcodeStr, Domain d> {
1060 def rr: PI<opc, MRMSrcReg, (outs), (ins RC:$src1, RC:$src2),
1061 !strconcat(OpcodeStr, "\t{$src2, $src1|$src1, $src2}"),
1062 [(set EFLAGS, (OpNode (vt RC:$src1), RC:$src2))], d>;
1063 def rm: PI<opc, MRMSrcMem, (outs), (ins RC:$src1, x86memop:$src2),
1064 !strconcat(OpcodeStr, "\t{$src2, $src1|$src1, $src2}"),
1065 [(set EFLAGS, (OpNode (vt RC:$src1),
1066 (ld_frag addr:$src2)))], d>;
1069 let Defs = [EFLAGS] in {
1070 let isAsmParserOnly = 1 in {
1071 defm VUCOMISS : sse12_ord_cmp<0x2E, FR32, X86cmp, f32, f32mem, loadf32,
1072 "ucomiss", SSEPackedSingle>, VEX;
1073 defm VUCOMISD : sse12_ord_cmp<0x2E, FR64, X86cmp, f64, f64mem, loadf64,
1074 "ucomisd", SSEPackedDouble>, OpSize, VEX;
1075 let Pattern = []<dag> in {
1076 defm VCOMISS : sse12_ord_cmp<0x2F, VR128, undef, v4f32, f128mem, load,
1077 "comiss", SSEPackedSingle>, VEX;
1078 defm VCOMISD : sse12_ord_cmp<0x2F, VR128, undef, v2f64, f128mem, load,
1079 "comisd", SSEPackedDouble>, OpSize, VEX;
1082 defm Int_VUCOMISS : sse12_ord_cmp<0x2E, VR128, X86ucomi, v4f32, f128mem,
1083 load, "ucomiss", SSEPackedSingle>, VEX;
1084 defm Int_VUCOMISD : sse12_ord_cmp<0x2E, VR128, X86ucomi, v2f64, f128mem,
1085 load, "ucomisd", SSEPackedDouble>, OpSize, VEX;
1087 defm Int_VCOMISS : sse12_ord_cmp<0x2F, VR128, X86comi, v4f32, f128mem,
1088 load, "comiss", SSEPackedSingle>, VEX;
1089 defm Int_VCOMISD : sse12_ord_cmp<0x2F, VR128, X86comi, v2f64, f128mem,
1090 load, "comisd", SSEPackedDouble>, OpSize, VEX;
1092 defm UCOMISS : sse12_ord_cmp<0x2E, FR32, X86cmp, f32, f32mem, loadf32,
1093 "ucomiss", SSEPackedSingle>, TB;
1094 defm UCOMISD : sse12_ord_cmp<0x2E, FR64, X86cmp, f64, f64mem, loadf64,
1095 "ucomisd", SSEPackedDouble>, TB, OpSize;
1097 let Pattern = []<dag> in {
1098 defm COMISS : sse12_ord_cmp<0x2F, VR128, undef, v4f32, f128mem, load,
1099 "comiss", SSEPackedSingle>, TB;
1100 defm COMISD : sse12_ord_cmp<0x2F, VR128, undef, v2f64, f128mem, load,
1101 "comisd", SSEPackedDouble>, TB, OpSize;
1104 defm Int_UCOMISS : sse12_ord_cmp<0x2E, VR128, X86ucomi, v4f32, f128mem,
1105 load, "ucomiss", SSEPackedSingle>, TB;
1106 defm Int_UCOMISD : sse12_ord_cmp<0x2E, VR128, X86ucomi, v2f64, f128mem,
1107 load, "ucomisd", SSEPackedDouble>, TB, OpSize;
1109 defm Int_COMISS : sse12_ord_cmp<0x2F, VR128, X86comi, v4f32, f128mem, load,
1110 "comiss", SSEPackedSingle>, TB;
1111 defm Int_COMISD : sse12_ord_cmp<0x2F, VR128, X86comi, v2f64, f128mem, load,
1112 "comisd", SSEPackedDouble>, TB, OpSize;
1113 } // Defs = [EFLAGS]
1115 // sse12_cmp_packed - sse 1 & 2 compared packed instructions
1116 multiclass sse12_cmp_packed<RegisterClass RC, X86MemOperand x86memop,
1117 Intrinsic Int, string asm, string asm_alt,
1119 def rri : PIi8<0xC2, MRMSrcReg,
1120 (outs RC:$dst), (ins RC:$src1, RC:$src, SSECC:$cc), asm,
1121 [(set RC:$dst, (Int RC:$src1, RC:$src, imm:$cc))], d>;
1122 def rmi : PIi8<0xC2, MRMSrcMem,
1123 (outs RC:$dst), (ins RC:$src1, f128mem:$src, SSECC:$cc), asm,
1124 [(set RC:$dst, (Int RC:$src1, (memop addr:$src), imm:$cc))], d>;
1125 // Accept explicit immediate argument form instead of comparison code.
1126 let isAsmParserOnly = 1 in {
1127 def rri_alt : PIi8<0xC2, MRMSrcReg,
1128 (outs RC:$dst), (ins RC:$src1, RC:$src, i8imm:$src2),
1130 def rmi_alt : PIi8<0xC2, MRMSrcMem,
1131 (outs RC:$dst), (ins RC:$src1, f128mem:$src, i8imm:$src2),
1136 let isAsmParserOnly = 1 in {
1137 defm VCMPPS : sse12_cmp_packed<VR128, f128mem, int_x86_sse_cmp_ps,
1138 "cmp${cc}ps\t{$src, $src1, $dst|$dst, $src1, $src}",
1139 "cmpps\t{$src2, $src, $src1, $dst|$dst, $src1, $src, $src2}",
1140 SSEPackedSingle>, VEX_4V;
1141 defm VCMPPD : sse12_cmp_packed<VR128, f128mem, int_x86_sse2_cmp_pd,
1142 "cmp${cc}pd\t{$src, $src1, $dst|$dst, $src1, $src}",
1143 "cmppd\t{$src2, $src, $src1, $dst|$dst, $src1, $src, $src2}",
1144 SSEPackedDouble>, OpSize, VEX_4V;
1146 let Constraints = "$src1 = $dst" in {
1147 defm CMPPS : sse12_cmp_packed<VR128, f128mem, int_x86_sse_cmp_ps,
1148 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
1149 "cmpps\t{$src2, $src, $dst|$dst, $src, $src2}",
1150 SSEPackedSingle>, TB;
1151 defm CMPPD : sse12_cmp_packed<VR128, f128mem, int_x86_sse2_cmp_pd,
1152 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1153 "cmppd\t{$src2, $src, $dst|$dst, $src, $src2}",
1154 SSEPackedDouble>, TB, OpSize;
1157 def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
1158 (CMPPSrri (v4f32 VR128:$src1), (v4f32 VR128:$src2), imm:$cc)>;
1159 def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
1160 (CMPPSrmi (v4f32 VR128:$src1), addr:$src2, imm:$cc)>;
1161 def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
1162 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
1163 def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
1164 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
1166 //===----------------------------------------------------------------------===//
1167 // SSE 1 & 2 - Shuffle Instructions
1168 //===----------------------------------------------------------------------===//
1170 /// sse12_shuffle - sse 1 & 2 shuffle instructions
1171 multiclass sse12_shuffle<RegisterClass RC, X86MemOperand x86memop,
1172 ValueType vt, string asm, PatFrag mem_frag,
1173 Domain d, bit IsConvertibleToThreeAddress = 0> {
1174 def rmi : PIi8<0xC6, MRMSrcMem, (outs VR128:$dst),
1175 (ins VR128:$src1, f128mem:$src2, i8imm:$src3), asm,
1176 [(set VR128:$dst, (vt (shufp:$src3
1177 VR128:$src1, (mem_frag addr:$src2))))], d>;
1178 let isConvertibleToThreeAddress = IsConvertibleToThreeAddress in
1179 def rri : PIi8<0xC6, MRMSrcReg, (outs VR128:$dst),
1180 (ins VR128:$src1, VR128:$src2, i8imm:$src3), asm,
1182 (vt (shufp:$src3 VR128:$src1, VR128:$src2)))], d>;
1185 let isAsmParserOnly = 1 in {
1186 defm VSHUFPS : sse12_shuffle<VR128, f128mem, v4f32,
1187 "shufps\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}",
1188 memopv4f32, SSEPackedSingle>, VEX_4V;
1189 defm VSHUFPD : sse12_shuffle<VR128, f128mem, v2f64,
1190 "shufpd\t{$src3, $src2, $src1, $dst|$dst, $src2, $src2, $src3}",
1191 memopv2f64, SSEPackedDouble>, OpSize, VEX_4V;
1194 let Constraints = "$src1 = $dst" in {
1195 defm SHUFPS : sse12_shuffle<VR128, f128mem, v4f32,
1196 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1197 memopv4f32, SSEPackedSingle, 1 /* cvt to pshufd */>,
1199 defm SHUFPD : sse12_shuffle<VR128, f128mem, v2f64,
1200 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1201 memopv2f64, SSEPackedDouble>, TB, OpSize;
1204 //===----------------------------------------------------------------------===//
1205 // SSE 1 & 2 - Unpack Instructions
1206 //===----------------------------------------------------------------------===//
1208 /// sse12_unpack_interleave - sse 1 & 2 unpack and interleave
1209 multiclass sse12_unpack_interleave<bits<8> opc, PatFrag OpNode, ValueType vt,
1210 PatFrag mem_frag, RegisterClass RC,
1211 X86MemOperand x86memop, string asm,
1213 def rr : PI<opc, MRMSrcReg,
1214 (outs RC:$dst), (ins RC:$src1, RC:$src2),
1216 (vt (OpNode RC:$src1, RC:$src2)))], d>;
1217 def rm : PI<opc, MRMSrcMem,
1218 (outs RC:$dst), (ins RC:$src1, x86memop:$src2),
1220 (vt (OpNode RC:$src1,
1221 (mem_frag addr:$src2))))], d>;
1224 let AddedComplexity = 10 in {
1225 let isAsmParserOnly = 1 in {
1226 defm VUNPCKHPS: sse12_unpack_interleave<0x15, unpckh, v4f32, memopv4f32,
1227 VR128, f128mem, "unpckhps\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1228 SSEPackedSingle>, VEX_4V;
1229 defm VUNPCKHPD: sse12_unpack_interleave<0x15, unpckh, v2f64, memopv2f64,
1230 VR128, f128mem, "unpckhpd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1231 SSEPackedDouble>, OpSize, VEX_4V;
1232 defm VUNPCKLPS: sse12_unpack_interleave<0x14, unpckl, v4f32, memopv4f32,
1233 VR128, f128mem, "unpcklps\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1234 SSEPackedSingle>, VEX_4V;
1235 defm VUNPCKLPD: sse12_unpack_interleave<0x14, unpckl, v2f64, memopv2f64,
1236 VR128, f128mem, "unpcklpd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1237 SSEPackedDouble>, OpSize, VEX_4V;
1239 defm VUNPCKHPSY: sse12_unpack_interleave<0x15, unpckh, v8f32, memopv8f32,
1240 VR256, f256mem, "unpckhps\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1241 SSEPackedSingle>, VEX_4V;
1242 defm VUNPCKHPDY: sse12_unpack_interleave<0x15, unpckh, v4f64, memopv4f64,
1243 VR256, f256mem, "unpckhpd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1244 SSEPackedDouble>, OpSize, VEX_4V;
1245 defm VUNPCKLPSY: sse12_unpack_interleave<0x14, unpckl, v8f32, memopv8f32,
1246 VR256, f256mem, "unpcklps\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1247 SSEPackedSingle>, VEX_4V;
1248 defm VUNPCKLPDY: sse12_unpack_interleave<0x14, unpckl, v4f64, memopv4f64,
1249 VR256, f256mem, "unpcklpd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1250 SSEPackedDouble>, OpSize, VEX_4V;
1253 let Constraints = "$src1 = $dst" in {
1254 defm UNPCKHPS: sse12_unpack_interleave<0x15, unpckh, v4f32, memopv4f32,
1255 VR128, f128mem, "unpckhps\t{$src2, $dst|$dst, $src2}",
1256 SSEPackedSingle>, TB;
1257 defm UNPCKHPD: sse12_unpack_interleave<0x15, unpckh, v2f64, memopv2f64,
1258 VR128, f128mem, "unpckhpd\t{$src2, $dst|$dst, $src2}",
1259 SSEPackedDouble>, TB, OpSize;
1260 defm UNPCKLPS: sse12_unpack_interleave<0x14, unpckl, v4f32, memopv4f32,
1261 VR128, f128mem, "unpcklps\t{$src2, $dst|$dst, $src2}",
1262 SSEPackedSingle>, TB;
1263 defm UNPCKLPD: sse12_unpack_interleave<0x14, unpckl, v2f64, memopv2f64,
1264 VR128, f128mem, "unpcklpd\t{$src2, $dst|$dst, $src2}",
1265 SSEPackedDouble>, TB, OpSize;
1266 } // Constraints = "$src1 = $dst"
1267 } // AddedComplexity
1269 //===----------------------------------------------------------------------===//
1270 // SSE 1 & 2 - Extract Floating-Point Sign mask
1271 //===----------------------------------------------------------------------===//
1273 /// sse12_extr_sign_mask - sse 1 & 2 unpack and interleave
1274 multiclass sse12_extr_sign_mask<RegisterClass RC, Intrinsic Int, string asm,
1276 def rr : PI<0x50, MRMSrcReg, (outs GR32:$dst), (ins RC:$src),
1277 !strconcat(asm, "\t{$src, $dst|$dst, $src}"),
1278 [(set GR32:$dst, (Int RC:$src))], d>;
1282 defm MOVMSKPS : sse12_extr_sign_mask<VR128, int_x86_sse_movmsk_ps, "movmskps",
1283 SSEPackedSingle>, TB;
1284 defm MOVMSKPD : sse12_extr_sign_mask<VR128, int_x86_sse2_movmsk_pd, "movmskpd",
1285 SSEPackedDouble>, TB, OpSize;
1287 let isAsmParserOnly = 1 in {
1288 defm VMOVMSKPS : sse12_extr_sign_mask<VR128, int_x86_sse_movmsk_ps,
1289 "movmskps", SSEPackedSingle>, VEX;
1290 defm VMOVMSKPD : sse12_extr_sign_mask<VR128, int_x86_sse2_movmsk_pd,
1291 "movmskpd", SSEPackedDouble>, OpSize,
1293 // FIXME: merge with multiclass above when the intrinsics come.
1294 def VMOVMSKPSYrr : PI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR256:$src),
1295 "movmskps\t{$src, $dst|$dst, $src}", [], SSEPackedSingle>, VEX;
1296 def VMOVMSKPDYrr : PI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR256:$src),
1297 "movmskpd\t{$src, $dst|$dst, $src}", [], SSEPackedDouble>, OpSize,
1301 //===----------------------------------------------------------------------===//
1302 // SSE 1 & 2 - Misc aliasing of packed SSE 1 & 2 instructions
1303 //===----------------------------------------------------------------------===//
1305 // Aliases of packed SSE1 & SSE2 instructions for scalar use. These all have
1306 // names that start with 'Fs'.
1308 // Alias instructions that map fld0 to pxor for sse.
1309 let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1310 canFoldAsLoad = 1 in {
1311 // FIXME: Set encoding to pseudo!
1312 def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins), "",
1313 [(set FR32:$dst, fp32imm0)]>,
1314 Requires<[HasSSE1]>, TB, OpSize;
1315 def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins), "",
1316 [(set FR64:$dst, fpimm0)]>,
1317 Requires<[HasSSE2]>, TB, OpSize;
1320 // Alias instruction to do FR32 or FR64 reg-to-reg copy using movaps. Upper
1321 // bits are disregarded.
1322 let neverHasSideEffects = 1 in {
1323 def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
1324 "movaps\t{$src, $dst|$dst, $src}", []>;
1325 def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1326 "movapd\t{$src, $dst|$dst, $src}", []>;
1329 // Alias instruction to load FR32 or FR64 from f128mem using movaps. Upper
1330 // bits are disregarded.
1331 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1332 def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
1333 "movaps\t{$src, $dst|$dst, $src}",
1334 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
1335 def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
1336 "movapd\t{$src, $dst|$dst, $src}",
1337 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
1340 //===----------------------------------------------------------------------===//
1341 // SSE 1 & 2 - Logical Instructions
1342 //===----------------------------------------------------------------------===//
1344 /// sse12_fp_alias_pack_logical - SSE 1 & 2 aliased packed FP logical ops
1346 multiclass sse12_fp_alias_pack_logical<bits<8> opc, string OpcodeStr,
1348 let isAsmParserOnly = 1 in {
1349 defm V#NAME#PS : sse12_fp_packed<opc, !strconcat(OpcodeStr, "ps"), OpNode,
1350 FR32, f32, f128mem, memopfsf32, SSEPackedSingle, 0>, VEX_4V;
1352 defm V#NAME#PD : sse12_fp_packed<opc, !strconcat(OpcodeStr, "pd"), OpNode,
1353 FR64, f64, f128mem, memopfsf64, SSEPackedDouble, 0>, OpSize, VEX_4V;
1356 let Constraints = "$src1 = $dst" in {
1357 defm PS : sse12_fp_packed<opc, !strconcat(OpcodeStr, "ps"), OpNode, FR32,
1358 f32, f128mem, memopfsf32, SSEPackedSingle>, TB;
1360 defm PD : sse12_fp_packed<opc, !strconcat(OpcodeStr, "pd"), OpNode, FR64,
1361 f64, f128mem, memopfsf64, SSEPackedDouble>, TB, OpSize;
1365 // Alias bitwise logical operations using SSE logical ops on packed FP values.
1366 let mayLoad = 0 in {
1367 defm FsAND : sse12_fp_alias_pack_logical<0x54, "and", X86fand>;
1368 defm FsOR : sse12_fp_alias_pack_logical<0x56, "or", X86for>;
1369 defm FsXOR : sse12_fp_alias_pack_logical<0x57, "xor", X86fxor>;
1372 let neverHasSideEffects = 1, Pattern = []<dag>, isCommutable = 0 in
1373 defm FsANDN : sse12_fp_alias_pack_logical<0x55, "andn", undef>;
1375 /// sse12_fp_packed_logical - SSE 1 & 2 packed FP logical ops
1377 multiclass sse12_fp_packed_logical<bits<8> opc, string OpcodeStr,
1378 SDNode OpNode, int HasPat = 0,
1379 list<list<dag>> Pattern = []> {
1380 let isAsmParserOnly = 1, Pattern = []<dag> in {
1381 defm V#NAME#PS : sse12_fp_packed_logical_rm<opc, VR128, SSEPackedSingle,
1382 !strconcat(OpcodeStr, "ps"), f128mem,
1383 !if(HasPat, Pattern[0], // rr
1384 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1,
1386 !if(HasPat, Pattern[2], // rm
1387 [(set VR128:$dst, (OpNode (bc_v2i64 (v4f32 VR128:$src1)),
1388 (memopv2i64 addr:$src2)))]), 0>,
1391 defm V#NAME#PD : sse12_fp_packed_logical_rm<opc, VR128, SSEPackedDouble,
1392 !strconcat(OpcodeStr, "pd"), f128mem,
1393 !if(HasPat, Pattern[1], // rr
1394 [(set VR128:$dst, (OpNode (bc_v2i64 (v2f64 VR128:$src1)),
1397 !if(HasPat, Pattern[3], // rm
1398 [(set VR128:$dst, (OpNode (bc_v2i64 (v2f64 VR128:$src1)),
1399 (memopv2i64 addr:$src2)))]), 0>,
1402 let Constraints = "$src1 = $dst" in {
1403 defm PS : sse12_fp_packed_logical_rm<opc, VR128, SSEPackedSingle,
1404 !strconcat(OpcodeStr, "ps"), f128mem,
1405 !if(HasPat, Pattern[0], // rr
1406 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1,
1408 !if(HasPat, Pattern[2], // rm
1409 [(set VR128:$dst, (OpNode (bc_v2i64 (v4f32 VR128:$src1)),
1410 (memopv2i64 addr:$src2)))])>, TB;
1412 defm PD : sse12_fp_packed_logical_rm<opc, VR128, SSEPackedDouble,
1413 !strconcat(OpcodeStr, "pd"), f128mem,
1414 !if(HasPat, Pattern[1], // rr
1415 [(set VR128:$dst, (OpNode (bc_v2i64 (v2f64 VR128:$src1)),
1418 !if(HasPat, Pattern[3], // rm
1419 [(set VR128:$dst, (OpNode (bc_v2i64 (v2f64 VR128:$src1)),
1420 (memopv2i64 addr:$src2)))])>,
1425 defm AND : sse12_fp_packed_logical<0x54, "and", and>;
1426 defm OR : sse12_fp_packed_logical<0x56, "or", or>;
1427 defm XOR : sse12_fp_packed_logical<0x57, "xor", xor>;
1428 let isCommutable = 0 in
1429 defm ANDN : sse12_fp_packed_logical<0x55, "andn", undef /* dummy */, 1, [
1431 [(set VR128:$dst, (v2i64 (and (xor VR128:$src1,
1432 (bc_v2i64 (v4i32 immAllOnesV))),
1435 [(set VR128:$dst, (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1436 (bc_v2i64 (v2f64 VR128:$src2))))],
1438 [(set VR128:$dst, (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
1439 (bc_v2i64 (v4i32 immAllOnesV))),
1440 (memopv2i64 addr:$src2))))],
1442 [(set VR128:$dst, (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1443 (memopv2i64 addr:$src2)))]]>;
1445 //===----------------------------------------------------------------------===//
1446 // SSE 1 & 2 - Arithmetic Instructions
1447 //===----------------------------------------------------------------------===//
1449 /// basic_sse12_fp_binop_xxx - SSE 1 & 2 binops come in both scalar and
1452 /// In addition, we also have a special variant of the scalar form here to
1453 /// represent the associated intrinsic operation. This form is unlike the
1454 /// plain scalar form, in that it takes an entire vector (instead of a scalar)
1455 /// and leaves the top elements unmodified (therefore these cannot be commuted).
1457 /// These three forms can each be reg+reg or reg+mem.
1459 multiclass basic_sse12_fp_binop_s<bits<8> opc, string OpcodeStr, SDNode OpNode,
1461 defm SS : sse12_fp_scalar<opc, !strconcat(OpcodeStr, "ss"),
1462 OpNode, FR32, f32mem, Is2Addr>, XS;
1463 defm SD : sse12_fp_scalar<opc, !strconcat(OpcodeStr, "sd"),
1464 OpNode, FR64, f64mem, Is2Addr>, XD;
1467 multiclass basic_sse12_fp_binop_p<bits<8> opc, string OpcodeStr, SDNode OpNode,
1469 let mayLoad = 0 in {
1470 defm PS : sse12_fp_packed<opc, !strconcat(OpcodeStr, "ps"), OpNode, VR128,
1471 v4f32, f128mem, memopv4f32, SSEPackedSingle, Is2Addr>, TB;
1472 defm PD : sse12_fp_packed<opc, !strconcat(OpcodeStr, "pd"), OpNode, VR128,
1473 v2f64, f128mem, memopv2f64, SSEPackedDouble, Is2Addr>, TB, OpSize;
1477 multiclass basic_sse12_fp_binop_p_y<bits<8> opc, string OpcodeStr,
1479 let mayLoad = 0 in {
1480 defm PSY : sse12_fp_packed<opc, !strconcat(OpcodeStr, "ps"), OpNode, VR256,
1481 v8f32, f256mem, memopv8f32, SSEPackedSingle, 0>, TB;
1482 defm PDY : sse12_fp_packed<opc, !strconcat(OpcodeStr, "pd"), OpNode, VR256,
1483 v4f64, f256mem, memopv4f64, SSEPackedDouble, 0>, TB, OpSize;
1487 multiclass basic_sse12_fp_binop_s_int<bits<8> opc, string OpcodeStr,
1489 defm SS : sse12_fp_scalar_int<opc, OpcodeStr, VR128,
1490 !strconcat(OpcodeStr, "ss"), "", "_ss", ssmem, sse_load_f32, Is2Addr>, XS;
1491 defm SD : sse12_fp_scalar_int<opc, OpcodeStr, VR128,
1492 !strconcat(OpcodeStr, "sd"), "2", "_sd", sdmem, sse_load_f64, Is2Addr>, XD;
1495 multiclass basic_sse12_fp_binop_p_int<bits<8> opc, string OpcodeStr,
1497 defm PS : sse12_fp_packed_int<opc, OpcodeStr, VR128,
1498 !strconcat(OpcodeStr, "ps"), "", "_ps", f128mem, memopv4f32,
1499 SSEPackedSingle, Is2Addr>, TB;
1501 defm PD : sse12_fp_packed_int<opc, OpcodeStr, VR128,
1502 !strconcat(OpcodeStr, "pd"), "2", "_pd", f128mem, memopv2f64,
1503 SSEPackedDouble, Is2Addr>, TB, OpSize;
1506 // Binary Arithmetic instructions
1507 let isAsmParserOnly = 1 in {
1508 defm VADD : basic_sse12_fp_binop_s<0x58, "add", fadd, 0>,
1509 basic_sse12_fp_binop_p<0x58, "add", fadd, 0>,
1510 basic_sse12_fp_binop_p_y<0x58, "add", fadd>, VEX_4V;
1511 defm VMUL : basic_sse12_fp_binop_s<0x59, "mul", fmul, 0>,
1512 basic_sse12_fp_binop_p<0x59, "mul", fmul, 0>,
1513 basic_sse12_fp_binop_p_y<0x59, "mul", fmul>, VEX_4V;
1515 let isCommutable = 0 in {
1516 defm VSUB : basic_sse12_fp_binop_s<0x5C, "sub", fsub, 0>,
1517 basic_sse12_fp_binop_p<0x5C, "sub", fsub, 0>,
1518 basic_sse12_fp_binop_p_y<0x5C, "sub", fsub>, VEX_4V;
1519 defm VDIV : basic_sse12_fp_binop_s<0x5E, "div", fdiv, 0>,
1520 basic_sse12_fp_binop_p<0x5E, "div", fdiv, 0>,
1521 basic_sse12_fp_binop_p_y<0x5E, "div", fdiv>, VEX_4V;
1522 defm VMAX : basic_sse12_fp_binop_s<0x5F, "max", X86fmax, 0>,
1523 basic_sse12_fp_binop_p<0x5F, "max", X86fmax, 0>,
1524 basic_sse12_fp_binop_p_y<0x5F, "max", X86fmax>, VEX_4V;
1525 defm VMIN : basic_sse12_fp_binop_s<0x5D, "min", X86fmin, 0>,
1526 basic_sse12_fp_binop_p<0x5D, "min", X86fmin, 0>,
1527 basic_sse12_fp_binop_p_y<0x5D, "min", X86fmin>, VEX_4V;
1531 let Constraints = "$src1 = $dst" in {
1532 defm ADD : basic_sse12_fp_binop_s<0x58, "add", fadd>,
1533 basic_sse12_fp_binop_p<0x58, "add", fadd>,
1534 basic_sse12_fp_binop_s_int<0x58, "add">;
1535 defm MUL : basic_sse12_fp_binop_s<0x59, "mul", fmul>,
1536 basic_sse12_fp_binop_p<0x59, "mul", fmul>,
1537 basic_sse12_fp_binop_s_int<0x59, "mul">;
1539 let isCommutable = 0 in {
1540 defm SUB : basic_sse12_fp_binop_s<0x5C, "sub", fsub>,
1541 basic_sse12_fp_binop_p<0x5C, "sub", fsub>,
1542 basic_sse12_fp_binop_s_int<0x5C, "sub">;
1543 defm DIV : basic_sse12_fp_binop_s<0x5E, "div", fdiv>,
1544 basic_sse12_fp_binop_p<0x5E, "div", fdiv>,
1545 basic_sse12_fp_binop_s_int<0x5E, "div">;
1546 defm MAX : basic_sse12_fp_binop_s<0x5F, "max", X86fmax>,
1547 basic_sse12_fp_binop_p<0x5F, "max", X86fmax>,
1548 basic_sse12_fp_binop_s_int<0x5F, "max">,
1549 basic_sse12_fp_binop_p_int<0x5F, "max">;
1550 defm MIN : basic_sse12_fp_binop_s<0x5D, "min", X86fmin>,
1551 basic_sse12_fp_binop_p<0x5D, "min", X86fmin>,
1552 basic_sse12_fp_binop_s_int<0x5D, "min">,
1553 basic_sse12_fp_binop_p_int<0x5D, "min">;
1558 /// In addition, we also have a special variant of the scalar form here to
1559 /// represent the associated intrinsic operation. This form is unlike the
1560 /// plain scalar form, in that it takes an entire vector (instead of a
1561 /// scalar) and leaves the top elements undefined.
1563 /// And, we have a special variant form for a full-vector intrinsic form.
1565 /// sse1_fp_unop_s - SSE1 unops in scalar form.
1566 multiclass sse1_fp_unop_s<bits<8> opc, string OpcodeStr,
1567 SDNode OpNode, Intrinsic F32Int> {
1568 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
1569 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
1570 [(set FR32:$dst, (OpNode FR32:$src))]>;
1571 // For scalar unary operations, fold a load into the operation
1572 // only in OptForSize mode. It eliminates an instruction, but it also
1573 // eliminates a whole-register clobber (the load), so it introduces a
1574 // partial register update condition.
1575 def SSm : I<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
1576 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
1577 [(set FR32:$dst, (OpNode (load addr:$src)))]>, XS,
1578 Requires<[HasSSE1, OptForSize]>;
1579 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1580 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
1581 [(set VR128:$dst, (F32Int VR128:$src))]>;
1582 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
1583 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
1584 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
1587 /// sse1_fp_unop_s_avx - AVX SSE1 unops in scalar form.
1588 multiclass sse1_fp_unop_s_avx<bits<8> opc, string OpcodeStr,
1589 SDNode OpNode, Intrinsic F32Int> {
1590 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
1591 !strconcat(!strconcat("v", OpcodeStr),
1592 "ss\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>;
1593 def SSm : I<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
1594 !strconcat(!strconcat("v", OpcodeStr),
1595 "ss\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
1596 []>, XS, Requires<[HasAVX, OptForSize]>;
1597 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
1598 (ins VR128:$src1, VR128:$src2),
1599 !strconcat(!strconcat("v", OpcodeStr),
1600 "ss\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>;
1601 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
1602 (ins VR128:$src1, ssmem:$src2),
1603 !strconcat(!strconcat("v", OpcodeStr),
1604 "ss\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>;
1607 /// sse1_fp_unop_p - SSE1 unops in packed form.
1608 multiclass sse1_fp_unop_p<bits<8> opc, string OpcodeStr, SDNode OpNode> {
1609 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1610 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1611 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]>;
1612 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1613 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1614 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
1617 /// sse1_fp_unop_p_y - AVX 256-bit SSE1 unops in packed form.
1618 multiclass sse1_fp_unop_p_y<bits<8> opc, string OpcodeStr, SDNode OpNode> {
1619 def PSYr : PSI<opc, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src),
1620 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1621 [(set VR256:$dst, (v8f32 (OpNode VR256:$src)))]>;
1622 def PSYm : PSI<opc, MRMSrcMem, (outs VR256:$dst), (ins f256mem:$src),
1623 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1624 [(set VR256:$dst, (OpNode (memopv8f32 addr:$src)))]>;
1627 /// sse1_fp_unop_p_int - SSE1 intrinsics unops in packed forms.
1628 multiclass sse1_fp_unop_p_int<bits<8> opc, string OpcodeStr,
1629 Intrinsic V4F32Int> {
1630 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1631 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1632 [(set VR128:$dst, (V4F32Int VR128:$src))]>;
1633 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1634 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1635 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
1639 /// sse2_fp_unop_s - SSE2 unops in scalar form.
1640 multiclass sse2_fp_unop_s<bits<8> opc, string OpcodeStr,
1641 SDNode OpNode, Intrinsic F64Int> {
1642 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1643 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1644 [(set FR64:$dst, (OpNode FR64:$src))]>;
1645 // See the comments in sse1_fp_unop_s for why this is OptForSize.
1646 def SDm : I<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
1647 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1648 [(set FR64:$dst, (OpNode (load addr:$src)))]>, XD,
1649 Requires<[HasSSE2, OptForSize]>;
1650 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1651 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1652 [(set VR128:$dst, (F64Int VR128:$src))]>;
1653 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
1654 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1655 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1658 /// sse2_fp_unop_s_avx - AVX SSE2 unops in scalar form.
1659 multiclass sse2_fp_unop_s_avx<bits<8> opc, string OpcodeStr,
1660 SDNode OpNode, Intrinsic F64Int> {
1661 def SDr : VSDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1662 !strconcat(OpcodeStr,
1663 "sd\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>;
1664 def SDm : VSDI<opc, MRMSrcMem, (outs FR64:$dst),
1665 (ins FR64:$src1, f64mem:$src2),
1666 !strconcat(OpcodeStr,
1667 "sd\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>;
1668 def SDr_Int : VSDI<opc, MRMSrcReg, (outs VR128:$dst),
1669 (ins VR128:$src1, VR128:$src2),
1670 !strconcat(OpcodeStr, "sd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
1672 def SDm_Int : VSDI<opc, MRMSrcMem, (outs VR128:$dst),
1673 (ins VR128:$src1, sdmem:$src2),
1674 !strconcat(OpcodeStr, "sd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
1678 /// sse2_fp_unop_p - SSE2 unops in vector forms.
1679 multiclass sse2_fp_unop_p<bits<8> opc, string OpcodeStr,
1681 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1682 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1683 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]>;
1684 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1685 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1686 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
1689 /// sse2_fp_unop_p_y - AVX SSE2 256-bit unops in vector forms.
1690 multiclass sse2_fp_unop_p_y<bits<8> opc, string OpcodeStr, SDNode OpNode> {
1691 def PDYr : PDI<opc, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src),
1692 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1693 [(set VR256:$dst, (v4f64 (OpNode VR256:$src)))]>;
1694 def PDYm : PDI<opc, MRMSrcMem, (outs VR256:$dst), (ins f256mem:$src),
1695 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1696 [(set VR256:$dst, (OpNode (memopv4f64 addr:$src)))]>;
1699 /// sse2_fp_unop_p_int - SSE2 intrinsic unops in vector forms.
1700 multiclass sse2_fp_unop_p_int<bits<8> opc, string OpcodeStr,
1701 Intrinsic V2F64Int> {
1702 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1703 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1704 [(set VR128:$dst, (V2F64Int VR128:$src))]>;
1705 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1706 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1707 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
1710 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
1712 defm VSQRT : sse1_fp_unop_s_avx<0x51, "sqrt", fsqrt, int_x86_sse_sqrt_ss>,
1713 sse2_fp_unop_s_avx<0x51, "sqrt", fsqrt, int_x86_sse2_sqrt_sd>,
1716 defm VSQRT : sse1_fp_unop_p<0x51, "vsqrt", fsqrt>,
1717 sse2_fp_unop_p<0x51, "vsqrt", fsqrt>,
1718 sse1_fp_unop_p_y<0x51, "vsqrt", fsqrt>,
1719 sse2_fp_unop_p_y<0x51, "vsqrt", fsqrt>,
1722 // Reciprocal approximations. Note that these typically require refinement
1723 // in order to obtain suitable precision.
1724 defm VRSQRT : sse1_fp_unop_s_avx<0x52, "rsqrt", X86frsqrt,
1725 int_x86_sse_rsqrt_ss>, VEX_4V;
1726 defm VRSQRT : sse1_fp_unop_p<0x52, "vrsqrt", X86frsqrt>,
1727 sse1_fp_unop_p_y<0x52, "vrsqrt", X86frsqrt>, VEX;
1729 defm VRCP : sse1_fp_unop_s_avx<0x53, "rcp", X86frcp, int_x86_sse_rcp_ss>,
1731 defm VRCP : sse1_fp_unop_p<0x53, "vrcp", X86frcp>,
1732 sse1_fp_unop_p_y<0x53, "vrcp", X86frcp>, VEX;
1736 defm SQRT : sse1_fp_unop_s<0x51, "sqrt", fsqrt, int_x86_sse_sqrt_ss>,
1737 sse1_fp_unop_p<0x51, "sqrt", fsqrt>,
1738 sse1_fp_unop_p_int<0x51, "sqrt", int_x86_sse_sqrt_ps>,
1739 sse2_fp_unop_s<0x51, "sqrt", fsqrt, int_x86_sse2_sqrt_sd>,
1740 sse2_fp_unop_p<0x51, "sqrt", fsqrt>,
1741 sse2_fp_unop_p_int<0x51, "sqrt", int_x86_sse2_sqrt_pd>;
1743 // Reciprocal approximations. Note that these typically require refinement
1744 // in order to obtain suitable precision.
1745 defm RSQRT : sse1_fp_unop_s<0x52, "rsqrt", X86frsqrt, int_x86_sse_rsqrt_ss>,
1746 sse1_fp_unop_p<0x52, "rsqrt", X86frsqrt>,
1747 sse1_fp_unop_p_int<0x52, "rsqrt", int_x86_sse_rsqrt_ps>;
1748 defm RCP : sse1_fp_unop_s<0x53, "rcp", X86frcp, int_x86_sse_rcp_ss>,
1749 sse1_fp_unop_p<0x53, "rcp", X86frcp>,
1750 sse1_fp_unop_p_int<0x53, "rcp", int_x86_sse_rcp_ps>;
1752 // There is no f64 version of the reciprocal approximation instructions.
1754 //===----------------------------------------------------------------------===//
1755 // SSE 1 & 2 - Non-temporal stores
1756 //===----------------------------------------------------------------------===//
1758 let isAsmParserOnly = 1 in {
1759 def VMOVNTPSmr_Int : VPSI<0x2B, MRMDestMem, (outs),
1760 (ins i128mem:$dst, VR128:$src),
1761 "movntps\t{$src, $dst|$dst, $src}",
1762 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>, VEX;
1763 def VMOVNTPDmr_Int : VPDI<0x2B, MRMDestMem, (outs),
1764 (ins i128mem:$dst, VR128:$src),
1765 "movntpd\t{$src, $dst|$dst, $src}",
1766 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>, VEX;
1768 let ExeDomain = SSEPackedInt in
1769 def VMOVNTDQmr_Int : VPDI<0xE7, MRMDestMem, (outs),
1770 (ins f128mem:$dst, VR128:$src),
1771 "movntdq\t{$src, $dst|$dst, $src}",
1772 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>, VEX;
1774 let AddedComplexity = 400 in { // Prefer non-temporal versions
1775 def VMOVNTPSmr : VPSI<0x2B, MRMDestMem, (outs),
1776 (ins f128mem:$dst, VR128:$src),
1777 "movntps\t{$src, $dst|$dst, $src}",
1778 [(alignednontemporalstore (v4f32 VR128:$src),
1780 def VMOVNTPDmr : VPDI<0x2B, MRMDestMem, (outs),
1781 (ins f128mem:$dst, VR128:$src),
1782 "movntpd\t{$src, $dst|$dst, $src}",
1783 [(alignednontemporalstore (v2f64 VR128:$src),
1785 def VMOVNTDQ_64mr : VPDI<0xE7, MRMDestMem, (outs),
1786 (ins f128mem:$dst, VR128:$src),
1787 "movntdq\t{$src, $dst|$dst, $src}",
1788 [(alignednontemporalstore (v2f64 VR128:$src),
1790 let ExeDomain = SSEPackedInt in
1791 def VMOVNTDQmr : VPDI<0xE7, MRMDestMem, (outs),
1792 (ins f128mem:$dst, VR128:$src),
1793 "movntdq\t{$src, $dst|$dst, $src}",
1794 [(alignednontemporalstore (v4f32 VR128:$src),
1797 def VMOVNTPSYmr : VPSI<0x2B, MRMDestMem, (outs),
1798 (ins f256mem:$dst, VR256:$src),
1799 "movntps\t{$src, $dst|$dst, $src}",
1800 [(alignednontemporalstore (v8f32 VR256:$src),
1802 def VMOVNTPDYmr : VPDI<0x2B, MRMDestMem, (outs),
1803 (ins f256mem:$dst, VR256:$src),
1804 "movntpd\t{$src, $dst|$dst, $src}",
1805 [(alignednontemporalstore (v4f64 VR256:$src),
1807 def VMOVNTDQY_64mr : VPDI<0xE7, MRMDestMem, (outs),
1808 (ins f256mem:$dst, VR256:$src),
1809 "movntdq\t{$src, $dst|$dst, $src}",
1810 [(alignednontemporalstore (v4f64 VR256:$src),
1812 let ExeDomain = SSEPackedInt in
1813 def VMOVNTDQYmr : VPDI<0xE7, MRMDestMem, (outs),
1814 (ins f256mem:$dst, VR256:$src),
1815 "movntdq\t{$src, $dst|$dst, $src}",
1816 [(alignednontemporalstore (v8f32 VR256:$src),
1821 def MOVNTPSmr_Int : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1822 "movntps\t{$src, $dst|$dst, $src}",
1823 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
1824 def MOVNTPDmr_Int : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1825 "movntpd\t{$src, $dst|$dst, $src}",
1826 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
1828 let ExeDomain = SSEPackedInt in
1829 def MOVNTDQmr_Int : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1830 "movntdq\t{$src, $dst|$dst, $src}",
1831 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
1833 let AddedComplexity = 400 in { // Prefer non-temporal versions
1834 def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1835 "movntps\t{$src, $dst|$dst, $src}",
1836 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
1837 def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1838 "movntpd\t{$src, $dst|$dst, $src}",
1839 [(alignednontemporalstore(v2f64 VR128:$src), addr:$dst)]>;
1841 def MOVNTDQ_64mr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1842 "movntdq\t{$src, $dst|$dst, $src}",
1843 [(alignednontemporalstore (v2f64 VR128:$src), addr:$dst)]>;
1845 let ExeDomain = SSEPackedInt in
1846 def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
1847 "movntdq\t{$src, $dst|$dst, $src}",
1848 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
1850 // There is no AVX form for instructions below this point
1851 def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1852 "movnti\t{$src, $dst|$dst, $src}",
1853 [(nontemporalstore (i32 GR32:$src), addr:$dst)]>,
1854 TB, Requires<[HasSSE2]>;
1856 def MOVNTI_64mr : RI<0xC3, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
1857 "movnti\t{$src, $dst|$dst, $src}",
1858 [(nontemporalstore (i64 GR64:$src), addr:$dst)]>,
1859 TB, Requires<[HasSSE2]>;
1862 def MOVNTImr_Int : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1863 "movnti\t{$src, $dst|$dst, $src}",
1864 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
1865 TB, Requires<[HasSSE2]>;
1867 //===----------------------------------------------------------------------===//
1868 // SSE 1 & 2 - Misc Instructions (No AVX form)
1869 //===----------------------------------------------------------------------===//
1871 // Prefetch intrinsic.
1872 def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
1873 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
1874 def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
1875 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
1876 def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
1877 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
1878 def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
1879 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
1881 // Load, store, and memory fence
1882 def SFENCE : I<0xAE, MRM_F8, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>,
1883 TB, Requires<[HasSSE1]>;
1885 // Alias instructions that map zero vector to pxor / xorp* for sse.
1886 // We set canFoldAsLoad because this can be converted to a constant-pool
1887 // load of an all-zeros value if folding it would be beneficial.
1888 // FIXME: Change encoding to pseudo!
1889 let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
1890 isCodeGenOnly = 1 in {
1891 def V_SET0PS : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "",
1892 [(set VR128:$dst, (v4f32 immAllZerosV))]>;
1893 def V_SET0PD : PDI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "",
1894 [(set VR128:$dst, (v2f64 immAllZerosV))]>;
1895 let ExeDomain = SSEPackedInt in
1896 def V_SET0PI : PDI<0xEF, MRMInitReg, (outs VR128:$dst), (ins), "",
1897 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
1900 def : Pat<(v2i64 immAllZerosV), (V_SET0PI)>;
1901 def : Pat<(v8i16 immAllZerosV), (V_SET0PI)>;
1902 def : Pat<(v16i8 immAllZerosV), (V_SET0PI)>;
1904 def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1905 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), sub_ss))>;
1907 //===----------------------------------------------------------------------===//
1908 // SSE 1 & 2 - Load/Store XCSR register
1909 //===----------------------------------------------------------------------===//
1911 let isAsmParserOnly = 1 in {
1912 def VLDMXCSR : VPSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
1913 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>, VEX;
1914 def VSTMXCSR : VPSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
1915 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>, VEX;
1918 def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
1919 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
1920 def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
1921 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
1923 //===---------------------------------------------------------------------===//
1924 // SSE2 - Move Aligned/Unaligned Packed Integer Instructions
1925 //===---------------------------------------------------------------------===//
1926 let ExeDomain = SSEPackedInt in { // SSE integer instructions
1928 let isAsmParserOnly = 1 in {
1929 let neverHasSideEffects = 1 in
1930 def VMOVDQArr : VPDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1931 "movdqa\t{$src, $dst|$dst, $src}", []>, VEX;
1932 def VMOVDQUrr : VPDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1933 "movdqu\t{$src, $dst|$dst, $src}", []>, XS, VEX;
1935 let canFoldAsLoad = 1, mayLoad = 1 in {
1936 def VMOVDQArm : VPDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1937 "movdqa\t{$src, $dst|$dst, $src}",
1938 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>,
1940 def VMOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1941 "vmovdqu\t{$src, $dst|$dst, $src}",
1942 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
1943 XS, VEX, Requires<[HasAVX]>;
1946 let mayStore = 1 in {
1947 def VMOVDQAmr : VPDI<0x7F, MRMDestMem, (outs),
1948 (ins i128mem:$dst, VR128:$src),
1949 "movdqa\t{$src, $dst|$dst, $src}",
1950 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>, VEX;
1951 def VMOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1952 "vmovdqu\t{$src, $dst|$dst, $src}",
1953 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
1954 XS, VEX, Requires<[HasAVX]>;
1958 let neverHasSideEffects = 1 in
1959 def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1960 "movdqa\t{$src, $dst|$dst, $src}", []>;
1962 let canFoldAsLoad = 1, mayLoad = 1 in {
1963 def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1964 "movdqa\t{$src, $dst|$dst, $src}",
1965 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
1966 def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1967 "movdqu\t{$src, $dst|$dst, $src}",
1968 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
1969 XS, Requires<[HasSSE2]>;
1972 let mayStore = 1 in {
1973 def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1974 "movdqa\t{$src, $dst|$dst, $src}",
1975 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
1976 def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1977 "movdqu\t{$src, $dst|$dst, $src}",
1978 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
1979 XS, Requires<[HasSSE2]>;
1982 // Intrinsic forms of MOVDQU load and store
1983 let isAsmParserOnly = 1 in {
1984 let canFoldAsLoad = 1 in
1985 def VMOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1986 "vmovdqu\t{$src, $dst|$dst, $src}",
1987 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1988 XS, VEX, Requires<[HasAVX]>;
1989 def VMOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
1990 "vmovdqu\t{$src, $dst|$dst, $src}",
1991 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1992 XS, VEX, Requires<[HasAVX]>;
1995 let canFoldAsLoad = 1 in
1996 def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
1997 "movdqu\t{$src, $dst|$dst, $src}",
1998 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1999 XS, Requires<[HasSSE2]>;
2000 def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2001 "movdqu\t{$src, $dst|$dst, $src}",
2002 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
2003 XS, Requires<[HasSSE2]>;
2005 } // ExeDomain = SSEPackedInt
2007 //===---------------------------------------------------------------------===//
2008 // SSE2 - Packed Integer Arithmetic Instructions
2009 //===---------------------------------------------------------------------===//
2011 let ExeDomain = SSEPackedInt in { // SSE integer instructions
2013 multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
2014 bit IsCommutable = 0, bit Is2Addr = 1> {
2015 let isCommutable = IsCommutable in
2016 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
2017 (ins VR128:$src1, VR128:$src2),
2019 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2020 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2021 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
2022 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2023 (ins VR128:$src1, i128mem:$src2),
2025 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2026 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2027 [(set VR128:$dst, (IntId VR128:$src1,
2028 (bitconvert (memopv2i64 addr:$src2))))]>;
2031 multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
2032 string OpcodeStr, Intrinsic IntId,
2033 Intrinsic IntId2, bit Is2Addr = 1> {
2034 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
2035 (ins VR128:$src1, VR128:$src2),
2037 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2038 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2039 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
2040 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2041 (ins VR128:$src1, i128mem:$src2),
2043 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2044 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2045 [(set VR128:$dst, (IntId VR128:$src1,
2046 (bitconvert (memopv2i64 addr:$src2))))]>;
2047 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst),
2048 (ins VR128:$src1, i32i8imm:$src2),
2050 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2051 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2052 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
2055 /// PDI_binop_rm - Simple SSE2 binary operator.
2056 multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
2057 ValueType OpVT, bit IsCommutable = 0, bit Is2Addr = 1> {
2058 let isCommutable = IsCommutable in
2059 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
2060 (ins VR128:$src1, VR128:$src2),
2062 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2063 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2064 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]>;
2065 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2066 (ins VR128:$src1, i128mem:$src2),
2068 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2069 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2070 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
2071 (bitconvert (memopv2i64 addr:$src2)))))]>;
2074 /// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
2076 /// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
2077 /// to collapse (bitconvert VT to VT) into its operand.
2079 multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
2080 bit IsCommutable = 0, bit Is2Addr = 1> {
2081 let isCommutable = IsCommutable in
2082 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
2083 (ins VR128:$src1, VR128:$src2),
2085 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2086 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2087 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]>;
2088 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2089 (ins VR128:$src1, i128mem:$src2),
2091 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2092 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2093 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2i64 addr:$src2)))]>;
2096 } // ExeDomain = SSEPackedInt
2098 // 128-bit Integer Arithmetic
2100 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
2101 defm VPADDB : PDI_binop_rm<0xFC, "vpaddb", add, v16i8, 1, 0 /*3addr*/>, VEX_4V;
2102 defm VPADDW : PDI_binop_rm<0xFD, "vpaddw", add, v8i16, 1, 0>, VEX_4V;
2103 defm VPADDD : PDI_binop_rm<0xFE, "vpaddd", add, v4i32, 1, 0>, VEX_4V;
2104 defm VPADDQ : PDI_binop_rm_v2i64<0xD4, "vpaddq", add, 1, 0>, VEX_4V;
2105 defm VPMULLW : PDI_binop_rm<0xD5, "vpmullw", mul, v8i16, 1, 0>, VEX_4V;
2106 defm VPSUBB : PDI_binop_rm<0xF8, "vpsubb", sub, v16i8, 0, 0>, VEX_4V;
2107 defm VPSUBW : PDI_binop_rm<0xF9, "vpsubw", sub, v8i16, 0, 0>, VEX_4V;
2108 defm VPSUBD : PDI_binop_rm<0xFA, "vpsubd", sub, v4i32, 0, 0>, VEX_4V;
2109 defm VPSUBQ : PDI_binop_rm_v2i64<0xFB, "vpsubq", sub, 0, 0>, VEX_4V;
2112 defm VPSUBSB : PDI_binop_rm_int<0xE8, "vpsubsb" , int_x86_sse2_psubs_b, 0, 0>,
2114 defm VPSUBSW : PDI_binop_rm_int<0xE9, "vpsubsw" , int_x86_sse2_psubs_w, 0, 0>,
2116 defm VPSUBUSB : PDI_binop_rm_int<0xD8, "vpsubusb", int_x86_sse2_psubus_b, 0, 0>,
2118 defm VPSUBUSW : PDI_binop_rm_int<0xD9, "vpsubusw", int_x86_sse2_psubus_w, 0, 0>,
2120 defm VPADDSB : PDI_binop_rm_int<0xEC, "vpaddsb" , int_x86_sse2_padds_b, 1, 0>,
2122 defm VPADDSW : PDI_binop_rm_int<0xED, "vpaddsw" , int_x86_sse2_padds_w, 1, 0>,
2124 defm VPADDUSB : PDI_binop_rm_int<0xDC, "vpaddusb", int_x86_sse2_paddus_b, 1, 0>,
2126 defm VPADDUSW : PDI_binop_rm_int<0xDD, "vpaddusw", int_x86_sse2_paddus_w, 1, 0>,
2128 defm VPMULHUW : PDI_binop_rm_int<0xE4, "vpmulhuw", int_x86_sse2_pmulhu_w, 1, 0>,
2130 defm VPMULHW : PDI_binop_rm_int<0xE5, "vpmulhw" , int_x86_sse2_pmulh_w, 1, 0>,
2132 defm VPMULUDQ : PDI_binop_rm_int<0xF4, "vpmuludq", int_x86_sse2_pmulu_dq, 1, 0>,
2134 defm VPMADDWD : PDI_binop_rm_int<0xF5, "vpmaddwd", int_x86_sse2_pmadd_wd, 1, 0>,
2136 defm VPAVGB : PDI_binop_rm_int<0xE0, "vpavgb", int_x86_sse2_pavg_b, 1, 0>,
2138 defm VPAVGW : PDI_binop_rm_int<0xE3, "vpavgw", int_x86_sse2_pavg_w, 1, 0>,
2140 defm VPMINUB : PDI_binop_rm_int<0xDA, "vpminub", int_x86_sse2_pminu_b, 1, 0>,
2142 defm VPMINSW : PDI_binop_rm_int<0xEA, "vpminsw", int_x86_sse2_pmins_w, 1, 0>,
2144 defm VPMAXUB : PDI_binop_rm_int<0xDE, "vpmaxub", int_x86_sse2_pmaxu_b, 1, 0>,
2146 defm VPMAXSW : PDI_binop_rm_int<0xEE, "vpmaxsw", int_x86_sse2_pmaxs_w, 1, 0>,
2148 defm VPSADBW : PDI_binop_rm_int<0xF6, "vpsadbw", int_x86_sse2_psad_bw, 1, 0>,
2152 let Constraints = "$src1 = $dst" in {
2153 defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
2154 defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
2155 defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
2156 defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
2157 defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
2158 defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
2159 defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
2160 defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
2161 defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
2164 defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
2165 defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
2166 defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
2167 defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
2168 defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
2169 defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
2170 defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
2171 defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
2172 defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
2173 defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w, 1>;
2174 defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
2175 defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
2176 defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
2177 defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
2178 defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
2179 defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
2180 defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
2181 defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
2182 defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
2184 } // Constraints = "$src1 = $dst"
2186 //===---------------------------------------------------------------------===//
2187 // SSE2 - Packed Integer Logical Instructions
2188 //===---------------------------------------------------------------------===//
2190 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
2191 defm VPSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "vpsllw",
2192 int_x86_sse2_psll_w, int_x86_sse2_pslli_w, 0>,
2194 defm VPSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "vpslld",
2195 int_x86_sse2_psll_d, int_x86_sse2_pslli_d, 0>,
2197 defm VPSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "vpsllq",
2198 int_x86_sse2_psll_q, int_x86_sse2_pslli_q, 0>,
2201 defm VPSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "vpsrlw",
2202 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w, 0>,
2204 defm VPSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "vpsrld",
2205 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d, 0>,
2207 defm VPSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "vpsrlq",
2208 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q, 0>,
2211 defm VPSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "vpsraw",
2212 int_x86_sse2_psra_w, int_x86_sse2_psrai_w, 0>,
2214 defm VPSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "vpsrad",
2215 int_x86_sse2_psra_d, int_x86_sse2_psrai_d, 0>,
2218 defm VPAND : PDI_binop_rm_v2i64<0xDB, "vpand", and, 1, 0>, VEX_4V;
2219 defm VPOR : PDI_binop_rm_v2i64<0xEB, "vpor" , or, 1, 0>, VEX_4V;
2220 defm VPXOR : PDI_binop_rm_v2i64<0xEF, "vpxor", xor, 1, 0>, VEX_4V;
2222 let ExeDomain = SSEPackedInt in {
2223 let neverHasSideEffects = 1 in {
2224 // 128-bit logical shifts.
2225 def VPSLLDQri : PDIi8<0x73, MRM7r,
2226 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
2227 "vpslldq\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>,
2229 def VPSRLDQri : PDIi8<0x73, MRM3r,
2230 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
2231 "vpsrldq\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>,
2233 // PSRADQri doesn't exist in SSE[1-3].
2235 def VPANDNrr : PDI<0xDF, MRMSrcReg,
2236 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2237 "vpandn\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2238 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2239 VR128:$src2)))]>, VEX_4V;
2241 def VPANDNrm : PDI<0xDF, MRMSrcMem,
2242 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2243 "vpandn\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2244 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2245 (memopv2i64 addr:$src2))))]>,
2250 let Constraints = "$src1 = $dst" in {
2251 defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
2252 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
2253 defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
2254 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
2255 defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
2256 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
2258 defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
2259 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
2260 defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
2261 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
2262 defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
2263 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
2265 defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
2266 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
2267 defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
2268 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
2270 defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2271 defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or, 1>;
2272 defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2274 let ExeDomain = SSEPackedInt in {
2275 let neverHasSideEffects = 1 in {
2276 // 128-bit logical shifts.
2277 def PSLLDQri : PDIi8<0x73, MRM7r,
2278 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
2279 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
2280 def PSRLDQri : PDIi8<0x73, MRM3r,
2281 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
2282 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
2283 // PSRADQri doesn't exist in SSE[1-3].
2285 def PANDNrr : PDI<0xDF, MRMSrcReg,
2286 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2287 "pandn\t{$src2, $dst|$dst, $src2}",
2288 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2291 def PANDNrm : PDI<0xDF, MRMSrcMem,
2292 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2293 "pandn\t{$src2, $dst|$dst, $src2}",
2294 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2295 (memopv2i64 addr:$src2))))]>;
2297 } // Constraints = "$src1 = $dst"
2299 let Predicates = [HasSSE2] in {
2300 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
2301 (v2i64 (PSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
2302 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
2303 (v2i64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
2304 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2305 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
2306 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2307 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
2308 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
2309 (v2f64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
2311 // Shift up / down and insert zero's.
2312 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
2313 (v2i64 (PSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
2314 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
2315 (v2i64 (PSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
2318 //===---------------------------------------------------------------------===//
2319 // SSE2 - Packed Integer Comparison Instructions
2320 //===---------------------------------------------------------------------===//
2322 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
2323 defm VPCMPEQB : PDI_binop_rm_int<0x74, "vpcmpeqb", int_x86_sse2_pcmpeq_b, 1,
2325 defm VPCMPEQW : PDI_binop_rm_int<0x75, "vpcmpeqw", int_x86_sse2_pcmpeq_w, 1,
2327 defm VPCMPEQD : PDI_binop_rm_int<0x76, "vpcmpeqd", int_x86_sse2_pcmpeq_d, 1,
2329 defm VPCMPGTB : PDI_binop_rm_int<0x64, "vpcmpgtb", int_x86_sse2_pcmpgt_b, 0,
2331 defm VPCMPGTW : PDI_binop_rm_int<0x65, "vpcmpgtw", int_x86_sse2_pcmpgt_w, 0,
2333 defm VPCMPGTD : PDI_binop_rm_int<0x66, "vpcmpgtd", int_x86_sse2_pcmpgt_d, 0,
2337 let Constraints = "$src1 = $dst" in {
2338 defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b, 1>;
2339 defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w, 1>;
2340 defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d, 1>;
2341 defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2342 defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2343 defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
2344 } // Constraints = "$src1 = $dst"
2346 def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
2347 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
2348 def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
2349 (PCMPEQBrm VR128:$src1, addr:$src2)>;
2350 def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
2351 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
2352 def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
2353 (PCMPEQWrm VR128:$src1, addr:$src2)>;
2354 def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
2355 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
2356 def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
2357 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2359 def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
2360 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
2361 def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
2362 (PCMPGTBrm VR128:$src1, addr:$src2)>;
2363 def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
2364 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
2365 def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
2366 (PCMPGTWrm VR128:$src1, addr:$src2)>;
2367 def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
2368 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
2369 def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
2370 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2372 //===---------------------------------------------------------------------===//
2373 // SSE2 - Packed Integer Pack Instructions
2374 //===---------------------------------------------------------------------===//
2376 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
2377 defm VPACKSSWB : PDI_binop_rm_int<0x63, "vpacksswb", int_x86_sse2_packsswb_128,
2379 defm VPACKSSDW : PDI_binop_rm_int<0x6B, "vpackssdw", int_x86_sse2_packssdw_128,
2381 defm VPACKUSWB : PDI_binop_rm_int<0x67, "vpackuswb", int_x86_sse2_packuswb_128,
2385 let Constraints = "$src1 = $dst" in {
2386 defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2387 defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2388 defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2389 } // Constraints = "$src1 = $dst"
2391 //===---------------------------------------------------------------------===//
2392 // SSE2 - Packed Integer Shuffle Instructions
2393 //===---------------------------------------------------------------------===//
2395 let ExeDomain = SSEPackedInt in {
2396 multiclass sse2_pshuffle<string OpcodeStr, ValueType vt, PatFrag pshuf_frag,
2398 def ri : Ii8<0x70, MRMSrcReg,
2399 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
2400 !strconcat(OpcodeStr,
2401 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
2402 [(set VR128:$dst, (vt (pshuf_frag:$src2 VR128:$src1,
2404 def mi : Ii8<0x70, MRMSrcMem,
2405 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
2406 !strconcat(OpcodeStr,
2407 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
2408 [(set VR128:$dst, (vt (pshuf_frag:$src2
2409 (bc_frag (memopv2i64 addr:$src1)),
2412 } // ExeDomain = SSEPackedInt
2414 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
2415 let AddedComplexity = 5 in
2416 defm VPSHUFD : sse2_pshuffle<"vpshufd", v4i32, pshufd, bc_v4i32>, OpSize,
2419 // SSE2 with ImmT == Imm8 and XS prefix.
2420 defm VPSHUFHW : sse2_pshuffle<"vpshufhw", v8i16, pshufhw, bc_v8i16>, XS,
2423 // SSE2 with ImmT == Imm8 and XD prefix.
2424 defm VPSHUFLW : sse2_pshuffle<"vpshuflw", v8i16, pshuflw, bc_v8i16>, XD,
2428 let Predicates = [HasSSE2] in {
2429 let AddedComplexity = 5 in
2430 defm PSHUFD : sse2_pshuffle<"pshufd", v4i32, pshufd, bc_v4i32>, TB, OpSize;
2432 // SSE2 with ImmT == Imm8 and XS prefix.
2433 defm PSHUFHW : sse2_pshuffle<"pshufhw", v8i16, pshufhw, bc_v8i16>, XS;
2435 // SSE2 with ImmT == Imm8 and XD prefix.
2436 defm PSHUFLW : sse2_pshuffle<"pshuflw", v8i16, pshuflw, bc_v8i16>, XD;
2439 //===---------------------------------------------------------------------===//
2440 // SSE2 - Packed Integer Unpack Instructions
2441 //===---------------------------------------------------------------------===//
2443 let ExeDomain = SSEPackedInt in {
2444 multiclass sse2_unpack<bits<8> opc, string OpcodeStr, ValueType vt,
2445 PatFrag unp_frag, PatFrag bc_frag, bit Is2Addr = 1> {
2446 def rr : PDI<opc, MRMSrcReg,
2447 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2449 !strconcat(OpcodeStr,"\t{$src2, $dst|$dst, $src2}"),
2450 !strconcat(OpcodeStr,"\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2451 [(set VR128:$dst, (vt (unp_frag VR128:$src1, VR128:$src2)))]>;
2452 def rm : PDI<opc, MRMSrcMem,
2453 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2455 !strconcat(OpcodeStr,"\t{$src2, $dst|$dst, $src2}"),
2456 !strconcat(OpcodeStr,"\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2457 [(set VR128:$dst, (unp_frag VR128:$src1,
2458 (bc_frag (memopv2i64
2462 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
2463 defm VPUNPCKLBW : sse2_unpack<0x60, "vpunpcklbw", v16i8, unpckl, bc_v16i8,
2465 defm VPUNPCKLWD : sse2_unpack<0x61, "vpunpcklwd", v8i16, unpckl, bc_v8i16,
2467 defm VPUNPCKLDQ : sse2_unpack<0x62, "vpunpckldq", v4i32, unpckl, bc_v4i32,
2470 /// FIXME: we could eliminate this and use sse2_unpack instead if tblgen
2471 /// knew to collapse (bitconvert VT to VT) into its operand.
2472 def VPUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
2473 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2474 "vpunpcklqdq\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2476 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>, VEX_4V;
2477 def VPUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
2478 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2479 "vpunpcklqdq\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2481 (v2i64 (unpckl VR128:$src1,
2482 (memopv2i64 addr:$src2))))]>, VEX_4V;
2484 defm VPUNPCKHBW : sse2_unpack<0x68, "vpunpckhbw", v16i8, unpckh, bc_v16i8,
2486 defm VPUNPCKHWD : sse2_unpack<0x69, "vpunpckhwd", v8i16, unpckh, bc_v8i16,
2488 defm VPUNPCKHDQ : sse2_unpack<0x6A, "vpunpckhdq", v4i32, unpckh, bc_v4i32,
2491 /// FIXME: we could eliminate this and use sse2_unpack instead if tblgen
2492 /// knew to collapse (bitconvert VT to VT) into its operand.
2493 def VPUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
2494 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2495 "vpunpckhqdq\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2497 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>, VEX_4V;
2498 def VPUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
2499 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2500 "vpunpckhqdq\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2502 (v2i64 (unpckh VR128:$src1,
2503 (memopv2i64 addr:$src2))))]>, VEX_4V;
2506 let Constraints = "$src1 = $dst" in {
2507 defm PUNPCKLBW : sse2_unpack<0x60, "punpcklbw", v16i8, unpckl, bc_v16i8>;
2508 defm PUNPCKLWD : sse2_unpack<0x61, "punpcklwd", v8i16, unpckl, bc_v8i16>;
2509 defm PUNPCKLDQ : sse2_unpack<0x62, "punpckldq", v4i32, unpckl, bc_v4i32>;
2511 /// FIXME: we could eliminate this and use sse2_unpack instead if tblgen
2512 /// knew to collapse (bitconvert VT to VT) into its operand.
2513 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
2514 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2515 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
2517 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
2518 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
2519 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2520 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
2522 (v2i64 (unpckl VR128:$src1,
2523 (memopv2i64 addr:$src2))))]>;
2525 defm PUNPCKHBW : sse2_unpack<0x68, "punpckhbw", v16i8, unpckh, bc_v16i8>;
2526 defm PUNPCKHWD : sse2_unpack<0x69, "punpckhwd", v8i16, unpckh, bc_v8i16>;
2527 defm PUNPCKHDQ : sse2_unpack<0x6A, "punpckhdq", v4i32, unpckh, bc_v4i32>;
2529 /// FIXME: we could eliminate this and use sse2_unpack instead if tblgen
2530 /// knew to collapse (bitconvert VT to VT) into its operand.
2531 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
2532 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2533 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
2535 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
2536 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
2537 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2538 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
2540 (v2i64 (unpckh VR128:$src1,
2541 (memopv2i64 addr:$src2))))]>;
2544 } // ExeDomain = SSEPackedInt
2546 //===---------------------------------------------------------------------===//
2547 // SSE2 - Packed Integer Extract and Insert
2548 //===---------------------------------------------------------------------===//
2550 let ExeDomain = SSEPackedInt in {
2551 multiclass sse2_pinsrw<bit Is2Addr = 1> {
2552 def rri : Ii8<0xC4, MRMSrcReg,
2553 (outs VR128:$dst), (ins VR128:$src1,
2554 GR32:$src2, i32i8imm:$src3),
2556 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2557 "vpinsrw\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
2559 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
2560 def rmi : Ii8<0xC4, MRMSrcMem,
2561 (outs VR128:$dst), (ins VR128:$src1,
2562 i16mem:$src2, i32i8imm:$src3),
2564 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2565 "vpinsrw\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
2567 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2572 let isAsmParserOnly = 1, Predicates = [HasAVX] in
2573 def VPEXTRWri : Ii8<0xC5, MRMSrcReg,
2574 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
2575 "vpextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2576 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
2577 imm:$src2))]>, OpSize, VEX;
2578 def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
2579 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
2580 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2581 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
2585 let isAsmParserOnly = 1, Predicates = [HasAVX] in
2586 defm PINSRW : sse2_pinsrw<0>, OpSize, VEX_4V;
2588 let Constraints = "$src1 = $dst" in
2589 defm VPINSRW : sse2_pinsrw, TB, OpSize;
2591 } // ExeDomain = SSEPackedInt
2593 //===---------------------------------------------------------------------===//
2594 // SSE2 - Packed Mask Creation
2595 //===---------------------------------------------------------------------===//
2597 let ExeDomain = SSEPackedInt in {
2599 let isAsmParserOnly = 1 in
2600 def VPMOVMSKBrr : VPDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
2601 "pmovmskb\t{$src, $dst|$dst, $src}",
2602 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>, VEX;
2603 def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
2604 "pmovmskb\t{$src, $dst|$dst, $src}",
2605 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2607 } // ExeDomain = SSEPackedInt
2609 //===---------------------------------------------------------------------===//
2610 // SSE2 - Conditional Store
2611 //===---------------------------------------------------------------------===//
2613 let ExeDomain = SSEPackedInt in {
2615 let isAsmParserOnly = 1 in {
2617 def VMASKMOVDQU : VPDI<0xF7, MRMSrcReg, (outs),
2618 (ins VR128:$src, VR128:$mask),
2619 "maskmovdqu\t{$mask, $src|$src, $mask}",
2620 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>, VEX;
2622 def VMASKMOVDQU64 : VPDI<0xF7, MRMSrcReg, (outs),
2623 (ins VR128:$src, VR128:$mask),
2624 "maskmovdqu\t{$mask, $src|$src, $mask}",
2625 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>, VEX;
2629 def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2630 "maskmovdqu\t{$mask, $src|$src, $mask}",
2631 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
2633 def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2634 "maskmovdqu\t{$mask, $src|$src, $mask}",
2635 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2637 } // ExeDomain = SSEPackedInt
2639 //===---------------------------------------------------------------------===//
2640 // SSE2 - Move Doubleword
2641 //===---------------------------------------------------------------------===//
2643 // Move Int Doubleword to Packed Double Int
2644 let isAsmParserOnly = 1 in {
2645 def VMOVDI2PDIrr : VPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2646 "movd\t{$src, $dst|$dst, $src}",
2648 (v4i32 (scalar_to_vector GR32:$src)))]>, VEX;
2649 def VMOVDI2PDIrm : VPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2650 "movd\t{$src, $dst|$dst, $src}",
2652 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>,
2655 def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2656 "movd\t{$src, $dst|$dst, $src}",
2658 (v4i32 (scalar_to_vector GR32:$src)))]>;
2659 def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2660 "movd\t{$src, $dst|$dst, $src}",
2662 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2665 // Move Int Doubleword to Single Scalar
2666 let isAsmParserOnly = 1 in {
2667 def VMOVDI2SSrr : VPDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
2668 "movd\t{$src, $dst|$dst, $src}",
2669 [(set FR32:$dst, (bitconvert GR32:$src))]>, VEX;
2671 def VMOVDI2SSrm : VPDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
2672 "movd\t{$src, $dst|$dst, $src}",
2673 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>,
2676 def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
2677 "movd\t{$src, $dst|$dst, $src}",
2678 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2680 def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
2681 "movd\t{$src, $dst|$dst, $src}",
2682 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2684 // Move Packed Doubleword Int to Packed Double Int
2685 let isAsmParserOnly = 1 in {
2686 def VMOVPDI2DIrr : VPDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
2687 "movd\t{$src, $dst|$dst, $src}",
2688 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2690 def VMOVPDI2DImr : VPDI<0x7E, MRMDestMem, (outs),
2691 (ins i32mem:$dst, VR128:$src),
2692 "movd\t{$src, $dst|$dst, $src}",
2693 [(store (i32 (vector_extract (v4i32 VR128:$src),
2694 (iPTR 0))), addr:$dst)]>, VEX;
2696 def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
2697 "movd\t{$src, $dst|$dst, $src}",
2698 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2700 def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
2701 "movd\t{$src, $dst|$dst, $src}",
2702 [(store (i32 (vector_extract (v4i32 VR128:$src),
2703 (iPTR 0))), addr:$dst)]>;
2705 // Move Scalar Single to Double Int
2706 let isAsmParserOnly = 1 in {
2707 def VMOVSS2DIrr : VPDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
2708 "movd\t{$src, $dst|$dst, $src}",
2709 [(set GR32:$dst, (bitconvert FR32:$src))]>, VEX;
2710 def VMOVSS2DImr : VPDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
2711 "movd\t{$src, $dst|$dst, $src}",
2712 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>, VEX;
2714 def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
2715 "movd\t{$src, $dst|$dst, $src}",
2716 [(set GR32:$dst, (bitconvert FR32:$src))]>;
2717 def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
2718 "movd\t{$src, $dst|$dst, $src}",
2719 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2721 // movd / movq to XMM register zero-extends
2722 let AddedComplexity = 15, isAsmParserOnly = 1 in {
2723 def VMOVZDI2PDIrr : VPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2724 "movd\t{$src, $dst|$dst, $src}",
2725 [(set VR128:$dst, (v4i32 (X86vzmovl
2726 (v4i32 (scalar_to_vector GR32:$src)))))]>,
2728 def VMOVZQI2PQIrr : VPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2729 "mov{d|q}\t{$src, $dst|$dst, $src}", // X86-64 only
2730 [(set VR128:$dst, (v2i64 (X86vzmovl
2731 (v2i64 (scalar_to_vector GR64:$src)))))]>,
2734 let AddedComplexity = 15 in {
2735 def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2736 "movd\t{$src, $dst|$dst, $src}",
2737 [(set VR128:$dst, (v4i32 (X86vzmovl
2738 (v4i32 (scalar_to_vector GR32:$src)))))]>;
2739 def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2740 "mov{d|q}\t{$src, $dst|$dst, $src}", // X86-64 only
2741 [(set VR128:$dst, (v2i64 (X86vzmovl
2742 (v2i64 (scalar_to_vector GR64:$src)))))]>;
2745 let AddedComplexity = 20 in {
2746 let isAsmParserOnly = 1 in
2747 def VMOVZDI2PDIrm : VPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2748 "movd\t{$src, $dst|$dst, $src}",
2750 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
2751 (loadi32 addr:$src))))))]>,
2753 def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2754 "movd\t{$src, $dst|$dst, $src}",
2756 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
2757 (loadi32 addr:$src))))))]>;
2759 def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2760 (MOVZDI2PDIrm addr:$src)>;
2761 def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2762 (MOVZDI2PDIrm addr:$src)>;
2763 def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2764 (MOVZDI2PDIrm addr:$src)>;
2767 //===---------------------------------------------------------------------===//
2768 // SSE2 - Move Quadword
2769 //===---------------------------------------------------------------------===//
2771 // Move Quadword Int to Packed Quadword Int
2772 let isAsmParserOnly = 1 in
2773 def VMOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
2774 "vmovq\t{$src, $dst|$dst, $src}",
2776 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2777 VEX, Requires<[HasAVX]>;
2778 def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
2779 "movq\t{$src, $dst|$dst, $src}",
2781 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2782 Requires<[HasSSE2]>; // SSE2 instruction with XS Prefix
2784 // Move Packed Quadword Int to Quadword Int
2785 let isAsmParserOnly = 1 in
2786 def VMOVPQI2QImr : VPDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
2787 "movq\t{$src, $dst|$dst, $src}",
2788 [(store (i64 (vector_extract (v2i64 VR128:$src),
2789 (iPTR 0))), addr:$dst)]>, VEX;
2790 def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
2791 "movq\t{$src, $dst|$dst, $src}",
2792 [(store (i64 (vector_extract (v2i64 VR128:$src),
2793 (iPTR 0))), addr:$dst)]>;
2795 def : Pat<(f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
2796 (f64 (EXTRACT_SUBREG (v2f64 VR128:$src), sub_sd))>;
2798 // Store / copy lower 64-bits of a XMM register.
2799 let isAsmParserOnly = 1 in
2800 def VMOVLQ128mr : VPDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
2801 "movq\t{$src, $dst|$dst, $src}",
2802 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>, VEX;
2803 def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
2804 "movq\t{$src, $dst|$dst, $src}",
2805 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2807 let AddedComplexity = 20, isAsmParserOnly = 1 in
2808 def VMOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
2809 "vmovq\t{$src, $dst|$dst, $src}",
2811 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
2812 (loadi64 addr:$src))))))]>,
2813 XS, VEX, Requires<[HasAVX]>;
2815 let AddedComplexity = 20 in {
2816 def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
2817 "movq\t{$src, $dst|$dst, $src}",
2819 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
2820 (loadi64 addr:$src))))))]>,
2821 XS, Requires<[HasSSE2]>;
2823 def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2824 (MOVZQI2PQIrm addr:$src)>;
2825 def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2826 (MOVZQI2PQIrm addr:$src)>;
2827 def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
2830 // Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2831 // IA32 document. movq xmm1, xmm2 does clear the high bits.
2832 let isAsmParserOnly = 1, AddedComplexity = 15 in
2833 def VMOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2834 "vmovq\t{$src, $dst|$dst, $src}",
2835 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
2836 XS, VEX, Requires<[HasAVX]>;
2837 let AddedComplexity = 15 in
2838 def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2839 "movq\t{$src, $dst|$dst, $src}",
2840 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
2841 XS, Requires<[HasSSE2]>;
2843 let AddedComplexity = 20, isAsmParserOnly = 1 in
2844 def VMOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2845 "vmovq\t{$src, $dst|$dst, $src}",
2846 [(set VR128:$dst, (v2i64 (X86vzmovl
2847 (loadv2i64 addr:$src))))]>,
2848 XS, VEX, Requires<[HasAVX]>;
2849 let AddedComplexity = 20 in {
2850 def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2851 "movq\t{$src, $dst|$dst, $src}",
2852 [(set VR128:$dst, (v2i64 (X86vzmovl
2853 (loadv2i64 addr:$src))))]>,
2854 XS, Requires<[HasSSE2]>;
2856 def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2857 (MOVZPQILo2PQIrm addr:$src)>;
2860 // Instructions to match in the assembler
2861 let isAsmParserOnly = 1 in {
2862 // This instructions is in fact an alias to movd with 64 bit dst
2863 def VMOVQs64rr : VPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2864 "movq\t{$src, $dst|$dst, $src}", []>, VEX, VEX_W;
2865 def VMOVQd64rr : VPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
2866 "movq\t{$src, $dst|$dst, $src}", []>, VEX, VEX_W;
2869 // Instructions for the disassembler
2870 // xr = XMM register
2873 let isAsmParserOnly = 1 in
2874 def VMOVQxrxr: I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2875 "vmovq\t{$src, $dst|$dst, $src}", []>, VEX, XS;
2876 def MOVQxrxr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2877 "movq\t{$src, $dst|$dst, $src}", []>, XS;
2879 //===---------------------------------------------------------------------===//
2880 // SSE2 - Misc Instructions
2881 //===---------------------------------------------------------------------===//
2884 def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
2885 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
2886 TB, Requires<[HasSSE2]>;
2888 // Load, store, and memory fence
2889 def LFENCE : I<0xAE, MRM_E8, (outs), (ins),
2890 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
2891 def MFENCE : I<0xAE, MRM_F0, (outs), (ins),
2892 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2894 // Pause. This "instruction" is encoded as "rep; nop", so even though it
2895 // was introduced with SSE2, it's backward compatible.
2896 def PAUSE : I<0x90, RawFrm, (outs), (ins), "pause", []>, REP;
2898 //TODO: custom lower this so as to never even generate the noop
2899 def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm),
2901 def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2902 def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
2903 def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm),
2906 // Alias instructions that map zero vector to pxor / xorp* for sse.
2907 // We set canFoldAsLoad because this can be converted to a constant-pool
2908 // load of an all-ones value if folding it would be beneficial.
2909 let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2910 isCodeGenOnly = 1, ExeDomain = SSEPackedInt in
2911 // FIXME: Change encoding to pseudo.
2912 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "",
2913 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
2915 //===---------------------------------------------------------------------===//
2916 // SSE3 - Conversion Instructions
2917 //===---------------------------------------------------------------------===//
2919 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
2920 def VCVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2921 "vcvtpd2dq\t{$src, $dst|$dst, $src}", []>, VEX;
2922 def VCVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
2923 "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX;
2924 def VCVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2925 "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX;
2928 def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
2929 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
2930 def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2931 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
2932 def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
2933 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
2934 def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2935 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
2937 //===---------------------------------------------------------------------===//
2938 // SSE3 - Move Instructions
2939 //===---------------------------------------------------------------------===//
2941 // Replicate Single FP
2942 multiclass sse3_replicate_sfp<bits<8> op, PatFrag rep_frag, string OpcodeStr> {
2943 def rr : S3SI<op, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2944 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2945 [(set VR128:$dst, (v4f32 (rep_frag
2946 VR128:$src, (undef))))]>;
2947 def rm : S3SI<op, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
2948 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2949 [(set VR128:$dst, (rep_frag
2950 (memopv4f32 addr:$src), (undef)))]>;
2953 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
2954 defm VMOVSHDUP : sse3_replicate_sfp<0x16, movshdup, "vmovshdup">, VEX;
2955 defm VMOVSLDUP : sse3_replicate_sfp<0x12, movsldup, "vmovsldup">, VEX;
2957 defm MOVSHDUP : sse3_replicate_sfp<0x16, movshdup, "movshdup">;
2958 defm MOVSLDUP : sse3_replicate_sfp<0x12, movsldup, "movsldup">;
2960 // Replicate Double FP
2961 multiclass sse3_replicate_dfp<string OpcodeStr> {
2962 def rr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2963 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2964 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
2965 def rm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2966 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2968 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2972 let isAsmParserOnly = 1, Predicates = [HasAVX] in
2973 defm VMOVDDUP : sse3_replicate_dfp<"vmovddup">, VEX;
2974 defm MOVDDUP : sse3_replicate_dfp<"movddup">;
2976 // Move Unaligned Integer
2977 let isAsmParserOnly = 1 in
2978 def VLDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2979 "vlddqu\t{$src, $dst|$dst, $src}",
2980 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>, VEX;
2981 def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2982 "lddqu\t{$src, $dst|$dst, $src}",
2983 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2985 def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2987 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2989 // Several Move patterns
2990 let AddedComplexity = 5 in {
2991 def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
2992 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2993 def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2994 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2995 def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2996 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2997 def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2998 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
3001 // vector_shuffle v1, <undef> <1, 1, 3, 3>
3002 let AddedComplexity = 15 in
3003 def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
3004 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
3005 let AddedComplexity = 20 in
3006 def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
3007 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
3009 // vector_shuffle v1, <undef> <0, 0, 2, 2>
3010 let AddedComplexity = 15 in
3011 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
3012 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
3013 let AddedComplexity = 20 in
3014 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
3015 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
3017 //===---------------------------------------------------------------------===//
3018 // SSE3 - Arithmetic
3019 //===---------------------------------------------------------------------===//
3021 multiclass sse3_addsub<Intrinsic Int, string OpcodeStr, bit Is2Addr = 1> {
3022 def rr : I<0xD0, MRMSrcReg,
3023 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
3025 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3026 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3027 [(set VR128:$dst, (Int VR128:$src1,
3029 def rm : I<0xD0, MRMSrcMem,
3030 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
3032 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3033 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3034 [(set VR128:$dst, (Int VR128:$src1,
3035 (memop addr:$src2)))]>;
3039 let isAsmParserOnly = 1, Predicates = [HasAVX],
3040 ExeDomain = SSEPackedDouble in {
3041 defm VADDSUBPS : sse3_addsub<int_x86_sse3_addsub_ps, "vaddsubps", 0>, XD,
3043 defm VADDSUBPD : sse3_addsub<int_x86_sse3_addsub_pd, "vaddsubpd", 0>, OpSize,
3046 let Constraints = "$src1 = $dst", Predicates = [HasSSE3],
3047 ExeDomain = SSEPackedDouble in {
3048 defm ADDSUBPS : sse3_addsub<int_x86_sse3_addsub_ps, "addsubps">, XD;
3049 defm ADDSUBPD : sse3_addsub<int_x86_sse3_addsub_pd, "addsubpd">, TB, OpSize;
3052 //===---------------------------------------------------------------------===//
3053 // SSE3 Instructions
3054 //===---------------------------------------------------------------------===//
3057 class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId, bit Is2Addr = 1>
3058 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
3060 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3061 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3062 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
3063 class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId, bit Is2Addr = 1>
3064 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
3066 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3067 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3068 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
3069 class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId, bit Is2Addr = 1>
3070 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
3072 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3073 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3074 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
3075 class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId, bit Is2Addr = 1>
3076 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
3078 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3079 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3080 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
3082 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
3083 def VHADDPSrr : S3D_Intrr<0x7C, "vhaddps", int_x86_sse3_hadd_ps, 0>, VEX_4V;
3084 def VHADDPSrm : S3D_Intrm<0x7C, "vhaddps", int_x86_sse3_hadd_ps, 0>, VEX_4V;
3085 def VHADDPDrr : S3_Intrr <0x7C, "vhaddpd", int_x86_sse3_hadd_pd, 0>, VEX_4V;
3086 def VHADDPDrm : S3_Intrm <0x7C, "vhaddpd", int_x86_sse3_hadd_pd, 0>, VEX_4V;
3087 def VHSUBPSrr : S3D_Intrr<0x7D, "vhsubps", int_x86_sse3_hsub_ps, 0>, VEX_4V;
3088 def VHSUBPSrm : S3D_Intrm<0x7D, "vhsubps", int_x86_sse3_hsub_ps, 0>, VEX_4V;
3089 def VHSUBPDrr : S3_Intrr <0x7D, "vhsubpd", int_x86_sse3_hsub_pd, 0>, VEX_4V;
3090 def VHSUBPDrm : S3_Intrm <0x7D, "vhsubpd", int_x86_sse3_hsub_pd, 0>, VEX_4V;
3093 let Constraints = "$src1 = $dst" in {
3094 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
3095 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
3096 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
3097 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
3098 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
3099 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
3100 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
3101 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
3104 //===---------------------------------------------------------------------===//
3105 // SSSE3 - Packed Absolute Instructions
3106 //===---------------------------------------------------------------------===//
3108 /// SS3I_unop_rm_int - Simple SSSE3 unary op whose type can be v*{i8,i16,i32}.
3109 multiclass SS3I_unop_rm_int<bits<8> opc, string OpcodeStr,
3110 PatFrag mem_frag64, PatFrag mem_frag128,
3111 Intrinsic IntId64, Intrinsic IntId128> {
3112 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
3113 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3114 [(set VR64:$dst, (IntId64 VR64:$src))]>;
3116 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
3117 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3119 (IntId64 (bitconvert (mem_frag64 addr:$src))))]>;
3121 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
3123 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3124 [(set VR128:$dst, (IntId128 VR128:$src))]>,
3127 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
3129 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3132 (bitconvert (mem_frag128 addr:$src))))]>, OpSize;
3135 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
3136 defm VPABSB : SS3I_unop_rm_int<0x1C, "vpabsb", memopv8i8, memopv16i8,
3137 int_x86_ssse3_pabs_b,
3138 int_x86_ssse3_pabs_b_128>, VEX;
3139 defm VPABSW : SS3I_unop_rm_int<0x1D, "vpabsw", memopv4i16, memopv8i16,
3140 int_x86_ssse3_pabs_w,
3141 int_x86_ssse3_pabs_w_128>, VEX;
3142 defm VPABSD : SS3I_unop_rm_int<0x1E, "vpabsd", memopv2i32, memopv4i32,
3143 int_x86_ssse3_pabs_d,
3144 int_x86_ssse3_pabs_d_128>, VEX;
3147 defm PABSB : SS3I_unop_rm_int<0x1C, "pabsb", memopv8i8, memopv16i8,
3148 int_x86_ssse3_pabs_b,
3149 int_x86_ssse3_pabs_b_128>;
3150 defm PABSW : SS3I_unop_rm_int<0x1D, "pabsw", memopv4i16, memopv8i16,
3151 int_x86_ssse3_pabs_w,
3152 int_x86_ssse3_pabs_w_128>;
3153 defm PABSD : SS3I_unop_rm_int<0x1E, "pabsd", memopv2i32, memopv4i32,
3154 int_x86_ssse3_pabs_d,
3155 int_x86_ssse3_pabs_d_128>;
3157 //===---------------------------------------------------------------------===//
3158 // SSSE3 - Packed Binary Operator Instructions
3159 //===---------------------------------------------------------------------===//
3161 /// SS3I_binop_rm_int - Simple SSSE3 bin op whose type can be v*{i8,i16,i32}.
3162 multiclass SS3I_binop_rm_int<bits<8> opc, string OpcodeStr,
3163 PatFrag mem_frag64, PatFrag mem_frag128,
3164 Intrinsic IntId64, Intrinsic IntId128,
3166 let isCommutable = 1 in
3167 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
3168 (ins VR64:$src1, VR64:$src2),
3170 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3171 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3172 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]>;
3173 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
3174 (ins VR64:$src1, i64mem:$src2),
3176 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3177 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3179 (IntId64 VR64:$src1,
3180 (bitconvert (memopv8i8 addr:$src2))))]>;
3182 let isCommutable = 1 in
3183 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
3184 (ins VR128:$src1, VR128:$src2),
3186 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3187 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3188 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3190 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
3191 (ins VR128:$src1, i128mem:$src2),
3193 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3194 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3196 (IntId128 VR128:$src1,
3197 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3200 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
3201 let isCommutable = 0 in {
3202 defm VPHADDW : SS3I_binop_rm_int<0x01, "vphaddw", memopv4i16, memopv8i16,
3203 int_x86_ssse3_phadd_w,
3204 int_x86_ssse3_phadd_w_128, 0>, VEX_4V;
3205 defm VPHADDD : SS3I_binop_rm_int<0x02, "vphaddd", memopv2i32, memopv4i32,
3206 int_x86_ssse3_phadd_d,
3207 int_x86_ssse3_phadd_d_128, 0>, VEX_4V;
3208 defm VPHADDSW : SS3I_binop_rm_int<0x03, "vphaddsw", memopv4i16, memopv8i16,
3209 int_x86_ssse3_phadd_sw,
3210 int_x86_ssse3_phadd_sw_128, 0>, VEX_4V;
3211 defm VPHSUBW : SS3I_binop_rm_int<0x05, "vphsubw", memopv4i16, memopv8i16,
3212 int_x86_ssse3_phsub_w,
3213 int_x86_ssse3_phsub_w_128, 0>, VEX_4V;
3214 defm VPHSUBD : SS3I_binop_rm_int<0x06, "vphsubd", memopv2i32, memopv4i32,
3215 int_x86_ssse3_phsub_d,
3216 int_x86_ssse3_phsub_d_128, 0>, VEX_4V;
3217 defm VPHSUBSW : SS3I_binop_rm_int<0x07, "vphsubsw", memopv4i16, memopv8i16,
3218 int_x86_ssse3_phsub_sw,
3219 int_x86_ssse3_phsub_sw_128, 0>, VEX_4V;
3220 defm VPMADDUBSW : SS3I_binop_rm_int<0x04, "vpmaddubsw", memopv8i8, memopv16i8,
3221 int_x86_ssse3_pmadd_ub_sw,
3222 int_x86_ssse3_pmadd_ub_sw_128, 0>, VEX_4V;
3223 defm VPSHUFB : SS3I_binop_rm_int<0x00, "vpshufb", memopv8i8, memopv16i8,
3224 int_x86_ssse3_pshuf_b,
3225 int_x86_ssse3_pshuf_b_128, 0>, VEX_4V;
3226 defm VPSIGNB : SS3I_binop_rm_int<0x08, "vpsignb", memopv8i8, memopv16i8,
3227 int_x86_ssse3_psign_b,
3228 int_x86_ssse3_psign_b_128, 0>, VEX_4V;
3229 defm VPSIGNW : SS3I_binop_rm_int<0x09, "vpsignw", memopv4i16, memopv8i16,
3230 int_x86_ssse3_psign_w,
3231 int_x86_ssse3_psign_w_128, 0>, VEX_4V;
3232 defm VPSIGND : SS3I_binop_rm_int<0x0A, "vpsignd", memopv2i32, memopv4i32,
3233 int_x86_ssse3_psign_d,
3234 int_x86_ssse3_psign_d_128, 0>, VEX_4V;
3236 defm VPMULHRSW : SS3I_binop_rm_int<0x0B, "vpmulhrsw", memopv4i16, memopv8i16,
3237 int_x86_ssse3_pmul_hr_sw,
3238 int_x86_ssse3_pmul_hr_sw_128, 0>, VEX_4V;
3241 // None of these have i8 immediate fields.
3242 let ImmT = NoImm, Constraints = "$src1 = $dst" in {
3243 let isCommutable = 0 in {
3244 defm PHADDW : SS3I_binop_rm_int<0x01, "phaddw", memopv4i16, memopv8i16,
3245 int_x86_ssse3_phadd_w,
3246 int_x86_ssse3_phadd_w_128>;
3247 defm PHADDD : SS3I_binop_rm_int<0x02, "phaddd", memopv2i32, memopv4i32,
3248 int_x86_ssse3_phadd_d,
3249 int_x86_ssse3_phadd_d_128>;
3250 defm PHADDSW : SS3I_binop_rm_int<0x03, "phaddsw", memopv4i16, memopv8i16,
3251 int_x86_ssse3_phadd_sw,
3252 int_x86_ssse3_phadd_sw_128>;
3253 defm PHSUBW : SS3I_binop_rm_int<0x05, "phsubw", memopv4i16, memopv8i16,
3254 int_x86_ssse3_phsub_w,
3255 int_x86_ssse3_phsub_w_128>;
3256 defm PHSUBD : SS3I_binop_rm_int<0x06, "phsubd", memopv2i32, memopv4i32,
3257 int_x86_ssse3_phsub_d,
3258 int_x86_ssse3_phsub_d_128>;
3259 defm PHSUBSW : SS3I_binop_rm_int<0x07, "phsubsw", memopv4i16, memopv8i16,
3260 int_x86_ssse3_phsub_sw,
3261 int_x86_ssse3_phsub_sw_128>;
3262 defm PMADDUBSW : SS3I_binop_rm_int<0x04, "pmaddubsw", memopv8i8, memopv16i8,
3263 int_x86_ssse3_pmadd_ub_sw,
3264 int_x86_ssse3_pmadd_ub_sw_128>;
3265 defm PSHUFB : SS3I_binop_rm_int<0x00, "pshufb", memopv8i8, memopv16i8,
3266 int_x86_ssse3_pshuf_b,
3267 int_x86_ssse3_pshuf_b_128>;
3268 defm PSIGNB : SS3I_binop_rm_int<0x08, "psignb", memopv8i8, memopv16i8,
3269 int_x86_ssse3_psign_b,
3270 int_x86_ssse3_psign_b_128>;
3271 defm PSIGNW : SS3I_binop_rm_int<0x09, "psignw", memopv4i16, memopv8i16,
3272 int_x86_ssse3_psign_w,
3273 int_x86_ssse3_psign_w_128>;
3274 defm PSIGND : SS3I_binop_rm_int<0x0A, "psignd", memopv2i32, memopv4i32,
3275 int_x86_ssse3_psign_d,
3276 int_x86_ssse3_psign_d_128>;
3278 defm PMULHRSW : SS3I_binop_rm_int<0x0B, "pmulhrsw", memopv4i16, memopv8i16,
3279 int_x86_ssse3_pmul_hr_sw,
3280 int_x86_ssse3_pmul_hr_sw_128>;
3283 def : Pat<(X86pshufb VR128:$src, VR128:$mask),
3284 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
3285 def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
3286 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
3288 //===---------------------------------------------------------------------===//
3289 // SSSE3 - Packed Align Instruction Patterns
3290 //===---------------------------------------------------------------------===//
3292 multiclass sse3_palign<string asm, bit Is2Addr = 1> {
3293 def R64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
3294 (ins VR64:$src1, VR64:$src2, i8imm:$src3),
3296 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3298 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
3300 def R64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
3301 (ins VR64:$src1, i64mem:$src2, i8imm:$src3),
3303 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3305 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
3308 def R128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
3309 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3311 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3313 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
3315 def R128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
3316 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3318 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3320 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
3324 let isAsmParserOnly = 1, Predicates = [HasAVX] in
3325 defm VPALIGN : sse3_palign<"vpalignr", 0>, VEX_4V;
3326 let Constraints = "$src1 = $dst" in
3327 defm PALIGN : sse3_palign<"palignr">;
3329 let AddedComplexity = 5 in {
3331 def : Pat<(v1i64 (palign:$src3 VR64:$src1, VR64:$src2)),
3332 (PALIGNR64rr VR64:$src2, VR64:$src1,
3333 (SHUFFLE_get_palign_imm VR64:$src3))>,
3334 Requires<[HasSSSE3]>;
3335 def : Pat<(v2i32 (palign:$src3 VR64:$src1, VR64:$src2)),
3336 (PALIGNR64rr VR64:$src2, VR64:$src1,
3337 (SHUFFLE_get_palign_imm VR64:$src3))>,
3338 Requires<[HasSSSE3]>;
3339 def : Pat<(v4i16 (palign:$src3 VR64:$src1, VR64:$src2)),
3340 (PALIGNR64rr VR64:$src2, VR64:$src1,
3341 (SHUFFLE_get_palign_imm VR64:$src3))>,
3342 Requires<[HasSSSE3]>;
3343 def : Pat<(v8i8 (palign:$src3 VR64:$src1, VR64:$src2)),
3344 (PALIGNR64rr VR64:$src2, VR64:$src1,
3345 (SHUFFLE_get_palign_imm VR64:$src3))>,
3346 Requires<[HasSSSE3]>;
3348 def : Pat<(v4i32 (palign:$src3 VR128:$src1, VR128:$src2)),
3349 (PALIGNR128rr VR128:$src2, VR128:$src1,
3350 (SHUFFLE_get_palign_imm VR128:$src3))>,
3351 Requires<[HasSSSE3]>;
3352 def : Pat<(v4f32 (palign:$src3 VR128:$src1, VR128:$src2)),
3353 (PALIGNR128rr VR128:$src2, VR128:$src1,
3354 (SHUFFLE_get_palign_imm VR128:$src3))>,
3355 Requires<[HasSSSE3]>;
3356 def : Pat<(v8i16 (palign:$src3 VR128:$src1, VR128:$src2)),
3357 (PALIGNR128rr VR128:$src2, VR128:$src1,
3358 (SHUFFLE_get_palign_imm VR128:$src3))>,
3359 Requires<[HasSSSE3]>;
3360 def : Pat<(v16i8 (palign:$src3 VR128:$src1, VR128:$src2)),
3361 (PALIGNR128rr VR128:$src2, VR128:$src1,
3362 (SHUFFLE_get_palign_imm VR128:$src3))>,
3363 Requires<[HasSSSE3]>;
3366 //===---------------------------------------------------------------------===//
3367 // SSSE3 Misc Instructions
3368 //===---------------------------------------------------------------------===//
3370 // Thread synchronization
3371 def MONITOR : I<0x01, MRM_C8, (outs), (ins), "monitor",
3372 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
3373 def MWAIT : I<0x01, MRM_C9, (outs), (ins), "mwait",
3374 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
3376 //===---------------------------------------------------------------------===//
3377 // Non-Instruction Patterns
3378 //===---------------------------------------------------------------------===//
3380 // extload f32 -> f64. This matches load+fextend because we have a hack in
3381 // the isel (PreprocessForFPConvert) that can introduce loads after dag
3383 // Since these loads aren't folded into the fextend, we have to match it
3385 let Predicates = [HasSSE2] in
3386 def : Pat<(fextend (loadf32 addr:$src)),
3387 (CVTSS2SDrm addr:$src)>;
3390 let Predicates = [HasSSE2] in {
3391 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
3392 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
3393 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
3394 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
3395 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
3396 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
3397 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
3398 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
3399 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
3400 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
3401 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
3402 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
3403 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
3404 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
3405 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
3406 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
3407 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
3408 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
3409 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
3410 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
3411 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
3412 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
3413 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
3414 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
3415 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
3416 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
3417 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
3418 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
3419 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
3420 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
3423 // Move scalar to XMM zero-extended
3424 // movd to XMM register zero-extends
3425 let AddedComplexity = 15 in {
3426 // Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
3427 def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
3428 (MOVSDrr (v2f64 (V_SET0PS)), FR64:$src)>;
3429 def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
3430 (MOVSSrr (v4f32 (V_SET0PS)), FR32:$src)>;
3431 def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
3432 (MOVSSrr (v4f32 (V_SET0PS)),
3433 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), sub_ss)))>;
3434 def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
3435 (MOVSSrr (v4i32 (V_SET0PI)),
3436 (EXTRACT_SUBREG (v4i32 VR128:$src), sub_ss))>;
3439 // Splat v2f64 / v2i64
3440 let AddedComplexity = 10 in {
3441 def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
3442 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
3443 def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
3444 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
3445 def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
3446 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
3447 def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
3448 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
3451 // Special unary SHUFPSrri case.
3452 def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
3453 (SHUFPSrri VR128:$src1, VR128:$src1,
3454 (SHUFFLE_get_shuf_imm VR128:$src3))>;
3455 let AddedComplexity = 5 in
3456 def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
3457 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3458 Requires<[HasSSE2]>;
3459 // Special unary SHUFPDrri case.
3460 def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
3461 (SHUFPDrri VR128:$src1, VR128:$src1,
3462 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3463 Requires<[HasSSE2]>;
3464 // Special unary SHUFPDrri case.
3465 def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
3466 (SHUFPDrri VR128:$src1, VR128:$src1,
3467 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3468 Requires<[HasSSE2]>;
3469 // Unary v4f32 shuffle with PSHUF* in order to fold a load.
3470 def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
3471 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3472 Requires<[HasSSE2]>;
3474 // Special binary v4i32 shuffle cases with SHUFPS.
3475 def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
3476 (SHUFPSrri VR128:$src1, VR128:$src2,
3477 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3478 Requires<[HasSSE2]>;
3479 def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
3480 (SHUFPSrmi VR128:$src1, addr:$src2,
3481 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3482 Requires<[HasSSE2]>;
3483 // Special binary v2i64 shuffle cases using SHUFPDrri.
3484 def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
3485 (SHUFPDrri VR128:$src1, VR128:$src2,
3486 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3487 Requires<[HasSSE2]>;
3489 // vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
3490 let AddedComplexity = 15 in {
3491 def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
3492 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3493 Requires<[OptForSpeed, HasSSE2]>;
3494 def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
3495 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3496 Requires<[OptForSpeed, HasSSE2]>;
3498 let AddedComplexity = 10 in {
3499 def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
3500 (UNPCKLPSrr VR128:$src, VR128:$src)>;
3501 def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
3502 (PUNPCKLBWrr VR128:$src, VR128:$src)>;
3503 def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
3504 (PUNPCKLWDrr VR128:$src, VR128:$src)>;
3505 def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
3506 (PUNPCKLDQrr VR128:$src, VR128:$src)>;
3509 // vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
3510 let AddedComplexity = 15 in {
3511 def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
3512 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3513 Requires<[OptForSpeed, HasSSE2]>;
3514 def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
3515 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3516 Requires<[OptForSpeed, HasSSE2]>;
3518 let AddedComplexity = 10 in {
3519 def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
3520 (UNPCKHPSrr VR128:$src, VR128:$src)>;
3521 def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
3522 (PUNPCKHBWrr VR128:$src, VR128:$src)>;
3523 def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
3524 (PUNPCKHWDrr VR128:$src, VR128:$src)>;
3525 def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
3526 (PUNPCKHDQrr VR128:$src, VR128:$src)>;
3529 let AddedComplexity = 20 in {
3530 // vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
3531 def : Pat<(v4i32 (movlhps VR128:$src1, VR128:$src2)),
3532 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
3534 // vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
3535 def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
3536 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
3538 // vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
3539 def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
3540 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
3541 def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
3542 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
3545 let AddedComplexity = 20 in {
3546 // vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
3547 def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
3548 (MOVLPSrm VR128:$src1, addr:$src2)>;
3549 def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
3550 (MOVLPDrm VR128:$src1, addr:$src2)>;
3551 def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
3552 (MOVLPSrm VR128:$src1, addr:$src2)>;
3553 def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
3554 (MOVLPDrm VR128:$src1, addr:$src2)>;
3557 // (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
3558 def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3559 (MOVLPSmr addr:$src1, VR128:$src2)>;
3560 def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3561 (MOVLPDmr addr:$src1, VR128:$src2)>;
3562 def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3564 (MOVLPSmr addr:$src1, VR128:$src2)>;
3565 def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3566 (MOVLPDmr addr:$src1, VR128:$src2)>;
3568 let AddedComplexity = 15 in {
3569 // Setting the lowest element in the vector.
3570 def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
3571 (MOVSSrr (v4i32 VR128:$src1),
3572 (EXTRACT_SUBREG (v4i32 VR128:$src2), sub_ss))>;
3573 def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
3574 (MOVSDrr (v2i64 VR128:$src1),
3575 (EXTRACT_SUBREG (v2i64 VR128:$src2), sub_sd))>;
3577 // vector_shuffle v1, v2 <4, 5, 2, 3> using movsd
3578 def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
3579 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, sub_sd))>,
3580 Requires<[HasSSE2]>;
3581 def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
3582 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, sub_sd))>,
3583 Requires<[HasSSE2]>;
3586 // vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3587 // fall back to this for SSE1)
3588 def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
3589 (SHUFPSrri VR128:$src2, VR128:$src1,
3590 (SHUFFLE_get_shuf_imm VR128:$src3))>;
3592 // Set lowest element and zero upper elements.
3593 def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
3594 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
3596 // Some special case pandn patterns.
3597 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3599 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3600 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3602 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3603 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3605 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3607 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3608 (memop addr:$src2))),
3609 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3610 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3611 (memop addr:$src2))),
3612 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3613 def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3614 (memop addr:$src2))),
3615 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3617 // vector -> vector casts
3618 def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3619 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3620 def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3621 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
3622 def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3623 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3624 def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3625 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
3627 // Use movaps / movups for SSE integer load / store (one byte shorter).
3628 def : Pat<(alignedloadv4i32 addr:$src),
3629 (MOVAPSrm addr:$src)>;
3630 def : Pat<(loadv4i32 addr:$src),
3631 (MOVUPSrm addr:$src)>;
3632 def : Pat<(alignedloadv2i64 addr:$src),
3633 (MOVAPSrm addr:$src)>;
3634 def : Pat<(loadv2i64 addr:$src),
3635 (MOVUPSrm addr:$src)>;
3637 def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3638 (MOVAPSmr addr:$dst, VR128:$src)>;
3639 def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3640 (MOVAPSmr addr:$dst, VR128:$src)>;
3641 def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3642 (MOVAPSmr addr:$dst, VR128:$src)>;
3643 def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3644 (MOVAPSmr addr:$dst, VR128:$src)>;
3645 def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3646 (MOVUPSmr addr:$dst, VR128:$src)>;
3647 def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3648 (MOVUPSmr addr:$dst, VR128:$src)>;
3649 def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3650 (MOVUPSmr addr:$dst, VR128:$src)>;
3651 def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3652 (MOVUPSmr addr:$dst, VR128:$src)>;
3654 //===----------------------------------------------------------------------===//
3655 // SSE4.1 - Packed Move with Sign/Zero Extend
3656 //===----------------------------------------------------------------------===//
3658 multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3659 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3660 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3661 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3663 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3664 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3666 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3670 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
3671 defm VPMOVSXBW : SS41I_binop_rm_int8<0x20, "vpmovsxbw", int_x86_sse41_pmovsxbw>,
3673 defm VPMOVSXWD : SS41I_binop_rm_int8<0x23, "vpmovsxwd", int_x86_sse41_pmovsxwd>,
3675 defm VPMOVSXDQ : SS41I_binop_rm_int8<0x25, "vpmovsxdq", int_x86_sse41_pmovsxdq>,
3677 defm VPMOVZXBW : SS41I_binop_rm_int8<0x30, "vpmovzxbw", int_x86_sse41_pmovzxbw>,
3679 defm VPMOVZXWD : SS41I_binop_rm_int8<0x33, "vpmovzxwd", int_x86_sse41_pmovzxwd>,
3681 defm VPMOVZXDQ : SS41I_binop_rm_int8<0x35, "vpmovzxdq", int_x86_sse41_pmovzxdq>,
3685 defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3686 defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3687 defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3688 defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3689 defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3690 defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3692 // Common patterns involving scalar load.
3693 def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3694 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3695 def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3696 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3698 def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3699 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3700 def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3701 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3703 def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3704 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3705 def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3706 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3708 def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3709 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3710 def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3711 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3713 def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3714 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3715 def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3716 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3718 def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3719 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3720 def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3721 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3724 multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3725 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3726 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3727 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3729 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3730 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3732 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3736 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
3737 defm VPMOVSXBD : SS41I_binop_rm_int4<0x21, "vpmovsxbd", int_x86_sse41_pmovsxbd>,
3739 defm VPMOVSXWQ : SS41I_binop_rm_int4<0x24, "vpmovsxwq", int_x86_sse41_pmovsxwq>,
3741 defm VPMOVZXBD : SS41I_binop_rm_int4<0x31, "vpmovzxbd", int_x86_sse41_pmovzxbd>,
3743 defm VPMOVZXWQ : SS41I_binop_rm_int4<0x34, "vpmovzxwq", int_x86_sse41_pmovzxwq>,
3747 defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3748 defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3749 defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3750 defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3752 // Common patterns involving scalar load
3753 def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
3754 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
3755 def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
3756 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
3758 def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
3759 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
3760 def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
3761 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
3764 multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3765 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3766 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3767 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3769 // Expecting a i16 load any extended to i32 value.
3770 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3771 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3772 [(set VR128:$dst, (IntId (bitconvert
3773 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3777 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
3778 defm VPMOVSXBQ : SS41I_binop_rm_int2<0x22, "vpmovsxbq", int_x86_sse41_pmovsxbq>,
3780 defm VPMOVZXBQ : SS41I_binop_rm_int2<0x32, "vpmovzxbq", int_x86_sse41_pmovzxbq>,
3783 defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
3784 defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
3786 // Common patterns involving scalar load
3787 def : Pat<(int_x86_sse41_pmovsxbq
3788 (bitconvert (v4i32 (X86vzmovl
3789 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
3790 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
3792 def : Pat<(int_x86_sse41_pmovzxbq
3793 (bitconvert (v4i32 (X86vzmovl
3794 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
3795 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
3797 //===----------------------------------------------------------------------===//
3798 // SSE4.1 - Extract Instructions
3799 //===----------------------------------------------------------------------===//
3801 /// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3802 multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
3803 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
3804 (ins VR128:$src1, i32i8imm:$src2),
3805 !strconcat(OpcodeStr,
3806 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3807 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3809 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3810 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
3811 !strconcat(OpcodeStr,
3812 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3815 // There's an AssertZext in the way of writing the store pattern
3816 // (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3819 let isAsmParserOnly = 1, Predicates = [HasAVX] in
3820 defm VPEXTRB : SS41I_extract8<0x14, "vpextrb">, VEX;
3822 defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
3825 /// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3826 multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
3827 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3828 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
3829 !strconcat(OpcodeStr,
3830 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3833 // There's an AssertZext in the way of writing the store pattern
3834 // (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3837 let isAsmParserOnly = 1, Predicates = [HasAVX] in
3838 defm VPEXTRW : SS41I_extract16<0x15, "vpextrw">, VEX;
3840 defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3843 /// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3844 multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
3845 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
3846 (ins VR128:$src1, i32i8imm:$src2),
3847 !strconcat(OpcodeStr,
3848 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3850 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
3851 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3852 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
3853 !strconcat(OpcodeStr,
3854 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3855 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3856 addr:$dst)]>, OpSize;
3859 let isAsmParserOnly = 1, Predicates = [HasAVX] in
3860 defm VPEXTRD : SS41I_extract32<0x16, "vpextrd">, VEX;
3862 defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
3864 /// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3865 multiclass SS41I_extract64<bits<8> opc, string OpcodeStr> {
3866 def rr : SS4AIi8<opc, MRMDestReg, (outs GR64:$dst),
3867 (ins VR128:$src1, i32i8imm:$src2),
3868 !strconcat(OpcodeStr,
3869 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3871 (extractelt (v2i64 VR128:$src1), imm:$src2))]>, OpSize, REX_W;
3872 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3873 (ins i64mem:$dst, VR128:$src1, i32i8imm:$src2),
3874 !strconcat(OpcodeStr,
3875 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3876 [(store (extractelt (v2i64 VR128:$src1), imm:$src2),
3877 addr:$dst)]>, OpSize, REX_W;
3880 let isAsmParserOnly = 1, Predicates = [HasAVX] in
3881 defm VPEXTRQ : SS41I_extract64<0x16, "vpextrq">, VEX, VEX_W;
3883 defm PEXTRQ : SS41I_extract64<0x16, "pextrq">;
3885 /// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3887 multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
3888 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
3889 (ins VR128:$src1, i32i8imm:$src2),
3890 !strconcat(OpcodeStr,
3891 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3893 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
3895 def mr : SS4AIi8<opc, MRMDestMem, (outs),
3896 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
3897 !strconcat(OpcodeStr,
3898 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3899 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
3900 addr:$dst)]>, OpSize;
3903 let isAsmParserOnly = 1, Predicates = [HasAVX] in
3904 defm VEXTRACTPS : SS41I_extractf32<0x17, "vextractps">, VEX;
3905 defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
3907 // Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3908 def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3911 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3912 Requires<[HasSSE41]>;
3914 //===----------------------------------------------------------------------===//
3915 // SSE4.1 - Insert Instructions
3916 //===----------------------------------------------------------------------===//
3918 multiclass SS41I_insert8<bits<8> opc, string asm, bit Is2Addr = 1> {
3919 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3920 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
3922 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3924 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
3926 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
3927 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3928 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3930 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3932 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
3934 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3935 imm:$src3))]>, OpSize;
3938 let isAsmParserOnly = 1, Predicates = [HasAVX] in
3939 defm VPINSRB : SS41I_insert8<0x20, "vpinsrb", 0>, VEX_4V;
3940 let Constraints = "$src1 = $dst" in
3941 defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3943 multiclass SS41I_insert32<bits<8> opc, string asm, bit Is2Addr = 1> {
3944 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3945 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
3947 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3949 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
3951 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3953 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3954 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3956 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3958 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
3960 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3961 imm:$src3)))]>, OpSize;
3964 let isAsmParserOnly = 1, Predicates = [HasAVX] in
3965 defm VPINSRD : SS41I_insert32<0x22, "vpinsrd", 0>, VEX_4V;
3966 let Constraints = "$src1 = $dst" in
3967 defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3969 multiclass SS41I_insert64<bits<8> opc, string asm, bit Is2Addr = 1> {
3970 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3971 (ins VR128:$src1, GR64:$src2, i32i8imm:$src3),
3973 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3975 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
3977 (v2i64 (insertelt VR128:$src1, GR64:$src2, imm:$src3)))]>,
3979 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
3980 (ins VR128:$src1, i64mem:$src2, i32i8imm:$src3),
3982 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3984 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
3986 (v2i64 (insertelt VR128:$src1, (loadi64 addr:$src2),
3987 imm:$src3)))]>, OpSize;
3990 let isAsmParserOnly = 1, Predicates = [HasAVX] in
3991 defm VPINSRQ : SS41I_insert64<0x22, "vpinsrq", 0>, VEX_4V, VEX_W;
3992 let Constraints = "$src1 = $dst" in
3993 defm PINSRQ : SS41I_insert64<0x22, "pinsrq">, REX_W;
3995 // insertps has a few different modes, there's the first two here below which
3996 // are optimized inserts that won't zero arbitrary elements in the destination
3997 // vector. The next one matches the intrinsic and could zero arbitrary elements
3998 // in the target vector.
3999 multiclass SS41I_insertf32<bits<8> opc, string asm, bit Is2Addr = 1> {
4000 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
4001 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
4003 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4005 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4007 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
4009 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
4010 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
4012 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4014 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4016 (X86insrtps VR128:$src1,
4017 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
4018 imm:$src3))]>, OpSize;
4021 let Constraints = "$src1 = $dst" in
4022 defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
4023 let isAsmParserOnly = 1, Predicates = [HasAVX] in
4024 defm VINSERTPS : SS41I_insertf32<0x21, "vinsertps", 0>, VEX_4V;
4026 def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
4027 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
4029 //===----------------------------------------------------------------------===//
4030 // SSE4.1 - Round Instructions
4031 //===----------------------------------------------------------------------===//
4033 multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
4036 Intrinsic V2F64Int> {
4037 // Intrinsic operation, reg.
4038 // Vector intrinsic operation, reg
4039 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
4040 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
4041 !strconcat(OpcodeStr,
4042 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4043 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
4046 // Vector intrinsic operation, mem
4047 def PSm_Int : Ii8<opcps, MRMSrcMem,
4048 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
4049 !strconcat(OpcodeStr,
4050 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4052 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
4054 Requires<[HasSSE41]>;
4056 // Vector intrinsic operation, reg
4057 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
4058 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
4059 !strconcat(OpcodeStr,
4060 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4061 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
4064 // Vector intrinsic operation, mem
4065 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
4066 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
4067 !strconcat(OpcodeStr,
4068 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4070 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
4074 multiclass sse41_fp_unop_rm_avx<bits<8> opcps, bits<8> opcpd,
4076 // Intrinsic operation, reg.
4077 // Vector intrinsic operation, reg
4078 def PSr : SS4AIi8<opcps, MRMSrcReg,
4079 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
4080 !strconcat(OpcodeStr,
4081 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4084 // Vector intrinsic operation, mem
4085 def PSm : Ii8<opcps, MRMSrcMem,
4086 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
4087 !strconcat(OpcodeStr,
4088 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4089 []>, TA, OpSize, Requires<[HasSSE41]>;
4091 // Vector intrinsic operation, reg
4092 def PDr : SS4AIi8<opcpd, MRMSrcReg,
4093 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
4094 !strconcat(OpcodeStr,
4095 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4098 // Vector intrinsic operation, mem
4099 def PDm : SS4AIi8<opcpd, MRMSrcMem,
4100 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
4101 !strconcat(OpcodeStr,
4102 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4106 multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
4109 Intrinsic F64Int, bit Is2Addr = 1> {
4110 // Intrinsic operation, reg.
4111 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
4112 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
4114 !strconcat(OpcodeStr,
4115 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4116 !strconcat(OpcodeStr,
4117 "ss\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4118 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
4121 // Intrinsic operation, mem.
4122 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
4123 (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
4125 !strconcat(OpcodeStr,
4126 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4127 !strconcat(OpcodeStr,
4128 "ss\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4130 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
4133 // Intrinsic operation, reg.
4134 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
4135 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
4137 !strconcat(OpcodeStr,
4138 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4139 !strconcat(OpcodeStr,
4140 "sd\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4141 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
4144 // Intrinsic operation, mem.
4145 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
4146 (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
4148 !strconcat(OpcodeStr,
4149 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4150 !strconcat(OpcodeStr,
4151 "sd\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4153 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
4157 multiclass sse41_fp_binop_rm_avx<bits<8> opcss, bits<8> opcsd,
4159 // Intrinsic operation, reg.
4160 def SSr : SS4AIi8<opcss, MRMSrcReg,
4161 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
4162 !strconcat(OpcodeStr,
4163 "ss\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
4166 // Intrinsic operation, mem.
4167 def SSm : SS4AIi8<opcss, MRMSrcMem,
4168 (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
4169 !strconcat(OpcodeStr,
4170 "ss\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
4173 // Intrinsic operation, reg.
4174 def SDr : SS4AIi8<opcsd, MRMSrcReg,
4175 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
4176 !strconcat(OpcodeStr,
4177 "sd\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
4180 // Intrinsic operation, mem.
4181 def SDm : SS4AIi8<opcsd, MRMSrcMem,
4182 (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
4183 !strconcat(OpcodeStr,
4184 "sd\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
4188 // FP round - roundss, roundps, roundsd, roundpd
4189 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
4191 defm VROUND : sse41_fp_unop_rm<0x08, 0x09, "vround",
4192 int_x86_sse41_round_ps, int_x86_sse41_round_pd>,
4194 defm VROUND : sse41_fp_binop_rm<0x0A, 0x0B, "vround",
4195 int_x86_sse41_round_ss, int_x86_sse41_round_sd,
4197 // Instructions for the assembler
4198 defm VROUND : sse41_fp_unop_rm_avx<0x08, 0x09, "vround">, VEX;
4199 defm VROUND : sse41_fp_binop_rm_avx<0x0A, 0x0B, "vround">, VEX_4V;
4202 defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
4203 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
4204 let Constraints = "$src1 = $dst" in
4205 defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
4206 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
4208 //===----------------------------------------------------------------------===//
4209 // SSE4.1 - Misc Instructions
4210 //===----------------------------------------------------------------------===//
4212 // SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
4213 multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
4214 Intrinsic IntId128> {
4215 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
4217 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
4218 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
4219 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
4221 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
4224 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
4227 let isAsmParserOnly = 1, Predicates = [HasAVX] in
4228 defm VPHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "vphminposuw",
4229 int_x86_sse41_phminposuw>, VEX;
4230 defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
4231 int_x86_sse41_phminposuw>;
4233 /// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
4234 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
4235 Intrinsic IntId128, bit Is2Addr = 1> {
4236 let isCommutable = 1 in
4237 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
4238 (ins VR128:$src1, VR128:$src2),
4240 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4241 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4242 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>, OpSize;
4243 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
4244 (ins VR128:$src1, i128mem:$src2),
4246 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4247 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4249 (IntId128 VR128:$src1,
4250 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
4253 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
4254 let isCommutable = 0 in
4255 defm VPACKUSDW : SS41I_binop_rm_int<0x2B, "vpackusdw", int_x86_sse41_packusdw,
4257 defm VPCMPEQQ : SS41I_binop_rm_int<0x29, "vpcmpeqq", int_x86_sse41_pcmpeqq,
4259 defm VPMINSB : SS41I_binop_rm_int<0x38, "vpminsb", int_x86_sse41_pminsb,
4261 defm VPMINSD : SS41I_binop_rm_int<0x39, "vpminsd", int_x86_sse41_pminsd,
4263 defm VPMINUD : SS41I_binop_rm_int<0x3B, "vpminud", int_x86_sse41_pminud,
4265 defm VPMINUW : SS41I_binop_rm_int<0x3A, "vpminuw", int_x86_sse41_pminuw,
4267 defm VPMAXSB : SS41I_binop_rm_int<0x3C, "vpmaxsb", int_x86_sse41_pmaxsb,
4269 defm VPMAXSD : SS41I_binop_rm_int<0x3D, "vpmaxsd", int_x86_sse41_pmaxsd,
4271 defm VPMAXUD : SS41I_binop_rm_int<0x3F, "vpmaxud", int_x86_sse41_pmaxud,
4273 defm VPMAXUW : SS41I_binop_rm_int<0x3E, "vpmaxuw", int_x86_sse41_pmaxuw,
4275 defm VPMULDQ : SS41I_binop_rm_int<0x28, "vpmuldq", int_x86_sse41_pmuldq,
4279 let Constraints = "$src1 = $dst" in {
4280 let isCommutable = 0 in
4281 defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw", int_x86_sse41_packusdw>;
4282 defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq", int_x86_sse41_pcmpeqq>;
4283 defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb", int_x86_sse41_pminsb>;
4284 defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd", int_x86_sse41_pminsd>;
4285 defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud", int_x86_sse41_pminud>;
4286 defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw", int_x86_sse41_pminuw>;
4287 defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb", int_x86_sse41_pmaxsb>;
4288 defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd", int_x86_sse41_pmaxsd>;
4289 defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud", int_x86_sse41_pmaxud>;
4290 defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw", int_x86_sse41_pmaxuw>;
4291 defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq>;
4294 def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
4295 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
4296 def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
4297 (PCMPEQQrm VR128:$src1, addr:$src2)>;
4299 /// SS48I_binop_rm - Simple SSE41 binary operator.
4300 multiclass SS48I_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
4301 ValueType OpVT, bit Is2Addr = 1> {
4302 let isCommutable = 1 in
4303 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
4304 (ins VR128:$src1, VR128:$src2),
4306 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4307 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4308 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]>,
4310 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
4311 (ins VR128:$src1, i128mem:$src2),
4313 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4314 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4315 [(set VR128:$dst, (OpNode VR128:$src1,
4316 (bc_v4i32 (memopv2i64 addr:$src2))))]>,
4320 let isAsmParserOnly = 1, Predicates = [HasAVX] in
4321 defm VPMULLD : SS48I_binop_rm<0x40, "vpmulld", mul, v4i32, 0>, VEX_4V;
4322 let Constraints = "$src1 = $dst" in
4323 defm PMULLD : SS48I_binop_rm<0x40, "pmulld", mul, v4i32>;
4325 /// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
4326 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
4327 Intrinsic IntId128, bit Is2Addr = 1> {
4328 let isCommutable = 1 in
4329 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
4330 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
4332 !strconcat(OpcodeStr,
4333 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4334 !strconcat(OpcodeStr,
4335 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4337 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
4339 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
4340 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
4342 !strconcat(OpcodeStr,
4343 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4344 !strconcat(OpcodeStr,
4345 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4347 (IntId128 VR128:$src1,
4348 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
4352 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
4353 let isCommutable = 0 in {
4354 defm VBLENDPS : SS41I_binop_rmi_int<0x0C, "vblendps", int_x86_sse41_blendps,
4356 defm VBLENDPD : SS41I_binop_rmi_int<0x0D, "vblendpd", int_x86_sse41_blendpd,
4358 defm VPBLENDW : SS41I_binop_rmi_int<0x0E, "vpblendw", int_x86_sse41_pblendw,
4360 defm VMPSADBW : SS41I_binop_rmi_int<0x42, "vmpsadbw", int_x86_sse41_mpsadbw,
4363 defm VDPPS : SS41I_binop_rmi_int<0x40, "vdpps", int_x86_sse41_dpps,
4365 defm VDPPD : SS41I_binop_rmi_int<0x41, "vdppd", int_x86_sse41_dppd,
4369 let Constraints = "$src1 = $dst" in {
4370 let isCommutable = 0 in {
4371 defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps", int_x86_sse41_blendps>;
4372 defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd", int_x86_sse41_blendpd>;
4373 defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw", int_x86_sse41_pblendw>;
4374 defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw", int_x86_sse41_mpsadbw>;
4376 defm DPPS : SS41I_binop_rmi_int<0x40, "dpps", int_x86_sse41_dpps>;
4377 defm DPPD : SS41I_binop_rmi_int<0x41, "dppd", int_x86_sse41_dppd>;
4380 /// SS41I_quaternary_int_avx - AVX SSE 4.1 with 4 operators
4381 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
4382 multiclass SS41I_quaternary_int_avx<bits<8> opc, string OpcodeStr> {
4383 def rr : I<opc, MRMSrcReg, (outs VR128:$dst),
4384 (ins VR128:$src1, VR128:$src2, VR128:$src3),
4385 !strconcat(OpcodeStr,
4386 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
4387 [], SSEPackedInt>, OpSize, TA, VEX_4V, VEX_I8IMM;
4389 def rm : I<opc, MRMSrcMem, (outs VR128:$dst),
4390 (ins VR128:$src1, i128mem:$src2, VR128:$src3),
4391 !strconcat(OpcodeStr,
4392 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
4393 [], SSEPackedInt>, OpSize, TA, VEX_4V, VEX_I8IMM;
4397 defm VBLENDVPD : SS41I_quaternary_int_avx<0x4B, "vblendvpd">;
4398 defm VBLENDVPS : SS41I_quaternary_int_avx<0x4A, "vblendvps">;
4399 defm VPBLENDVB : SS41I_quaternary_int_avx<0x4C, "vpblendvb">;
4401 /// SS41I_ternary_int - SSE 4.1 ternary operator
4402 let Uses = [XMM0], Constraints = "$src1 = $dst" in {
4403 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
4404 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
4405 (ins VR128:$src1, VR128:$src2),
4406 !strconcat(OpcodeStr,
4407 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
4408 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
4411 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
4412 (ins VR128:$src1, i128mem:$src2),
4413 !strconcat(OpcodeStr,
4414 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
4417 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
4421 defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
4422 defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
4423 defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
4425 // ptest instruction we'll lower to this in X86ISelLowering primarily from
4426 // the intel intrinsic that corresponds to this.
4427 let Defs = [EFLAGS], isAsmParserOnly = 1, Predicates = [HasAVX] in {
4428 def VPTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
4429 "vptest\t{$src2, $src1|$src1, $src2}",
4430 [(set EFLAGS, (X86ptest VR128:$src1, VR128:$src2))]>,
4432 def VPTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
4433 "vptest\t{$src2, $src1|$src1, $src2}",
4434 [(set EFLAGS, (X86ptest VR128:$src1, (load addr:$src2)))]>,
4438 let Defs = [EFLAGS] in {
4439 def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
4440 "ptest \t{$src2, $src1|$src1, $src2}",
4441 [(set EFLAGS, (X86ptest VR128:$src1, VR128:$src2))]>,
4443 def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
4444 "ptest \t{$src2, $src1|$src1, $src2}",
4445 [(set EFLAGS, (X86ptest VR128:$src1, (load addr:$src2)))]>,
4449 let isAsmParserOnly = 1, Predicates = [HasAVX] in
4450 def VMOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
4451 "vmovntdqa\t{$src, $dst|$dst, $src}",
4452 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>,
4454 def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
4455 "movntdqa\t{$src, $dst|$dst, $src}",
4456 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>,
4459 //===----------------------------------------------------------------------===//
4460 // SSE4.2 - Compare Instructions
4461 //===----------------------------------------------------------------------===//
4463 /// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
4464 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
4465 Intrinsic IntId128, bit Is2Addr = 1> {
4466 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
4467 (ins VR128:$src1, VR128:$src2),
4469 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4470 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4471 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
4473 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
4474 (ins VR128:$src1, i128mem:$src2),
4476 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4477 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4479 (IntId128 VR128:$src1,
4480 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
4483 let isAsmParserOnly = 1, Predicates = [HasAVX] in
4484 defm VPCMPGTQ : SS42I_binop_rm_int<0x37, "vpcmpgtq", int_x86_sse42_pcmpgtq,
4486 let Constraints = "$src1 = $dst" in
4487 defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
4489 def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
4490 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
4491 def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
4492 (PCMPGTQrm VR128:$src1, addr:$src2)>;
4494 //===----------------------------------------------------------------------===//
4495 // SSE4.2 - String/text Processing Instructions
4496 //===----------------------------------------------------------------------===//
4498 // Packed Compare Implicit Length Strings, Return Mask
4499 let Defs = [EFLAGS], usesCustomInserter = 1 in {
4500 def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
4501 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
4502 "#PCMPISTRM128rr PSEUDO!",
4503 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
4504 imm:$src3))]>, OpSize;
4505 def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
4506 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
4507 "#PCMPISTRM128rm PSEUDO!",
4508 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128
4509 VR128:$src1, (load addr:$src2), imm:$src3))]>, OpSize;
4512 let Defs = [XMM0, EFLAGS], isAsmParserOnly = 1,
4513 Predicates = [HasAVX] in {
4514 def VPCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
4515 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
4516 "vpcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize, VEX;
4517 def VPCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
4518 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
4519 "vpcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize, VEX;
4522 let Defs = [XMM0, EFLAGS] in {
4523 def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
4524 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
4525 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
4526 def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
4527 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
4528 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
4531 // Packed Compare Explicit Length Strings, Return Mask
4532 let Defs = [EFLAGS], Uses = [EAX, EDX], usesCustomInserter = 1 in {
4533 def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
4534 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
4535 "#PCMPESTRM128rr PSEUDO!",
4537 (int_x86_sse42_pcmpestrm128
4538 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5))]>, OpSize;
4540 def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
4541 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
4542 "#PCMPESTRM128rm PSEUDO!",
4543 [(set VR128:$dst, (int_x86_sse42_pcmpestrm128
4544 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5))]>,
4548 let isAsmParserOnly = 1, Predicates = [HasAVX],
4549 Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
4550 def VPCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
4551 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
4552 "vpcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize, VEX;
4553 def VPCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
4554 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
4555 "vpcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize, VEX;
4558 let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
4559 def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
4560 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
4561 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
4562 def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
4563 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
4564 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
4567 // Packed Compare Implicit Length Strings, Return Index
4568 let Defs = [ECX, EFLAGS] in {
4569 multiclass SS42AI_pcmpistri<Intrinsic IntId128, string asm = "pcmpistri"> {
4570 def rr : SS42AI<0x63, MRMSrcReg, (outs),
4571 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
4572 !strconcat(asm, "\t{$src3, $src2, $src1|$src1, $src2, $src3}"),
4573 [(set ECX, (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
4574 (implicit EFLAGS)]>, OpSize;
4575 def rm : SS42AI<0x63, MRMSrcMem, (outs),
4576 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
4577 !strconcat(asm, "\t{$src3, $src2, $src1|$src1, $src2, $src3}"),
4578 [(set ECX, (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
4579 (implicit EFLAGS)]>, OpSize;
4583 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
4584 defm VPCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128, "vpcmpistri">,
4586 defm VPCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128, "vpcmpistri">,
4588 defm VPCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128, "vpcmpistri">,
4590 defm VPCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128, "vpcmpistri">,
4592 defm VPCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128, "vpcmpistri">,
4594 defm VPCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128, "vpcmpistri">,
4598 defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
4599 defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
4600 defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
4601 defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
4602 defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
4603 defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
4605 // Packed Compare Explicit Length Strings, Return Index
4606 let Defs = [ECX, EFLAGS], Uses = [EAX, EDX] in {
4607 multiclass SS42AI_pcmpestri<Intrinsic IntId128, string asm = "pcmpestri"> {
4608 def rr : SS42AI<0x61, MRMSrcReg, (outs),
4609 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
4610 !strconcat(asm, "\t{$src5, $src3, $src1|$src1, $src3, $src5}"),
4611 [(set ECX, (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
4612 (implicit EFLAGS)]>, OpSize;
4613 def rm : SS42AI<0x61, MRMSrcMem, (outs),
4614 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
4615 !strconcat(asm, "\t{$src5, $src3, $src1|$src1, $src3, $src5}"),
4617 (IntId128 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5)),
4618 (implicit EFLAGS)]>, OpSize;
4622 let isAsmParserOnly = 1, Predicates = [HasAVX] in {
4623 defm VPCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128, "vpcmpestri">,
4625 defm VPCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128, "vpcmpestri">,
4627 defm VPCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128, "vpcmpestri">,
4629 defm VPCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128, "vpcmpestri">,
4631 defm VPCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128, "vpcmpestri">,
4633 defm VPCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128, "vpcmpestri">,
4637 defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
4638 defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
4639 defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
4640 defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
4641 defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
4642 defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;
4644 //===----------------------------------------------------------------------===//
4645 // SSE4.2 - CRC Instructions
4646 //===----------------------------------------------------------------------===//
4648 // No CRC instructions have AVX equivalents
4650 // crc intrinsic instruction
4651 // This set of instructions are only rm, the only difference is the size
4653 let Constraints = "$src1 = $dst" in {
4654 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
4655 (ins GR32:$src1, i8mem:$src2),
4656 "crc32{b} \t{$src2, $src1|$src1, $src2}",
4658 (int_x86_sse42_crc32_8 GR32:$src1,
4659 (load addr:$src2)))]>;
4660 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
4661 (ins GR32:$src1, GR8:$src2),
4662 "crc32{b} \t{$src2, $src1|$src1, $src2}",
4664 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>;
4665 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
4666 (ins GR32:$src1, i16mem:$src2),
4667 "crc32{w} \t{$src2, $src1|$src1, $src2}",
4669 (int_x86_sse42_crc32_16 GR32:$src1,
4670 (load addr:$src2)))]>,
4672 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
4673 (ins GR32:$src1, GR16:$src2),
4674 "crc32{w} \t{$src2, $src1|$src1, $src2}",
4676 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
4678 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
4679 (ins GR32:$src1, i32mem:$src2),
4680 "crc32{l} \t{$src2, $src1|$src1, $src2}",
4682 (int_x86_sse42_crc32_32 GR32:$src1,
4683 (load addr:$src2)))]>;
4684 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
4685 (ins GR32:$src1, GR32:$src2),
4686 "crc32{l} \t{$src2, $src1|$src1, $src2}",
4688 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>;
4689 def CRC64m8 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
4690 (ins GR64:$src1, i8mem:$src2),
4691 "crc32{b} \t{$src2, $src1|$src1, $src2}",
4693 (int_x86_sse42_crc64_8 GR64:$src1,
4694 (load addr:$src2)))]>,
4696 def CRC64r8 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
4697 (ins GR64:$src1, GR8:$src2),
4698 "crc32{b} \t{$src2, $src1|$src1, $src2}",
4700 (int_x86_sse42_crc64_8 GR64:$src1, GR8:$src2))]>,
4702 def CRC64m64 : SS42FI<0xF1, MRMSrcMem, (outs GR64:$dst),
4703 (ins GR64:$src1, i64mem:$src2),
4704 "crc32{q} \t{$src2, $src1|$src1, $src2}",
4706 (int_x86_sse42_crc64_64 GR64:$src1,
4707 (load addr:$src2)))]>,
4709 def CRC64r64 : SS42FI<0xF1, MRMSrcReg, (outs GR64:$dst),
4710 (ins GR64:$src1, GR64:$src2),
4711 "crc32{q} \t{$src2, $src1|$src1, $src2}",
4713 (int_x86_sse42_crc64_64 GR64:$src1, GR64:$src2))]>,
4717 //===----------------------------------------------------------------------===//
4718 // AES-NI Instructions
4719 //===----------------------------------------------------------------------===//
4721 multiclass AESI_binop_rm_int<bits<8> opc, string OpcodeStr,
4722 Intrinsic IntId128, bit Is2Addr = 1> {
4723 def rr : AES8I<opc, MRMSrcReg, (outs VR128:$dst),
4724 (ins VR128:$src1, VR128:$src2),
4726 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4727 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4728 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
4730 def rm : AES8I<opc, MRMSrcMem, (outs VR128:$dst),
4731 (ins VR128:$src1, i128mem:$src2),
4733 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4734 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4736 (IntId128 VR128:$src1,
4737 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
4740 // Perform One Round of an AES Encryption/Decryption Flow
4741 let isAsmParserOnly = 1, Predicates = [HasAVX, HasAES] in {
4742 defm VAESENC : AESI_binop_rm_int<0xDC, "vaesenc",
4743 int_x86_aesni_aesenc, 0>, VEX_4V;
4744 defm VAESENCLAST : AESI_binop_rm_int<0xDD, "vaesenclast",
4745 int_x86_aesni_aesenclast, 0>, VEX_4V;
4746 defm VAESDEC : AESI_binop_rm_int<0xDE, "vaesdec",
4747 int_x86_aesni_aesdec, 0>, VEX_4V;
4748 defm VAESDECLAST : AESI_binop_rm_int<0xDF, "vaesdeclast",
4749 int_x86_aesni_aesdeclast, 0>, VEX_4V;
4752 let Constraints = "$src1 = $dst" in {
4753 defm AESENC : AESI_binop_rm_int<0xDC, "aesenc",
4754 int_x86_aesni_aesenc>;
4755 defm AESENCLAST : AESI_binop_rm_int<0xDD, "aesenclast",
4756 int_x86_aesni_aesenclast>;
4757 defm AESDEC : AESI_binop_rm_int<0xDE, "aesdec",
4758 int_x86_aesni_aesdec>;
4759 defm AESDECLAST : AESI_binop_rm_int<0xDF, "aesdeclast",
4760 int_x86_aesni_aesdeclast>;
4763 def : Pat<(v2i64 (int_x86_aesni_aesenc VR128:$src1, VR128:$src2)),
4764 (AESENCrr VR128:$src1, VR128:$src2)>;
4765 def : Pat<(v2i64 (int_x86_aesni_aesenc VR128:$src1, (memop addr:$src2))),
4766 (AESENCrm VR128:$src1, addr:$src2)>;
4767 def : Pat<(v2i64 (int_x86_aesni_aesenclast VR128:$src1, VR128:$src2)),
4768 (AESENCLASTrr VR128:$src1, VR128:$src2)>;
4769 def : Pat<(v2i64 (int_x86_aesni_aesenclast VR128:$src1, (memop addr:$src2))),
4770 (AESENCLASTrm VR128:$src1, addr:$src2)>;
4771 def : Pat<(v2i64 (int_x86_aesni_aesdec VR128:$src1, VR128:$src2)),
4772 (AESDECrr VR128:$src1, VR128:$src2)>;
4773 def : Pat<(v2i64 (int_x86_aesni_aesdec VR128:$src1, (memop addr:$src2))),
4774 (AESDECrm VR128:$src1, addr:$src2)>;
4775 def : Pat<(v2i64 (int_x86_aesni_aesdeclast VR128:$src1, VR128:$src2)),
4776 (AESDECLASTrr VR128:$src1, VR128:$src2)>;
4777 def : Pat<(v2i64 (int_x86_aesni_aesdeclast VR128:$src1, (memop addr:$src2))),
4778 (AESDECLASTrm VR128:$src1, addr:$src2)>;
4780 // Perform the AES InvMixColumn Transformation
4781 let isAsmParserOnly = 1, Predicates = [HasAVX, HasAES] in {
4782 def VAESIMCrr : AES8I<0xDB, MRMSrcReg, (outs VR128:$dst),
4784 "vaesimc\t{$src1, $dst|$dst, $src1}",
4786 (int_x86_aesni_aesimc VR128:$src1))]>,
4788 def VAESIMCrm : AES8I<0xDB, MRMSrcMem, (outs VR128:$dst),
4789 (ins i128mem:$src1),
4790 "vaesimc\t{$src1, $dst|$dst, $src1}",
4792 (int_x86_aesni_aesimc (bitconvert (memopv2i64 addr:$src1))))]>,
4795 def AESIMCrr : AES8I<0xDB, MRMSrcReg, (outs VR128:$dst),
4797 "aesimc\t{$src1, $dst|$dst, $src1}",
4799 (int_x86_aesni_aesimc VR128:$src1))]>,
4801 def AESIMCrm : AES8I<0xDB, MRMSrcMem, (outs VR128:$dst),
4802 (ins i128mem:$src1),
4803 "aesimc\t{$src1, $dst|$dst, $src1}",
4805 (int_x86_aesni_aesimc (bitconvert (memopv2i64 addr:$src1))))]>,
4808 // AES Round Key Generation Assist
4809 let isAsmParserOnly = 1, Predicates = [HasAVX, HasAES] in {
4810 def VAESKEYGENASSIST128rr : AESAI<0xDF, MRMSrcReg, (outs VR128:$dst),
4811 (ins VR128:$src1, i8imm:$src2),
4812 "vaeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}",
4814 (int_x86_aesni_aeskeygenassist VR128:$src1, imm:$src2))]>,
4816 def VAESKEYGENASSIST128rm : AESAI<0xDF, MRMSrcMem, (outs VR128:$dst),
4817 (ins i128mem:$src1, i8imm:$src2),
4818 "vaeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}",
4820 (int_x86_aesni_aeskeygenassist (bitconvert (memopv2i64 addr:$src1)),
4824 def AESKEYGENASSIST128rr : AESAI<0xDF, MRMSrcReg, (outs VR128:$dst),
4825 (ins VR128:$src1, i8imm:$src2),
4826 "aeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}",
4828 (int_x86_aesni_aeskeygenassist VR128:$src1, imm:$src2))]>,
4830 def AESKEYGENASSIST128rm : AESAI<0xDF, MRMSrcMem, (outs VR128:$dst),
4831 (ins i128mem:$src1, i8imm:$src2),
4832 "aeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}",
4834 (int_x86_aesni_aeskeygenassist (bitconvert (memopv2i64 addr:$src1)),