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 1 & 2 Instructions Classes
19 //===----------------------------------------------------------------------===//
21 /// sse12_fp_scalar - SSE 1 & 2 scalar instructions class
22 multiclass sse12_fp_scalar<bits<8> opc, string OpcodeStr, SDNode OpNode,
23 RegisterClass RC, X86MemOperand x86memop,
25 let isCommutable = 1 in {
26 def rr : SI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
28 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
29 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
30 [(set RC:$dst, (OpNode RC:$src1, RC:$src2))]>;
32 def rm : SI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, x86memop:$src2),
34 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
35 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
36 [(set RC:$dst, (OpNode RC:$src1, (load addr:$src2)))]>;
39 /// sse12_fp_scalar_int - SSE 1 & 2 scalar instructions intrinsics class
40 multiclass sse12_fp_scalar_int<bits<8> opc, string OpcodeStr, RegisterClass RC,
41 string asm, string SSEVer, string FPSizeStr,
42 Operand memopr, ComplexPattern mem_cpat,
44 def rr_Int : SI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
46 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
47 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
48 [(set RC:$dst, (!cast<Intrinsic>(
49 !strconcat("int_x86_sse", SSEVer, "_", OpcodeStr, FPSizeStr))
50 RC:$src1, RC:$src2))]>;
51 def rm_Int : SI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, memopr:$src2),
53 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
54 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
55 [(set RC:$dst, (!cast<Intrinsic>(!strconcat("int_x86_sse",
56 SSEVer, "_", OpcodeStr, FPSizeStr))
57 RC:$src1, mem_cpat:$src2))]>;
60 /// sse12_fp_packed - SSE 1 & 2 packed instructions class
61 multiclass sse12_fp_packed<bits<8> opc, string OpcodeStr, SDNode OpNode,
62 RegisterClass RC, ValueType vt,
63 X86MemOperand x86memop, PatFrag mem_frag,
64 Domain d, bit Is2Addr = 1> {
65 let isCommutable = 1 in
66 def rr : PI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
68 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
69 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
70 [(set RC:$dst, (vt (OpNode RC:$src1, RC:$src2)))], d>;
72 def rm : PI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, x86memop:$src2),
74 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
75 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
76 [(set RC:$dst, (OpNode RC:$src1, (mem_frag addr:$src2)))], d>;
79 /// sse12_fp_packed_logical_rm - SSE 1 & 2 packed instructions class
80 multiclass sse12_fp_packed_logical_rm<bits<8> opc, RegisterClass RC, Domain d,
81 string OpcodeStr, X86MemOperand x86memop,
82 list<dag> pat_rr, list<dag> pat_rm,
84 let isCommutable = 1 in
85 def rr : PI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
87 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
88 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
90 def rm : PI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, x86memop:$src2),
92 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
93 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
97 /// sse12_fp_packed_int - SSE 1 & 2 packed instructions intrinsics class
98 multiclass sse12_fp_packed_int<bits<8> opc, string OpcodeStr, RegisterClass RC,
99 string asm, string SSEVer, string FPSizeStr,
100 X86MemOperand x86memop, PatFrag mem_frag,
101 Domain d, bit Is2Addr = 1> {
102 def rr_Int : PI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
104 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
105 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
106 [(set RC:$dst, (!cast<Intrinsic>(
107 !strconcat("int_x86_", SSEVer, "_", OpcodeStr, FPSizeStr))
108 RC:$src1, RC:$src2))], d>;
109 def rm_Int : PI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1,x86memop:$src2),
111 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
112 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
113 [(set RC:$dst, (!cast<Intrinsic>(
114 !strconcat("int_x86_", SSEVer, "_", OpcodeStr, FPSizeStr))
115 RC:$src1, (mem_frag addr:$src2)))], d>;
118 //===----------------------------------------------------------------------===//
119 // SSE 1 & 2 - Move Instructions
120 //===----------------------------------------------------------------------===//
122 class sse12_move_rr<RegisterClass RC, ValueType vt, string asm> :
123 SI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, RC:$src2), asm,
124 [(set (vt VR128:$dst), (movl VR128:$src1, (scalar_to_vector RC:$src2)))]>;
126 // Loading from memory automatically zeroing upper bits.
127 class sse12_move_rm<RegisterClass RC, X86MemOperand x86memop,
128 PatFrag mem_pat, string OpcodeStr> :
129 SI<0x10, MRMSrcMem, (outs RC:$dst), (ins x86memop:$src),
130 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
131 [(set RC:$dst, (mem_pat addr:$src))]>;
133 // Move Instructions. Register-to-register movss/movsd is not used for FR32/64
134 // register copies because it's a partial register update; FsMOVAPSrr/FsMOVAPDrr
135 // is used instead. Register-to-register movss/movsd is not modeled as an
136 // INSERT_SUBREG because INSERT_SUBREG requires that the insert be implementable
137 // in terms of a copy, and just mentioned, we don't use movss/movsd for copies.
138 def VMOVSSrr : sse12_move_rr<FR32, v4f32,
139 "movss\t{$src2, $src1, $dst|$dst, $src1, $src2}">, XS, VEX_4V;
140 def VMOVSDrr : sse12_move_rr<FR64, v2f64,
141 "movsd\t{$src2, $src1, $dst|$dst, $src1, $src2}">, XD, VEX_4V;
143 let canFoldAsLoad = 1, isReMaterializable = 1 in {
144 def VMOVSSrm : sse12_move_rm<FR32, f32mem, loadf32, "movss">, XS, VEX;
146 let AddedComplexity = 20 in
147 def VMOVSDrm : sse12_move_rm<FR64, f64mem, loadf64, "movsd">, XD, VEX;
150 let Constraints = "$src1 = $dst" in {
151 def MOVSSrr : sse12_move_rr<FR32, v4f32,
152 "movss\t{$src2, $dst|$dst, $src2}">, XS;
153 def MOVSDrr : sse12_move_rr<FR64, v2f64,
154 "movsd\t{$src2, $dst|$dst, $src2}">, XD;
157 let canFoldAsLoad = 1, isReMaterializable = 1 in {
158 def MOVSSrm : sse12_move_rm<FR32, f32mem, loadf32, "movss">, XS;
160 let AddedComplexity = 20 in
161 def MOVSDrm : sse12_move_rm<FR64, f64mem, loadf64, "movsd">, XD;
164 let AddedComplexity = 15 in {
165 // Extract the low 32-bit value from one vector and insert it into another.
166 def : Pat<(v4f32 (movl VR128:$src1, VR128:$src2)),
167 (MOVSSrr (v4f32 VR128:$src1),
168 (EXTRACT_SUBREG (v4f32 VR128:$src2), sub_ss))>;
169 // Extract the low 64-bit value from one vector and insert it into another.
170 def : Pat<(v2f64 (movl VR128:$src1, VR128:$src2)),
171 (MOVSDrr (v2f64 VR128:$src1),
172 (EXTRACT_SUBREG (v2f64 VR128:$src2), sub_sd))>;
175 // Implicitly promote a 32-bit scalar to a vector.
176 def : Pat<(v4f32 (scalar_to_vector FR32:$src)),
177 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FR32:$src, sub_ss)>;
178 // Implicitly promote a 64-bit scalar to a vector.
179 def : Pat<(v2f64 (scalar_to_vector FR64:$src)),
180 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FR64:$src, sub_sd)>;
181 // Implicitly promote a 32-bit scalar to a vector.
182 def : Pat<(v8f32 (scalar_to_vector FR32:$src)),
183 (INSERT_SUBREG (v8f32 (IMPLICIT_DEF)), FR32:$src, sub_ss)>;
184 // Implicitly promote a 64-bit scalar to a vector.
185 def : Pat<(v4f64 (scalar_to_vector FR64:$src)),
186 (INSERT_SUBREG (v4f64 (IMPLICIT_DEF)), FR64:$src, sub_sd)>;
188 let AddedComplexity = 20 in {
189 // MOVSSrm zeros the high parts of the register; represent this
190 // with SUBREG_TO_REG.
191 def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector (loadf32 addr:$src))))),
192 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), sub_ss)>;
193 def : Pat<(v4f32 (scalar_to_vector (loadf32 addr:$src))),
194 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), sub_ss)>;
195 def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
196 (SUBREG_TO_REG (i32 0), (MOVSSrm addr:$src), sub_ss)>;
197 // MOVSDrm zeros the high parts of the register; represent this
198 // with SUBREG_TO_REG.
199 def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector (loadf64 addr:$src))))),
200 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
201 def : Pat<(v2f64 (scalar_to_vector (loadf64 addr:$src))),
202 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
203 def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
204 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
205 def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
206 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
207 def : Pat<(v2f64 (X86vzload addr:$src)),
208 (SUBREG_TO_REG (i64 0), (MOVSDrm addr:$src), sub_sd)>;
211 // Store scalar value to memory.
212 def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
213 "movss\t{$src, $dst|$dst, $src}",
214 [(store FR32:$src, addr:$dst)]>;
215 def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
216 "movsd\t{$src, $dst|$dst, $src}",
217 [(store FR64:$src, addr:$dst)]>;
219 def VMOVSSmr : SI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
220 "movss\t{$src, $dst|$dst, $src}",
221 [(store FR32:$src, addr:$dst)]>, XS, VEX;
222 def VMOVSDmr : SI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
223 "movsd\t{$src, $dst|$dst, $src}",
224 [(store FR64:$src, addr:$dst)]>, XD, VEX;
226 // Extract and store.
227 def : Pat<(store (f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
230 (EXTRACT_SUBREG (v4f32 VR128:$src), sub_ss))>;
231 def : Pat<(store (f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
234 (EXTRACT_SUBREG (v2f64 VR128:$src), sub_sd))>;
236 // Move Aligned/Unaligned floating point values
237 multiclass sse12_mov_packed<bits<8> opc, RegisterClass RC,
238 X86MemOperand x86memop, PatFrag ld_frag,
239 string asm, Domain d,
240 bit IsReMaterializable = 1> {
241 let neverHasSideEffects = 1 in
242 def rr : PI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src),
243 !strconcat(asm, "\t{$src, $dst|$dst, $src}"), [], d>;
244 let canFoldAsLoad = 1, isReMaterializable = IsReMaterializable in
245 def rm : PI<opc, MRMSrcMem, (outs RC:$dst), (ins x86memop:$src),
246 !strconcat(asm, "\t{$src, $dst|$dst, $src}"),
247 [(set RC:$dst, (ld_frag addr:$src))], d>;
250 defm VMOVAPS : sse12_mov_packed<0x28, VR128, f128mem, alignedloadv4f32,
251 "movaps", SSEPackedSingle>, VEX;
252 defm VMOVAPD : sse12_mov_packed<0x28, VR128, f128mem, alignedloadv2f64,
253 "movapd", SSEPackedDouble>, OpSize, VEX;
254 defm VMOVUPS : sse12_mov_packed<0x10, VR128, f128mem, loadv4f32,
255 "movups", SSEPackedSingle>, VEX;
256 defm VMOVUPD : sse12_mov_packed<0x10, VR128, f128mem, loadv2f64,
257 "movupd", SSEPackedDouble, 0>, OpSize, VEX;
259 defm VMOVAPSY : sse12_mov_packed<0x28, VR256, f256mem, alignedloadv8f32,
260 "movaps", SSEPackedSingle>, VEX;
261 defm VMOVAPDY : sse12_mov_packed<0x28, VR256, f256mem, alignedloadv4f64,
262 "movapd", SSEPackedDouble>, OpSize, VEX;
263 defm VMOVUPSY : sse12_mov_packed<0x10, VR256, f256mem, loadv8f32,
264 "movups", SSEPackedSingle>, VEX;
265 defm VMOVUPDY : sse12_mov_packed<0x10, VR256, f256mem, loadv4f64,
266 "movupd", SSEPackedDouble, 0>, OpSize, VEX;
267 defm MOVAPS : sse12_mov_packed<0x28, VR128, f128mem, alignedloadv4f32,
268 "movaps", SSEPackedSingle>, TB;
269 defm MOVAPD : sse12_mov_packed<0x28, VR128, f128mem, alignedloadv2f64,
270 "movapd", SSEPackedDouble>, TB, OpSize;
271 defm MOVUPS : sse12_mov_packed<0x10, VR128, f128mem, loadv4f32,
272 "movups", SSEPackedSingle>, TB;
273 defm MOVUPD : sse12_mov_packed<0x10, VR128, f128mem, loadv2f64,
274 "movupd", SSEPackedDouble, 0>, TB, OpSize;
276 def VMOVAPSmr : VPSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
277 "movaps\t{$src, $dst|$dst, $src}",
278 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>, VEX;
279 def VMOVAPDmr : VPDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
280 "movapd\t{$src, $dst|$dst, $src}",
281 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>, VEX;
282 def VMOVUPSmr : VPSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
283 "movups\t{$src, $dst|$dst, $src}",
284 [(store (v4f32 VR128:$src), addr:$dst)]>, VEX;
285 def VMOVUPDmr : VPDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
286 "movupd\t{$src, $dst|$dst, $src}",
287 [(store (v2f64 VR128:$src), addr:$dst)]>, VEX;
288 def VMOVAPSYmr : VPSI<0x29, MRMDestMem, (outs), (ins f256mem:$dst, VR256:$src),
289 "movaps\t{$src, $dst|$dst, $src}",
290 [(alignedstore (v8f32 VR256:$src), addr:$dst)]>, VEX;
291 def VMOVAPDYmr : VPDI<0x29, MRMDestMem, (outs), (ins f256mem:$dst, VR256:$src),
292 "movapd\t{$src, $dst|$dst, $src}",
293 [(alignedstore (v4f64 VR256:$src), addr:$dst)]>, VEX;
294 def VMOVUPSYmr : VPSI<0x11, MRMDestMem, (outs), (ins f256mem:$dst, VR256:$src),
295 "movups\t{$src, $dst|$dst, $src}",
296 [(store (v8f32 VR256:$src), addr:$dst)]>, VEX;
297 def VMOVUPDYmr : VPDI<0x11, MRMDestMem, (outs), (ins f256mem:$dst, VR256:$src),
298 "movupd\t{$src, $dst|$dst, $src}",
299 [(store (v4f64 VR256:$src), addr:$dst)]>, VEX;
301 def : Pat<(int_x86_avx_loadu_ps_256 addr:$src), (VMOVUPSYrm addr:$src)>;
302 def : Pat<(int_x86_avx_storeu_ps_256 addr:$dst, VR256:$src),
303 (VMOVUPSYmr addr:$dst, VR256:$src)>;
305 def : Pat<(int_x86_avx_loadu_pd_256 addr:$src), (VMOVUPDYrm addr:$src)>;
306 def : Pat<(int_x86_avx_storeu_pd_256 addr:$dst, VR256:$src),
307 (VMOVUPDYmr addr:$dst, VR256:$src)>;
309 def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
310 "movaps\t{$src, $dst|$dst, $src}",
311 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
312 def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
313 "movapd\t{$src, $dst|$dst, $src}",
314 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
315 def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
316 "movups\t{$src, $dst|$dst, $src}",
317 [(store (v4f32 VR128:$src), addr:$dst)]>;
318 def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
319 "movupd\t{$src, $dst|$dst, $src}",
320 [(store (v2f64 VR128:$src), addr:$dst)]>;
322 // Intrinsic forms of MOVUPS/D load and store
323 def VMOVUPSmr_Int : VPSI<0x11, MRMDestMem, (outs),
324 (ins f128mem:$dst, VR128:$src),
325 "movups\t{$src, $dst|$dst, $src}",
326 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>, VEX;
327 def VMOVUPDmr_Int : VPDI<0x11, MRMDestMem, (outs),
328 (ins f128mem:$dst, VR128:$src),
329 "movupd\t{$src, $dst|$dst, $src}",
330 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>, VEX;
332 def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
333 "movups\t{$src, $dst|$dst, $src}",
334 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
335 def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
336 "movupd\t{$src, $dst|$dst, $src}",
337 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
339 // Move Low/High packed floating point values
340 multiclass sse12_mov_hilo_packed<bits<8>opc, RegisterClass RC,
341 PatFrag mov_frag, string base_opc,
343 def PSrm : PI<opc, MRMSrcMem,
344 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
345 !strconcat(base_opc, "s", asm_opr),
348 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))],
349 SSEPackedSingle>, TB;
351 def PDrm : PI<opc, MRMSrcMem,
352 (outs RC:$dst), (ins RC:$src1, f64mem:$src2),
353 !strconcat(base_opc, "d", asm_opr),
354 [(set RC:$dst, (v2f64 (mov_frag RC:$src1,
355 (scalar_to_vector (loadf64 addr:$src2)))))],
356 SSEPackedDouble>, TB, OpSize;
359 let AddedComplexity = 20 in {
360 defm VMOVL : sse12_mov_hilo_packed<0x12, VR128, movlp, "movlp",
361 "\t{$src2, $src1, $dst|$dst, $src1, $src2}">, VEX_4V;
362 defm VMOVH : sse12_mov_hilo_packed<0x16, VR128, movlhps, "movhp",
363 "\t{$src2, $src1, $dst|$dst, $src1, $src2}">, VEX_4V;
365 let Constraints = "$src1 = $dst", AddedComplexity = 20 in {
366 defm MOVL : sse12_mov_hilo_packed<0x12, VR128, movlp, "movlp",
367 "\t{$src2, $dst|$dst, $src2}">;
368 defm MOVH : sse12_mov_hilo_packed<0x16, VR128, movlhps, "movhp",
369 "\t{$src2, $dst|$dst, $src2}">;
372 def VMOVLPSmr : VPSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
373 "movlps\t{$src, $dst|$dst, $src}",
374 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
375 (iPTR 0))), addr:$dst)]>, VEX;
376 def VMOVLPDmr : VPDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
377 "movlpd\t{$src, $dst|$dst, $src}",
378 [(store (f64 (vector_extract (v2f64 VR128:$src),
379 (iPTR 0))), addr:$dst)]>, VEX;
380 def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
381 "movlps\t{$src, $dst|$dst, $src}",
382 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
383 (iPTR 0))), addr:$dst)]>;
384 def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
385 "movlpd\t{$src, $dst|$dst, $src}",
386 [(store (f64 (vector_extract (v2f64 VR128:$src),
387 (iPTR 0))), addr:$dst)]>;
389 // v2f64 extract element 1 is always custom lowered to unpack high to low
390 // and extract element 0 so the non-store version isn't too horrible.
391 def VMOVHPSmr : VPSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
392 "movhps\t{$src, $dst|$dst, $src}",
393 [(store (f64 (vector_extract
394 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
395 (undef)), (iPTR 0))), addr:$dst)]>,
397 def VMOVHPDmr : VPDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
398 "movhpd\t{$src, $dst|$dst, $src}",
399 [(store (f64 (vector_extract
400 (v2f64 (unpckh VR128:$src, (undef))),
401 (iPTR 0))), addr:$dst)]>,
403 def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
404 "movhps\t{$src, $dst|$dst, $src}",
405 [(store (f64 (vector_extract
406 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
407 (undef)), (iPTR 0))), addr:$dst)]>;
408 def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
409 "movhpd\t{$src, $dst|$dst, $src}",
410 [(store (f64 (vector_extract
411 (v2f64 (unpckh VR128:$src, (undef))),
412 (iPTR 0))), addr:$dst)]>;
414 let AddedComplexity = 20 in {
415 def VMOVLHPSrr : VPSI<0x16, MRMSrcReg, (outs VR128:$dst),
416 (ins VR128:$src1, VR128:$src2),
417 "movlhps\t{$src2, $src1, $dst|$dst, $src1, $src2}",
419 (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>,
421 def VMOVHLPSrr : VPSI<0x12, MRMSrcReg, (outs VR128:$dst),
422 (ins VR128:$src1, VR128:$src2),
423 "movhlps\t{$src2, $src1, $dst|$dst, $src1, $src2}",
425 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>,
428 let Constraints = "$src1 = $dst", AddedComplexity = 20 in {
429 def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
430 (ins VR128:$src1, VR128:$src2),
431 "movlhps\t{$src2, $dst|$dst, $src2}",
433 (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>;
434 def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
435 (ins VR128:$src1, VR128:$src2),
436 "movhlps\t{$src2, $dst|$dst, $src2}",
438 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
441 def : Pat<(movlhps VR128:$src1, (bc_v4i32 (v2i64 (X86vzload addr:$src2)))),
442 (MOVHPSrm (v4i32 VR128:$src1), addr:$src2)>;
443 let AddedComplexity = 20 in {
444 def : Pat<(v4f32 (movddup VR128:$src, (undef))),
445 (MOVLHPSrr (v4f32 VR128:$src), (v4f32 VR128:$src))>;
446 def : Pat<(v2i64 (movddup VR128:$src, (undef))),
447 (MOVLHPSrr (v2i64 VR128:$src), (v2i64 VR128:$src))>;
450 //===----------------------------------------------------------------------===//
451 // SSE 1 & 2 - Conversion Instructions
452 //===----------------------------------------------------------------------===//
454 multiclass sse12_cvt_s<bits<8> opc, RegisterClass SrcRC, RegisterClass DstRC,
455 SDNode OpNode, X86MemOperand x86memop, PatFrag ld_frag,
457 def rr : SI<opc, MRMSrcReg, (outs DstRC:$dst), (ins SrcRC:$src), asm,
458 [(set DstRC:$dst, (OpNode SrcRC:$src))]>;
459 def rm : SI<opc, MRMSrcMem, (outs DstRC:$dst), (ins x86memop:$src), asm,
460 [(set DstRC:$dst, (OpNode (ld_frag addr:$src)))]>;
463 multiclass sse12_cvt_s_np<bits<8> opc, RegisterClass SrcRC, RegisterClass DstRC,
464 X86MemOperand x86memop, string asm> {
465 def rr : SI<opc, MRMSrcReg, (outs DstRC:$dst), (ins SrcRC:$src), asm,
467 def rm : SI<opc, MRMSrcMem, (outs DstRC:$dst), (ins x86memop:$src), asm,
471 multiclass sse12_cvt_p<bits<8> opc, RegisterClass SrcRC, RegisterClass DstRC,
472 SDNode OpNode, X86MemOperand x86memop, PatFrag ld_frag,
473 string asm, Domain d> {
474 def rr : PI<opc, MRMSrcReg, (outs DstRC:$dst), (ins SrcRC:$src), asm,
475 [(set DstRC:$dst, (OpNode SrcRC:$src))], d>;
476 def rm : PI<opc, MRMSrcMem, (outs DstRC:$dst), (ins x86memop:$src), asm,
477 [(set DstRC:$dst, (OpNode (ld_frag addr:$src)))], d>;
480 multiclass sse12_vcvt_avx<bits<8> opc, RegisterClass SrcRC, RegisterClass DstRC,
481 X86MemOperand x86memop, string asm> {
482 def rr : SI<opc, MRMSrcReg, (outs DstRC:$dst), (ins DstRC:$src1, SrcRC:$src),
483 !strconcat(asm,"\t{$src, $src1, $dst|$dst, $src1, $src}"), []>;
484 def rm : SI<opc, MRMSrcMem, (outs DstRC:$dst),
485 (ins DstRC:$src1, x86memop:$src),
486 !strconcat(asm,"\t{$src, $src1, $dst|$dst, $src1, $src}"), []>;
489 defm VCVTTSS2SI : sse12_cvt_s<0x2C, FR32, GR32, fp_to_sint, f32mem, loadf32,
490 "cvttss2si\t{$src, $dst|$dst, $src}">, XS, VEX;
491 defm VCVTTSS2SI64 : sse12_cvt_s<0x2C, FR32, GR64, fp_to_sint, f32mem, loadf32,
492 "cvttss2si\t{$src, $dst|$dst, $src}">, XS, VEX,
494 defm VCVTTSD2SI : sse12_cvt_s<0x2C, FR64, GR32, fp_to_sint, f64mem, loadf64,
495 "cvttsd2si\t{$src, $dst|$dst, $src}">, XD, VEX;
496 defm VCVTTSD2SI64 : sse12_cvt_s<0x2C, FR64, GR64, fp_to_sint, f64mem, loadf64,
497 "cvttsd2si\t{$src, $dst|$dst, $src}">, XD,
500 // The assembler can recognize rr 64-bit instructions by seeing a rxx
501 // register, but the same isn't true when only using memory operands,
502 // provide other assembly "l" and "q" forms to address this explicitly
503 // where appropriate to do so.
504 defm VCVTSI2SS : sse12_vcvt_avx<0x2A, GR32, FR32, i32mem, "cvtsi2ss">, XS,
506 defm VCVTSI2SS64 : sse12_vcvt_avx<0x2A, GR64, FR32, i64mem, "cvtsi2ss{q}">, XS,
508 defm VCVTSI2SD : sse12_vcvt_avx<0x2A, GR32, FR64, i32mem, "cvtsi2sd">, XD,
510 defm VCVTSI2SDL : sse12_vcvt_avx<0x2A, GR32, FR64, i32mem, "cvtsi2sd{l}">, XD,
512 defm VCVTSI2SD64 : sse12_vcvt_avx<0x2A, GR64, FR64, i64mem, "cvtsi2sd{q}">, XD,
515 let Predicates = [HasAVX] in {
516 def : Pat<(f32 (sint_to_fp (loadi32 addr:$src))),
517 (VCVTSI2SSrm (f32 (IMPLICIT_DEF)), addr:$src)>;
518 def : Pat<(f32 (sint_to_fp (loadi64 addr:$src))),
519 (VCVTSI2SS64rm (f32 (IMPLICIT_DEF)), addr:$src)>;
520 def : Pat<(f64 (sint_to_fp (loadi32 addr:$src))),
521 (VCVTSI2SDrm (f64 (IMPLICIT_DEF)), addr:$src)>;
522 def : Pat<(f64 (sint_to_fp (loadi64 addr:$src))),
523 (VCVTSI2SD64rm (f64 (IMPLICIT_DEF)), addr:$src)>;
525 def : Pat<(f32 (sint_to_fp GR32:$src)),
526 (VCVTSI2SSrr (f32 (IMPLICIT_DEF)), GR32:$src)>;
527 def : Pat<(f32 (sint_to_fp GR64:$src)),
528 (VCVTSI2SS64rr (f32 (IMPLICIT_DEF)), GR64:$src)>;
529 def : Pat<(f64 (sint_to_fp GR32:$src)),
530 (VCVTSI2SDrr (f64 (IMPLICIT_DEF)), GR32:$src)>;
531 def : Pat<(f64 (sint_to_fp GR64:$src)),
532 (VCVTSI2SD64rr (f64 (IMPLICIT_DEF)), GR64:$src)>;
535 defm CVTTSS2SI : sse12_cvt_s<0x2C, FR32, GR32, fp_to_sint, f32mem, loadf32,
536 "cvttss2si\t{$src, $dst|$dst, $src}">, XS;
537 defm CVTTSS2SI64 : sse12_cvt_s<0x2C, FR32, GR64, fp_to_sint, f32mem, loadf32,
538 "cvttss2si{q}\t{$src, $dst|$dst, $src}">, XS, REX_W;
539 defm CVTTSD2SI : sse12_cvt_s<0x2C, FR64, GR32, fp_to_sint, f64mem, loadf64,
540 "cvttsd2si\t{$src, $dst|$dst, $src}">, XD;
541 defm CVTTSD2SI64 : sse12_cvt_s<0x2C, FR64, GR64, fp_to_sint, f64mem, loadf64,
542 "cvttsd2si{q}\t{$src, $dst|$dst, $src}">, XD, REX_W;
543 defm CVTSI2SS : sse12_cvt_s<0x2A, GR32, FR32, sint_to_fp, i32mem, loadi32,
544 "cvtsi2ss\t{$src, $dst|$dst, $src}">, XS;
545 defm CVTSI2SS64 : sse12_cvt_s<0x2A, GR64, FR32, sint_to_fp, i64mem, loadi64,
546 "cvtsi2ss{q}\t{$src, $dst|$dst, $src}">, XS, REX_W;
547 defm CVTSI2SD : sse12_cvt_s<0x2A, GR32, FR64, sint_to_fp, i32mem, loadi32,
548 "cvtsi2sd\t{$src, $dst|$dst, $src}">, XD;
549 defm CVTSI2SD64 : sse12_cvt_s<0x2A, GR64, FR64, sint_to_fp, i64mem, loadi64,
550 "cvtsi2sd{q}\t{$src, $dst|$dst, $src}">, XD, REX_W;
552 // Conversion Instructions Intrinsics - Match intrinsics which expect MM
553 // and/or XMM operand(s).
555 multiclass sse12_cvt_sint<bits<8> opc, RegisterClass SrcRC, RegisterClass DstRC,
556 Intrinsic Int, X86MemOperand x86memop, PatFrag ld_frag,
558 def rr : SI<opc, MRMSrcReg, (outs DstRC:$dst), (ins SrcRC:$src),
559 !strconcat(asm, "\t{$src, $dst|$dst, $src}"),
560 [(set DstRC:$dst, (Int SrcRC:$src))]>;
561 def rm : SI<opc, MRMSrcMem, (outs DstRC:$dst), (ins x86memop:$src),
562 !strconcat(asm, "\t{$src, $dst|$dst, $src}"),
563 [(set DstRC:$dst, (Int (ld_frag addr:$src)))]>;
566 multiclass sse12_cvt_sint_3addr<bits<8> opc, RegisterClass SrcRC,
567 RegisterClass DstRC, Intrinsic Int, X86MemOperand x86memop,
568 PatFrag ld_frag, string asm, bit Is2Addr = 1> {
569 def rr : SI<opc, MRMSrcReg, (outs DstRC:$dst), (ins DstRC:$src1, SrcRC:$src2),
571 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
572 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
573 [(set DstRC:$dst, (Int DstRC:$src1, SrcRC:$src2))]>;
574 def rm : SI<opc, MRMSrcMem, (outs DstRC:$dst),
575 (ins DstRC:$src1, x86memop:$src2),
577 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
578 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
579 [(set DstRC:$dst, (Int DstRC:$src1, (ld_frag addr:$src2)))]>;
582 defm Int_VCVTSS2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse_cvtss2si,
583 f32mem, load, "cvtss2si">, XS, VEX;
584 defm Int_VCVTSS2SI64 : sse12_cvt_sint<0x2D, VR128, GR64,
585 int_x86_sse_cvtss2si64, f32mem, load, "cvtss2si">,
587 defm Int_VCVTSD2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse2_cvtsd2si,
588 f128mem, load, "cvtsd2si">, XD, VEX;
589 defm Int_VCVTSD2SI64 : sse12_cvt_sint<0x2D, VR128, GR64,
590 int_x86_sse2_cvtsd2si64, f128mem, load, "cvtsd2si">,
593 // FIXME: The asm matcher has a hack to ignore instructions with _Int and Int_
594 // Get rid of this hack or rename the intrinsics, there are several
595 // intructions that only match with the intrinsic form, why create duplicates
596 // to let them be recognized by the assembler?
597 defm VCVTSD2SI_alt : sse12_cvt_s_np<0x2D, FR64, GR32, f64mem,
598 "cvtsd2si\t{$src, $dst|$dst, $src}">, XD, VEX;
599 defm VCVTSD2SI64 : sse12_cvt_s_np<0x2D, FR64, GR64, f64mem,
600 "cvtsd2si\t{$src, $dst|$dst, $src}">, XD, VEX, VEX_W;
601 defm Int_CVTSS2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse_cvtss2si,
602 f32mem, load, "cvtss2si">, XS;
603 defm Int_CVTSS2SI64 : sse12_cvt_sint<0x2D, VR128, GR64, int_x86_sse_cvtss2si64,
604 f32mem, load, "cvtss2si{q}">, XS, REX_W;
605 defm CVTSD2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse2_cvtsd2si,
606 f128mem, load, "cvtsd2si{l}">, XD;
607 defm CVTSD2SI64 : sse12_cvt_sint<0x2D, VR128, GR64, int_x86_sse2_cvtsd2si64,
608 f128mem, load, "cvtsd2si{q}">, XD, REX_W;
611 defm Int_VCVTSI2SS : sse12_cvt_sint_3addr<0x2A, GR32, VR128,
612 int_x86_sse_cvtsi2ss, i32mem, loadi32, "cvtsi2ss", 0>, XS, VEX_4V;
613 defm Int_VCVTSI2SS64 : sse12_cvt_sint_3addr<0x2A, GR64, VR128,
614 int_x86_sse_cvtsi642ss, i64mem, loadi64, "cvtsi2ss", 0>, XS, VEX_4V,
616 defm Int_VCVTSI2SD : sse12_cvt_sint_3addr<0x2A, GR32, VR128,
617 int_x86_sse2_cvtsi2sd, i32mem, loadi32, "cvtsi2sd", 0>, XD, VEX_4V;
618 defm Int_VCVTSI2SD64 : sse12_cvt_sint_3addr<0x2A, GR64, VR128,
619 int_x86_sse2_cvtsi642sd, i64mem, loadi64, "cvtsi2sd", 0>, XD,
622 let Constraints = "$src1 = $dst" in {
623 defm Int_CVTSI2SS : sse12_cvt_sint_3addr<0x2A, GR32, VR128,
624 int_x86_sse_cvtsi2ss, i32mem, loadi32,
626 defm Int_CVTSI2SS64 : sse12_cvt_sint_3addr<0x2A, GR64, VR128,
627 int_x86_sse_cvtsi642ss, i64mem, loadi64,
628 "cvtsi2ss{q}">, XS, REX_W;
629 defm Int_CVTSI2SD : sse12_cvt_sint_3addr<0x2A, GR32, VR128,
630 int_x86_sse2_cvtsi2sd, i32mem, loadi32,
632 defm Int_CVTSI2SD64 : sse12_cvt_sint_3addr<0x2A, GR64, VR128,
633 int_x86_sse2_cvtsi642sd, i64mem, loadi64,
634 "cvtsi2sd">, XD, REX_W;
639 // Aliases for intrinsics
640 defm Int_VCVTTSS2SI : sse12_cvt_sint<0x2C, VR128, GR32, int_x86_sse_cvttss2si,
641 f32mem, load, "cvttss2si">, XS, VEX;
642 defm Int_VCVTTSS2SI64 : sse12_cvt_sint<0x2C, VR128, GR64,
643 int_x86_sse_cvttss2si64, f32mem, load,
644 "cvttss2si">, XS, VEX, VEX_W;
645 defm Int_VCVTTSD2SI : sse12_cvt_sint<0x2C, VR128, GR32, int_x86_sse2_cvttsd2si,
646 f128mem, load, "cvttsd2si">, XD, VEX;
647 defm Int_VCVTTSD2SI64 : sse12_cvt_sint<0x2C, VR128, GR64,
648 int_x86_sse2_cvttsd2si64, f128mem, load,
649 "cvttsd2si">, XD, VEX, VEX_W;
650 defm Int_CVTTSS2SI : sse12_cvt_sint<0x2C, VR128, GR32, int_x86_sse_cvttss2si,
651 f32mem, load, "cvttss2si">, XS;
652 defm Int_CVTTSS2SI64 : sse12_cvt_sint<0x2C, VR128, GR64,
653 int_x86_sse_cvttss2si64, f32mem, load,
654 "cvttss2si{q}">, XS, REX_W;
655 defm Int_CVTTSD2SI : sse12_cvt_sint<0x2C, VR128, GR32, int_x86_sse2_cvttsd2si,
656 f128mem, load, "cvttsd2si">, XD;
657 defm Int_CVTTSD2SI64 : sse12_cvt_sint<0x2C, VR128, GR64,
658 int_x86_sse2_cvttsd2si64, f128mem, load,
659 "cvttsd2si{q}">, XD, REX_W;
661 let Pattern = []<dag> in {
662 defm VCVTSS2SI : sse12_cvt_s<0x2D, FR32, GR32, undef, f32mem, load,
663 "cvtss2si{l}\t{$src, $dst|$dst, $src}">, XS, VEX;
664 defm VCVTSS2SI64 : sse12_cvt_s<0x2D, FR32, GR64, undef, f32mem, load,
665 "cvtss2si\t{$src, $dst|$dst, $src}">, XS, VEX,
667 defm VCVTDQ2PS : sse12_cvt_p<0x5B, VR128, VR128, undef, i128mem, load,
668 "cvtdq2ps\t{$src, $dst|$dst, $src}",
669 SSEPackedSingle>, TB, VEX;
670 defm VCVTDQ2PSY : sse12_cvt_p<0x5B, VR256, VR256, undef, i256mem, load,
671 "cvtdq2ps\t{$src, $dst|$dst, $src}",
672 SSEPackedSingle>, TB, VEX;
674 let Pattern = []<dag> in {
675 defm CVTSS2SI : sse12_cvt_s<0x2D, FR32, GR32, undef, f32mem, load /*dummy*/,
676 "cvtss2si{l}\t{$src, $dst|$dst, $src}">, XS;
677 defm CVTSS2SI64 : sse12_cvt_s<0x2D, FR32, GR64, undef, f32mem, load /*dummy*/,
678 "cvtss2si{q}\t{$src, $dst|$dst, $src}">, XS, REX_W;
679 defm CVTDQ2PS : sse12_cvt_p<0x5B, VR128, VR128, undef, i128mem, load /*dummy*/,
680 "cvtdq2ps\t{$src, $dst|$dst, $src}",
681 SSEPackedSingle>, TB; /* PD SSE3 form is avaiable */
686 // Convert scalar double to scalar single
687 def VCVTSD2SSrr : VSDI<0x5A, MRMSrcReg, (outs FR32:$dst),
688 (ins FR64:$src1, FR64:$src2),
689 "cvtsd2ss\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>,
691 def VCVTSD2SSrm : I<0x5A, MRMSrcMem, (outs FR32:$dst),
692 (ins FR64:$src1, f64mem:$src2),
693 "vcvtsd2ss\t{$src2, $src1, $dst|$dst, $src1, $src2}",
694 []>, XD, Requires<[HasAVX, OptForSize]>, VEX_4V;
695 def : Pat<(f32 (fround FR64:$src)), (VCVTSD2SSrr FR64:$src, FR64:$src)>,
698 def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
699 "cvtsd2ss\t{$src, $dst|$dst, $src}",
700 [(set FR32:$dst, (fround FR64:$src))]>;
701 def CVTSD2SSrm : I<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
702 "cvtsd2ss\t{$src, $dst|$dst, $src}",
703 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>, XD,
704 Requires<[HasSSE2, OptForSize]>;
706 defm Int_VCVTSD2SS: sse12_cvt_sint_3addr<0x5A, VR128, VR128,
707 int_x86_sse2_cvtsd2ss, f64mem, load, "cvtsd2ss", 0>,
709 let Constraints = "$src1 = $dst" in
710 defm Int_CVTSD2SS: sse12_cvt_sint_3addr<0x5A, VR128, VR128,
711 int_x86_sse2_cvtsd2ss, f64mem, load, "cvtsd2ss">, XS;
713 // Convert scalar single to scalar double
714 // SSE2 instructions with XS prefix
715 def VCVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst),
716 (ins FR32:$src1, FR32:$src2),
717 "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
718 []>, XS, Requires<[HasAVX]>, VEX_4V;
719 def VCVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst),
720 (ins FR32:$src1, f32mem:$src2),
721 "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
722 []>, XS, VEX_4V, Requires<[HasAVX, OptForSize]>;
724 let Predicates = [HasAVX] in {
725 def : Pat<(f64 (fextend FR32:$src)),
726 (VCVTSS2SDrr FR32:$src, FR32:$src)>;
727 def : Pat<(fextend (loadf32 addr:$src)),
728 (VCVTSS2SDrm (f32 (IMPLICIT_DEF)), addr:$src)>;
729 def : Pat<(extloadf32 addr:$src),
730 (VCVTSS2SDrm (f32 (IMPLICIT_DEF)), addr:$src)>;
733 def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
734 "cvtss2sd\t{$src, $dst|$dst, $src}",
735 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
737 def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
738 "cvtss2sd\t{$src, $dst|$dst, $src}",
739 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
740 Requires<[HasSSE2, OptForSize]>;
742 def Int_VCVTSS2SDrr: I<0x5A, MRMSrcReg,
743 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
744 "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
745 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
746 VR128:$src2))]>, XS, VEX_4V,
748 def Int_VCVTSS2SDrm: I<0x5A, MRMSrcMem,
749 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
750 "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
751 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
752 (load addr:$src2)))]>, XS, VEX_4V,
754 let Constraints = "$src1 = $dst" in { // SSE2 instructions with XS prefix
755 def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
756 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
757 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
758 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
761 def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
762 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
763 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
764 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
765 (load addr:$src2)))]>, XS,
769 def : Pat<(extloadf32 addr:$src),
770 (CVTSS2SDrr (MOVSSrm addr:$src))>,
771 Requires<[HasSSE2, OptForSpeed]>;
773 // Convert doubleword to packed single/double fp
774 // SSE2 instructions without OpSize prefix
775 def Int_VCVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
776 "vcvtdq2ps\t{$src, $dst|$dst, $src}",
777 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
778 TB, VEX, Requires<[HasAVX]>;
779 def Int_VCVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
780 "vcvtdq2ps\t{$src, $dst|$dst, $src}",
781 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
782 (bitconvert (memopv2i64 addr:$src))))]>,
783 TB, VEX, Requires<[HasAVX]>;
784 def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
785 "cvtdq2ps\t{$src, $dst|$dst, $src}",
786 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
787 TB, Requires<[HasSSE2]>;
788 def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
789 "cvtdq2ps\t{$src, $dst|$dst, $src}",
790 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
791 (bitconvert (memopv2i64 addr:$src))))]>,
792 TB, Requires<[HasSSE2]>;
794 // FIXME: why the non-intrinsic version is described as SSE3?
795 // SSE2 instructions with XS prefix
796 def Int_VCVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
797 "vcvtdq2pd\t{$src, $dst|$dst, $src}",
798 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
799 XS, VEX, Requires<[HasAVX]>;
800 def Int_VCVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
801 "vcvtdq2pd\t{$src, $dst|$dst, $src}",
802 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
803 (bitconvert (memopv2i64 addr:$src))))]>,
804 XS, VEX, Requires<[HasAVX]>;
805 def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
806 "cvtdq2pd\t{$src, $dst|$dst, $src}",
807 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
808 XS, Requires<[HasSSE2]>;
809 def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
810 "cvtdq2pd\t{$src, $dst|$dst, $src}",
811 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
812 (bitconvert (memopv2i64 addr:$src))))]>,
813 XS, Requires<[HasSSE2]>;
816 // Convert packed single/double fp to doubleword
817 def VCVTPS2DQrr : VPDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
818 "cvtps2dq\t{$src, $dst|$dst, $src}", []>, VEX;
819 def VCVTPS2DQrm : VPDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
820 "cvtps2dq\t{$src, $dst|$dst, $src}", []>, VEX;
821 def VCVTPS2DQYrr : VPDI<0x5B, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src),
822 "cvtps2dq\t{$src, $dst|$dst, $src}", []>, VEX;
823 def VCVTPS2DQYrm : VPDI<0x5B, MRMSrcMem, (outs VR256:$dst), (ins f256mem:$src),
824 "cvtps2dq\t{$src, $dst|$dst, $src}", []>, VEX;
825 def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
826 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
827 def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
828 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
830 def Int_VCVTPS2DQrr : VPDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
831 "cvtps2dq\t{$src, $dst|$dst, $src}",
832 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>,
834 def Int_VCVTPS2DQrm : VPDI<0x5B, MRMSrcMem, (outs VR128:$dst),
836 "cvtps2dq\t{$src, $dst|$dst, $src}",
837 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
838 (memop addr:$src)))]>, VEX;
839 def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
840 "cvtps2dq\t{$src, $dst|$dst, $src}",
841 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
842 def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
843 "cvtps2dq\t{$src, $dst|$dst, $src}",
844 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
845 (memop addr:$src)))]>;
847 // SSE2 packed instructions with XD prefix
848 def Int_VCVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
849 "vcvtpd2dq\t{$src, $dst|$dst, $src}",
850 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
851 XD, VEX, Requires<[HasAVX]>;
852 def Int_VCVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
853 "vcvtpd2dq\t{$src, $dst|$dst, $src}",
854 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
855 (memop addr:$src)))]>,
856 XD, VEX, Requires<[HasAVX]>;
857 def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
858 "cvtpd2dq\t{$src, $dst|$dst, $src}",
859 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
860 XD, Requires<[HasSSE2]>;
861 def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
862 "cvtpd2dq\t{$src, $dst|$dst, $src}",
863 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
864 (memop addr:$src)))]>,
865 XD, Requires<[HasSSE2]>;
868 // Convert with truncation packed single/double fp to doubleword
869 // SSE2 packed instructions with XS prefix
870 def VCVTTPS2DQrr : VSSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
871 "cvttps2dq\t{$src, $dst|$dst, $src}", []>, VEX;
872 def VCVTTPS2DQrm : VSSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
873 "cvttps2dq\t{$src, $dst|$dst, $src}", []>, VEX;
874 def VCVTTPS2DQYrr : VSSI<0x5B, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src),
875 "cvttps2dq\t{$src, $dst|$dst, $src}", []>, VEX;
876 def VCVTTPS2DQYrm : VSSI<0x5B, MRMSrcMem, (outs VR256:$dst), (ins f256mem:$src),
877 "cvttps2dq\t{$src, $dst|$dst, $src}", []>, VEX;
878 def CVTTPS2DQrr : SSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
879 "cvttps2dq\t{$src, $dst|$dst, $src}",
881 (int_x86_sse2_cvttps2dq VR128:$src))]>;
882 def CVTTPS2DQrm : SSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
883 "cvttps2dq\t{$src, $dst|$dst, $src}",
885 (int_x86_sse2_cvttps2dq (memop addr:$src)))]>;
887 def Int_VCVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
888 "vcvttps2dq\t{$src, $dst|$dst, $src}",
890 (int_x86_sse2_cvttps2dq VR128:$src))]>,
891 XS, VEX, Requires<[HasAVX]>;
892 def Int_VCVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
893 "vcvttps2dq\t{$src, $dst|$dst, $src}",
894 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
895 (memop addr:$src)))]>,
896 XS, VEX, Requires<[HasAVX]>;
898 def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
899 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
900 def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
901 (CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
903 def : Pat<(v8f32 (sint_to_fp (v8i32 VR256:$src))),
904 (VCVTDQ2PSYrr VR256:$src)>, Requires<[HasAVX]>;
905 def : Pat<(v8i32 (fp_to_sint (v8f32 VR256:$src))),
906 (VCVTTPS2DQYrr VR256:$src)>, Requires<[HasAVX]>;
908 def Int_VCVTTPD2DQrr : VPDI<0xE6, MRMSrcReg, (outs VR128:$dst),
910 "cvttpd2dq\t{$src, $dst|$dst, $src}",
911 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>,
913 def Int_VCVTTPD2DQrm : VPDI<0xE6, MRMSrcMem, (outs VR128:$dst),
915 "cvttpd2dq\t{$src, $dst|$dst, $src}",
916 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
917 (memop addr:$src)))]>, VEX;
918 def CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
919 "cvttpd2dq\t{$src, $dst|$dst, $src}",
920 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
921 def CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
922 "cvttpd2dq\t{$src, $dst|$dst, $src}",
923 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
924 (memop addr:$src)))]>;
926 // The assembler can recognize rr 256-bit instructions by seeing a ymm
927 // register, but the same isn't true when using memory operands instead.
928 // Provide other assembly rr and rm forms to address this explicitly.
929 def VCVTTPD2DQrr : VPDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
930 "cvttpd2dq\t{$src, $dst|$dst, $src}", []>, VEX;
931 def VCVTTPD2DQXrYr : VPDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR256:$src),
932 "cvttpd2dq\t{$src, $dst|$dst, $src}", []>, VEX;
935 def VCVTTPD2DQXrr : VPDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
936 "cvttpd2dqx\t{$src, $dst|$dst, $src}", []>, VEX;
937 def VCVTTPD2DQXrm : VPDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
938 "cvttpd2dqx\t{$src, $dst|$dst, $src}", []>, VEX;
941 def VCVTTPD2DQYrr : VPDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR256:$src),
942 "cvttpd2dqy\t{$src, $dst|$dst, $src}", []>, VEX;
943 def VCVTTPD2DQYrm : VPDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f256mem:$src),
944 "cvttpd2dqy\t{$src, $dst|$dst, $src}", []>, VEX, VEX_L;
946 // Convert packed single to packed double
947 let Predicates = [HasAVX] in {
948 // SSE2 instructions without OpSize prefix
949 def VCVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
950 "vcvtps2pd\t{$src, $dst|$dst, $src}", []>, VEX;
951 def VCVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
952 "vcvtps2pd\t{$src, $dst|$dst, $src}", []>, VEX;
953 def VCVTPS2PDYrr : I<0x5A, MRMSrcReg, (outs VR256:$dst), (ins VR128:$src),
954 "vcvtps2pd\t{$src, $dst|$dst, $src}", []>, VEX;
955 def VCVTPS2PDYrm : I<0x5A, MRMSrcMem, (outs VR256:$dst), (ins f128mem:$src),
956 "vcvtps2pd\t{$src, $dst|$dst, $src}", []>, VEX;
958 def CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
959 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
960 def CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
961 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
963 def Int_VCVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
964 "vcvtps2pd\t{$src, $dst|$dst, $src}",
965 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
966 VEX, Requires<[HasAVX]>;
967 def Int_VCVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
968 "vcvtps2pd\t{$src, $dst|$dst, $src}",
969 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
970 (load addr:$src)))]>,
971 VEX, Requires<[HasAVX]>;
972 def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
973 "cvtps2pd\t{$src, $dst|$dst, $src}",
974 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
975 TB, Requires<[HasSSE2]>;
976 def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
977 "cvtps2pd\t{$src, $dst|$dst, $src}",
978 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
979 (load addr:$src)))]>,
980 TB, Requires<[HasSSE2]>;
982 // Convert packed double to packed single
983 // The assembler can recognize rr 256-bit instructions by seeing a ymm
984 // register, but the same isn't true when using memory operands instead.
985 // Provide other assembly rr and rm forms to address this explicitly.
986 def VCVTPD2PSrr : VPDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
987 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>, VEX;
988 def VCVTPD2PSXrYr : VPDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR256:$src),
989 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>, VEX;
992 def VCVTPD2PSXrr : VPDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
993 "cvtpd2psx\t{$src, $dst|$dst, $src}", []>, VEX;
994 def VCVTPD2PSXrm : VPDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
995 "cvtpd2psx\t{$src, $dst|$dst, $src}", []>, VEX;
998 def VCVTPD2PSYrr : VPDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR256:$src),
999 "cvtpd2psy\t{$src, $dst|$dst, $src}", []>, VEX;
1000 def VCVTPD2PSYrm : VPDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f256mem:$src),
1001 "cvtpd2psy\t{$src, $dst|$dst, $src}", []>, VEX, VEX_L;
1002 def CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1003 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1004 def CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1005 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1008 def Int_VCVTPD2PSrr : VPDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1009 "cvtpd2ps\t{$src, $dst|$dst, $src}",
1010 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
1011 def Int_VCVTPD2PSrm : VPDI<0x5A, MRMSrcMem, (outs VR128:$dst),
1013 "cvtpd2ps\t{$src, $dst|$dst, $src}",
1014 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1015 (memop addr:$src)))]>;
1016 def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1017 "cvtpd2ps\t{$src, $dst|$dst, $src}",
1018 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
1019 def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1020 "cvtpd2ps\t{$src, $dst|$dst, $src}",
1021 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1022 (memop addr:$src)))]>;
1024 // AVX 256-bit register conversion intrinsics
1025 // FIXME: Migrate SSE conversion intrinsics matching to use patterns as below
1026 // whenever possible to avoid declaring two versions of each one.
1027 def : Pat<(int_x86_avx_cvtdq2_ps_256 VR256:$src),
1028 (VCVTDQ2PSYrr VR256:$src)>;
1029 def : Pat<(int_x86_avx_cvtdq2_ps_256 (memopv8i32 addr:$src)),
1030 (VCVTDQ2PSYrm addr:$src)>;
1032 def : Pat<(int_x86_avx_cvt_pd2_ps_256 VR256:$src),
1033 (VCVTPD2PSYrr VR256:$src)>;
1034 def : Pat<(int_x86_avx_cvt_pd2_ps_256 (memopv4f64 addr:$src)),
1035 (VCVTPD2PSYrm addr:$src)>;
1037 def : Pat<(int_x86_avx_cvt_ps2dq_256 VR256:$src),
1038 (VCVTPS2DQYrr VR256:$src)>;
1039 def : Pat<(int_x86_avx_cvt_ps2dq_256 (memopv8f32 addr:$src)),
1040 (VCVTPS2DQYrm addr:$src)>;
1042 def : Pat<(int_x86_avx_cvt_ps2_pd_256 VR128:$src),
1043 (VCVTPS2PDYrr VR128:$src)>;
1044 def : Pat<(int_x86_avx_cvt_ps2_pd_256 (memopv4f32 addr:$src)),
1045 (VCVTPS2PDYrm addr:$src)>;
1047 def : Pat<(int_x86_avx_cvtt_pd2dq_256 VR256:$src),
1048 (VCVTTPD2DQYrr VR256:$src)>;
1049 def : Pat<(int_x86_avx_cvtt_pd2dq_256 (memopv4f64 addr:$src)),
1050 (VCVTTPD2DQYrm addr:$src)>;
1052 def : Pat<(int_x86_avx_cvtt_ps2dq_256 VR256:$src),
1053 (VCVTTPS2DQYrr VR256:$src)>;
1054 def : Pat<(int_x86_avx_cvtt_ps2dq_256 (memopv8f32 addr:$src)),
1055 (VCVTTPS2DQYrm addr:$src)>;
1057 // Match fround for 128/256-bit conversions
1058 def : Pat<(v4f32 (fround (v4f64 VR256:$src))),
1059 (VCVTPD2PSYrr VR256:$src)>;
1060 def : Pat<(v4f32 (fround (loadv4f64 addr:$src))),
1061 (VCVTPD2PSYrm addr:$src)>;
1063 //===----------------------------------------------------------------------===//
1064 // SSE 1 & 2 - Compare Instructions
1065 //===----------------------------------------------------------------------===//
1067 // sse12_cmp_scalar - sse 1 & 2 compare scalar instructions
1068 multiclass sse12_cmp_scalar<RegisterClass RC, X86MemOperand x86memop,
1069 string asm, string asm_alt> {
1070 let isAsmParserOnly = 1 in {
1071 def rr : SIi8<0xC2, MRMSrcReg,
1072 (outs RC:$dst), (ins RC:$src1, RC:$src, SSECC:$cc),
1075 def rm : SIi8<0xC2, MRMSrcMem,
1076 (outs RC:$dst), (ins RC:$src1, x86memop:$src, SSECC:$cc),
1080 // Accept explicit immediate argument form instead of comparison code.
1081 def rr_alt : SIi8<0xC2, MRMSrcReg,
1082 (outs RC:$dst), (ins RC:$src1, RC:$src, i8imm:$src2),
1085 def rm_alt : SIi8<0xC2, MRMSrcMem,
1086 (outs RC:$dst), (ins RC:$src1, x86memop:$src, i8imm:$src2),
1090 let neverHasSideEffects = 1 in {
1091 defm VCMPSS : sse12_cmp_scalar<FR32, f32mem,
1092 "cmp${cc}ss\t{$src, $src1, $dst|$dst, $src1, $src}",
1093 "cmpss\t{$src2, $src, $src1, $dst|$dst, $src1, $src, $src2}">,
1095 defm VCMPSD : sse12_cmp_scalar<FR64, f64mem,
1096 "cmp${cc}sd\t{$src, $src1, $dst|$dst, $src1, $src}",
1097 "cmpsd\t{$src2, $src, $src1, $dst|$dst, $src1, $src, $src2}">,
1101 let Constraints = "$src1 = $dst" in {
1102 def CMPSSrr : SIi8<0xC2, MRMSrcReg,
1103 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2, SSECC:$cc),
1104 "cmp${cc}ss\t{$src2, $dst|$dst, $src2}",
1105 [(set FR32:$dst, (X86cmpss (f32 FR32:$src1), FR32:$src2, imm:$cc))]>, XS;
1106 def CMPSSrm : SIi8<0xC2, MRMSrcMem,
1107 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2, SSECC:$cc),
1108 "cmp${cc}ss\t{$src2, $dst|$dst, $src2}",
1109 [(set FR32:$dst, (X86cmpss (f32 FR32:$src1), (loadf32 addr:$src2), imm:$cc))]>, XS;
1110 def CMPSDrr : SIi8<0xC2, MRMSrcReg,
1111 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2, SSECC:$cc),
1112 "cmp${cc}sd\t{$src2, $dst|$dst, $src2}",
1113 [(set FR64:$dst, (X86cmpsd (f64 FR64:$src1), FR64:$src2, imm:$cc))]>, XD;
1114 def CMPSDrm : SIi8<0xC2, MRMSrcMem,
1115 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2, SSECC:$cc),
1116 "cmp${cc}sd\t{$src2, $dst|$dst, $src2}",
1117 [(set FR64:$dst, (X86cmpsd (f64 FR64:$src1), (loadf64 addr:$src2), imm:$cc))]>, XD;
1119 let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
1120 def CMPSSrr_alt : SIi8<0xC2, MRMSrcReg,
1121 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, i8imm:$src2),
1122 "cmpss\t{$src2, $src, $dst|$dst, $src, $src2}", []>, XS;
1123 def CMPSSrm_alt : SIi8<0xC2, MRMSrcMem,
1124 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, i8imm:$src2),
1125 "cmpss\t{$src2, $src, $dst|$dst, $src, $src2}", []>, XS;
1126 def CMPSDrr_alt : SIi8<0xC2, MRMSrcReg,
1127 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, i8imm:$src2),
1128 "cmpsd\t{$src2, $src, $dst|$dst, $src, $src2}", []>, XD;
1129 def CMPSDrm_alt : SIi8<0xC2, MRMSrcMem,
1130 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, i8imm:$src2),
1131 "cmpsd\t{$src2, $src, $dst|$dst, $src, $src2}", []>, XD;
1134 multiclass sse12_cmp_scalar_int<RegisterClass RC, X86MemOperand x86memop,
1135 Intrinsic Int, string asm> {
1136 def rr : SIi8<0xC2, MRMSrcReg, (outs VR128:$dst),
1137 (ins VR128:$src1, VR128:$src, SSECC:$cc), asm,
1138 [(set VR128:$dst, (Int VR128:$src1,
1139 VR128:$src, imm:$cc))]>;
1140 def rm : SIi8<0xC2, MRMSrcMem, (outs VR128:$dst),
1141 (ins VR128:$src1, f32mem:$src, SSECC:$cc), asm,
1142 [(set VR128:$dst, (Int VR128:$src1,
1143 (load addr:$src), imm:$cc))]>;
1146 // Aliases to match intrinsics which expect XMM operand(s).
1147 defm Int_VCMPSS : sse12_cmp_scalar_int<VR128, f32mem, int_x86_sse_cmp_ss,
1148 "cmp${cc}ss\t{$src, $src1, $dst|$dst, $src1, $src}">,
1150 defm Int_VCMPSD : sse12_cmp_scalar_int<VR128, f64mem, int_x86_sse2_cmp_sd,
1151 "cmp${cc}sd\t{$src, $src1, $dst|$dst, $src1, $src}">,
1153 let Constraints = "$src1 = $dst" in {
1154 defm Int_CMPSS : sse12_cmp_scalar_int<VR128, f32mem, int_x86_sse_cmp_ss,
1155 "cmp${cc}ss\t{$src, $dst|$dst, $src}">, XS;
1156 defm Int_CMPSD : sse12_cmp_scalar_int<VR128, f64mem, int_x86_sse2_cmp_sd,
1157 "cmp${cc}sd\t{$src, $dst|$dst, $src}">, XD;
1161 // sse12_ord_cmp - Unordered/Ordered scalar fp compare and set EFLAGS
1162 multiclass sse12_ord_cmp<bits<8> opc, RegisterClass RC, SDNode OpNode,
1163 ValueType vt, X86MemOperand x86memop,
1164 PatFrag ld_frag, string OpcodeStr, Domain d> {
1165 def rr: PI<opc, MRMSrcReg, (outs), (ins RC:$src1, RC:$src2),
1166 !strconcat(OpcodeStr, "\t{$src2, $src1|$src1, $src2}"),
1167 [(set EFLAGS, (OpNode (vt RC:$src1), RC:$src2))], d>;
1168 def rm: PI<opc, MRMSrcMem, (outs), (ins RC:$src1, x86memop:$src2),
1169 !strconcat(OpcodeStr, "\t{$src2, $src1|$src1, $src2}"),
1170 [(set EFLAGS, (OpNode (vt RC:$src1),
1171 (ld_frag addr:$src2)))], d>;
1174 let Defs = [EFLAGS] in {
1175 defm VUCOMISS : sse12_ord_cmp<0x2E, FR32, X86cmp, f32, f32mem, loadf32,
1176 "ucomiss", SSEPackedSingle>, VEX;
1177 defm VUCOMISD : sse12_ord_cmp<0x2E, FR64, X86cmp, f64, f64mem, loadf64,
1178 "ucomisd", SSEPackedDouble>, OpSize, VEX;
1179 let Pattern = []<dag> in {
1180 defm VCOMISS : sse12_ord_cmp<0x2F, VR128, undef, v4f32, f128mem, load,
1181 "comiss", SSEPackedSingle>, VEX;
1182 defm VCOMISD : sse12_ord_cmp<0x2F, VR128, undef, v2f64, f128mem, load,
1183 "comisd", SSEPackedDouble>, OpSize, VEX;
1186 defm Int_VUCOMISS : sse12_ord_cmp<0x2E, VR128, X86ucomi, v4f32, f128mem,
1187 load, "ucomiss", SSEPackedSingle>, VEX;
1188 defm Int_VUCOMISD : sse12_ord_cmp<0x2E, VR128, X86ucomi, v2f64, f128mem,
1189 load, "ucomisd", SSEPackedDouble>, OpSize, VEX;
1191 defm Int_VCOMISS : sse12_ord_cmp<0x2F, VR128, X86comi, v4f32, f128mem,
1192 load, "comiss", SSEPackedSingle>, VEX;
1193 defm Int_VCOMISD : sse12_ord_cmp<0x2F, VR128, X86comi, v2f64, f128mem,
1194 load, "comisd", SSEPackedDouble>, OpSize, VEX;
1195 defm UCOMISS : sse12_ord_cmp<0x2E, FR32, X86cmp, f32, f32mem, loadf32,
1196 "ucomiss", SSEPackedSingle>, TB;
1197 defm UCOMISD : sse12_ord_cmp<0x2E, FR64, X86cmp, f64, f64mem, loadf64,
1198 "ucomisd", SSEPackedDouble>, TB, OpSize;
1200 let Pattern = []<dag> in {
1201 defm COMISS : sse12_ord_cmp<0x2F, VR128, undef, v4f32, f128mem, load,
1202 "comiss", SSEPackedSingle>, TB;
1203 defm COMISD : sse12_ord_cmp<0x2F, VR128, undef, v2f64, f128mem, load,
1204 "comisd", SSEPackedDouble>, TB, OpSize;
1207 defm Int_UCOMISS : sse12_ord_cmp<0x2E, VR128, X86ucomi, v4f32, f128mem,
1208 load, "ucomiss", SSEPackedSingle>, TB;
1209 defm Int_UCOMISD : sse12_ord_cmp<0x2E, VR128, X86ucomi, v2f64, f128mem,
1210 load, "ucomisd", SSEPackedDouble>, TB, OpSize;
1212 defm Int_COMISS : sse12_ord_cmp<0x2F, VR128, X86comi, v4f32, f128mem, load,
1213 "comiss", SSEPackedSingle>, TB;
1214 defm Int_COMISD : sse12_ord_cmp<0x2F, VR128, X86comi, v2f64, f128mem, load,
1215 "comisd", SSEPackedDouble>, TB, OpSize;
1216 } // Defs = [EFLAGS]
1218 // sse12_cmp_packed - sse 1 & 2 compared packed instructions
1219 multiclass sse12_cmp_packed<RegisterClass RC, X86MemOperand x86memop,
1220 Intrinsic Int, string asm, string asm_alt,
1222 let isAsmParserOnly = 1 in {
1223 def rri : PIi8<0xC2, MRMSrcReg,
1224 (outs RC:$dst), (ins RC:$src1, RC:$src, SSECC:$cc), asm,
1225 [(set RC:$dst, (Int RC:$src1, RC:$src, imm:$cc))], d>;
1226 def rmi : PIi8<0xC2, MRMSrcMem,
1227 (outs RC:$dst), (ins RC:$src1, f128mem:$src, SSECC:$cc), asm,
1228 [(set RC:$dst, (Int RC:$src1, (memop addr:$src), imm:$cc))], d>;
1231 // Accept explicit immediate argument form instead of comparison code.
1232 def rri_alt : PIi8<0xC2, MRMSrcReg,
1233 (outs RC:$dst), (ins RC:$src1, RC:$src, i8imm:$src2),
1235 def rmi_alt : PIi8<0xC2, MRMSrcMem,
1236 (outs RC:$dst), (ins RC:$src1, f128mem:$src, i8imm:$src2),
1240 defm VCMPPS : sse12_cmp_packed<VR128, f128mem, int_x86_sse_cmp_ps,
1241 "cmp${cc}ps\t{$src, $src1, $dst|$dst, $src1, $src}",
1242 "cmpps\t{$src2, $src, $src1, $dst|$dst, $src1, $src, $src2}",
1243 SSEPackedSingle>, VEX_4V;
1244 defm VCMPPD : sse12_cmp_packed<VR128, f128mem, int_x86_sse2_cmp_pd,
1245 "cmp${cc}pd\t{$src, $src1, $dst|$dst, $src1, $src}",
1246 "cmppd\t{$src2, $src, $src1, $dst|$dst, $src1, $src, $src2}",
1247 SSEPackedDouble>, OpSize, VEX_4V;
1248 defm VCMPPSY : sse12_cmp_packed<VR256, f256mem, int_x86_avx_cmp_ps_256,
1249 "cmp${cc}ps\t{$src, $src1, $dst|$dst, $src1, $src}",
1250 "cmpps\t{$src2, $src, $src1, $dst|$dst, $src1, $src, $src2}",
1251 SSEPackedSingle>, VEX_4V;
1252 defm VCMPPDY : sse12_cmp_packed<VR256, f256mem, int_x86_avx_cmp_pd_256,
1253 "cmp${cc}pd\t{$src, $src1, $dst|$dst, $src1, $src}",
1254 "cmppd\t{$src2, $src, $src1, $dst|$dst, $src1, $src, $src2}",
1255 SSEPackedDouble>, OpSize, VEX_4V;
1256 let Constraints = "$src1 = $dst" in {
1257 defm CMPPS : sse12_cmp_packed<VR128, f128mem, int_x86_sse_cmp_ps,
1258 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
1259 "cmpps\t{$src2, $src, $dst|$dst, $src, $src2}",
1260 SSEPackedSingle>, TB;
1261 defm CMPPD : sse12_cmp_packed<VR128, f128mem, int_x86_sse2_cmp_pd,
1262 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1263 "cmppd\t{$src2, $src, $dst|$dst, $src, $src2}",
1264 SSEPackedDouble>, TB, OpSize;
1267 let Predicates = [HasSSE1] in {
1268 def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
1269 (CMPPSrri (v4f32 VR128:$src1), (v4f32 VR128:$src2), imm:$cc)>;
1270 def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
1271 (CMPPSrmi (v4f32 VR128:$src1), addr:$src2, imm:$cc)>;
1274 let Predicates = [HasSSE2] in {
1275 def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
1276 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
1277 def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
1278 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
1281 let Predicates = [HasAVX] in {
1282 def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
1283 (VCMPPSrri (v4f32 VR128:$src1), (v4f32 VR128:$src2), imm:$cc)>;
1284 def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
1285 (VCMPPSrmi (v4f32 VR128:$src1), addr:$src2, imm:$cc)>;
1286 def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
1287 (VCMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
1288 def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
1289 (VCMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
1291 def : Pat<(v8i32 (X86cmpps (v8f32 VR256:$src1), VR256:$src2, imm:$cc)),
1292 (VCMPPSYrri (v8f32 VR256:$src1), (v8f32 VR256:$src2), imm:$cc)>;
1293 def : Pat<(v8i32 (X86cmpps (v8f32 VR256:$src1), (memop addr:$src2), imm:$cc)),
1294 (VCMPPSYrmi (v8f32 VR256:$src1), addr:$src2, imm:$cc)>;
1295 def : Pat<(v4i64 (X86cmppd (v4f64 VR256:$src1), VR256:$src2, imm:$cc)),
1296 (VCMPPDYrri VR256:$src1, VR256:$src2, imm:$cc)>;
1297 def : Pat<(v4i64 (X86cmppd (v4f64 VR256:$src1), (memop addr:$src2), imm:$cc)),
1298 (VCMPPDYrmi VR256:$src1, addr:$src2, imm:$cc)>;
1301 //===----------------------------------------------------------------------===//
1302 // SSE 1 & 2 - Shuffle Instructions
1303 //===----------------------------------------------------------------------===//
1305 /// sse12_shuffle - sse 1 & 2 shuffle instructions
1306 multiclass sse12_shuffle<RegisterClass RC, X86MemOperand x86memop,
1307 ValueType vt, string asm, PatFrag mem_frag,
1308 Domain d, bit IsConvertibleToThreeAddress = 0> {
1309 def rmi : PIi8<0xC6, MRMSrcMem, (outs RC:$dst),
1310 (ins RC:$src1, f128mem:$src2, i8imm:$src3), asm,
1311 [(set RC:$dst, (vt (shufp:$src3
1312 RC:$src1, (mem_frag addr:$src2))))], d>;
1313 let isConvertibleToThreeAddress = IsConvertibleToThreeAddress in
1314 def rri : PIi8<0xC6, MRMSrcReg, (outs RC:$dst),
1315 (ins RC:$src1, RC:$src2, i8imm:$src3), asm,
1317 (vt (shufp:$src3 RC:$src1, RC:$src2)))], d>;
1320 defm VSHUFPS : sse12_shuffle<VR128, f128mem, v4f32,
1321 "shufps\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}",
1322 memopv4f32, SSEPackedSingle>, TB, VEX_4V;
1323 defm VSHUFPSY : sse12_shuffle<VR256, f256mem, v8f32,
1324 "shufps\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}",
1325 memopv8f32, SSEPackedSingle>, TB, VEX_4V;
1326 defm VSHUFPD : sse12_shuffle<VR128, f128mem, v2f64,
1327 "shufpd\t{$src3, $src2, $src1, $dst|$dst, $src2, $src2, $src3}",
1328 memopv2f64, SSEPackedDouble>, TB, OpSize, VEX_4V;
1329 defm VSHUFPDY : sse12_shuffle<VR256, f256mem, v4f64,
1330 "shufpd\t{$src3, $src2, $src1, $dst|$dst, $src2, $src2, $src3}",
1331 memopv4f64, SSEPackedDouble>, TB, OpSize, VEX_4V;
1333 let Constraints = "$src1 = $dst" in {
1334 defm SHUFPS : sse12_shuffle<VR128, f128mem, v4f32,
1335 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1336 memopv4f32, SSEPackedSingle, 1 /* cvt to pshufd */>,
1338 defm SHUFPD : sse12_shuffle<VR128, f128mem, v2f64,
1339 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1340 memopv2f64, SSEPackedDouble>, TB, OpSize;
1343 //===----------------------------------------------------------------------===//
1344 // SSE 1 & 2 - Unpack Instructions
1345 //===----------------------------------------------------------------------===//
1347 /// sse12_unpack_interleave - sse 1 & 2 unpack and interleave
1348 multiclass sse12_unpack_interleave<bits<8> opc, PatFrag OpNode, ValueType vt,
1349 PatFrag mem_frag, RegisterClass RC,
1350 X86MemOperand x86memop, string asm,
1352 def rr : PI<opc, MRMSrcReg,
1353 (outs RC:$dst), (ins RC:$src1, RC:$src2),
1355 (vt (OpNode RC:$src1, RC:$src2)))], d>;
1356 def rm : PI<opc, MRMSrcMem,
1357 (outs RC:$dst), (ins RC:$src1, x86memop:$src2),
1359 (vt (OpNode RC:$src1,
1360 (mem_frag addr:$src2))))], d>;
1363 let AddedComplexity = 10 in {
1364 defm VUNPCKHPS: sse12_unpack_interleave<0x15, unpckh, v4f32, memopv4f32,
1365 VR128, f128mem, "unpckhps\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1366 SSEPackedSingle>, VEX_4V;
1367 defm VUNPCKHPD: sse12_unpack_interleave<0x15, unpckh, v2f64, memopv2f64,
1368 VR128, f128mem, "unpckhpd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1369 SSEPackedDouble>, OpSize, VEX_4V;
1370 defm VUNPCKLPS: sse12_unpack_interleave<0x14, unpckl, v4f32, memopv4f32,
1371 VR128, f128mem, "unpcklps\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1372 SSEPackedSingle>, VEX_4V;
1373 defm VUNPCKLPD: sse12_unpack_interleave<0x14, unpckl, v2f64, memopv2f64,
1374 VR128, f128mem, "unpcklpd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1375 SSEPackedDouble>, OpSize, VEX_4V;
1377 defm VUNPCKHPSY: sse12_unpack_interleave<0x15, unpckh, v8f32, memopv8f32,
1378 VR256, f256mem, "unpckhps\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1379 SSEPackedSingle>, VEX_4V;
1380 defm VUNPCKHPDY: sse12_unpack_interleave<0x15, unpckh, v4f64, memopv4f64,
1381 VR256, f256mem, "unpckhpd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1382 SSEPackedDouble>, OpSize, VEX_4V;
1383 defm VUNPCKLPSY: sse12_unpack_interleave<0x14, unpckl, v8f32, memopv8f32,
1384 VR256, f256mem, "unpcklps\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1385 SSEPackedSingle>, VEX_4V;
1386 defm VUNPCKLPDY: sse12_unpack_interleave<0x14, unpckl, v4f64, memopv4f64,
1387 VR256, f256mem, "unpcklpd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1388 SSEPackedDouble>, OpSize, VEX_4V;
1390 let Constraints = "$src1 = $dst" in {
1391 defm UNPCKHPS: sse12_unpack_interleave<0x15, unpckh, v4f32, memopv4f32,
1392 VR128, f128mem, "unpckhps\t{$src2, $dst|$dst, $src2}",
1393 SSEPackedSingle>, TB;
1394 defm UNPCKHPD: sse12_unpack_interleave<0x15, unpckh, v2f64, memopv2f64,
1395 VR128, f128mem, "unpckhpd\t{$src2, $dst|$dst, $src2}",
1396 SSEPackedDouble>, TB, OpSize;
1397 defm UNPCKLPS: sse12_unpack_interleave<0x14, unpckl, v4f32, memopv4f32,
1398 VR128, f128mem, "unpcklps\t{$src2, $dst|$dst, $src2}",
1399 SSEPackedSingle>, TB;
1400 defm UNPCKLPD: sse12_unpack_interleave<0x14, unpckl, v2f64, memopv2f64,
1401 VR128, f128mem, "unpcklpd\t{$src2, $dst|$dst, $src2}",
1402 SSEPackedDouble>, TB, OpSize;
1403 } // Constraints = "$src1 = $dst"
1404 } // AddedComplexity
1406 //===----------------------------------------------------------------------===//
1407 // SSE 1 & 2 - Extract Floating-Point Sign mask
1408 //===----------------------------------------------------------------------===//
1410 /// sse12_extr_sign_mask - sse 1 & 2 unpack and interleave
1411 multiclass sse12_extr_sign_mask<RegisterClass RC, Intrinsic Int, string asm,
1413 def rr32 : PI<0x50, MRMSrcReg, (outs GR32:$dst), (ins RC:$src),
1414 !strconcat(asm, "\t{$src, $dst|$dst, $src}"),
1415 [(set GR32:$dst, (Int RC:$src))], d>;
1416 def rr64 : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins RC:$src),
1417 !strconcat(asm, "\t{$src, $dst|$dst, $src}"), [], d>, REX_W;
1421 defm VMOVMSKPS : sse12_extr_sign_mask<VR128, int_x86_sse_movmsk_ps,
1422 "movmskps", SSEPackedSingle>, VEX;
1423 defm VMOVMSKPD : sse12_extr_sign_mask<VR128, int_x86_sse2_movmsk_pd,
1424 "movmskpd", SSEPackedDouble>, OpSize,
1426 defm VMOVMSKPSY : sse12_extr_sign_mask<VR256, int_x86_avx_movmsk_ps_256,
1427 "movmskps", SSEPackedSingle>, VEX;
1428 defm VMOVMSKPDY : sse12_extr_sign_mask<VR256, int_x86_avx_movmsk_pd_256,
1429 "movmskpd", SSEPackedDouble>, OpSize,
1431 defm MOVMSKPS : sse12_extr_sign_mask<VR128, int_x86_sse_movmsk_ps, "movmskps",
1432 SSEPackedSingle>, TB;
1433 defm MOVMSKPD : sse12_extr_sign_mask<VR128, int_x86_sse2_movmsk_pd, "movmskpd",
1434 SSEPackedDouble>, TB, OpSize;
1437 def MOVMSKPDrr32_alt : PI<0x50, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
1438 "movmskpd\t{$src, $dst|$dst, $src}",
1439 [(set GR32:$dst, (X86fgetsign FR64:$src))], SSEPackedDouble>, TB, OpSize;
1440 def MOVMSKPDrr64_alt : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src),
1441 "movmskpd\t{$src, $dst|$dst, $src}",
1442 [(set GR64:$dst, (X86fgetsign FR64:$src))], SSEPackedDouble>, TB, OpSize;
1443 def MOVMSKPSrr32_alt : PI<0x50, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
1444 "movmskps\t{$src, $dst|$dst, $src}",
1445 [(set GR32:$dst, (X86fgetsign FR32:$src))], SSEPackedSingle>, TB;
1446 def MOVMSKPSrr64_alt : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src),
1447 "movmskps\t{$src, $dst|$dst, $src}",
1448 [(set GR64:$dst, (X86fgetsign FR32:$src))], SSEPackedSingle>, TB;
1451 def VMOVMSKPSr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
1452 "movmskps\t{$src, $dst|$dst, $src}", [], SSEPackedSingle>, VEX;
1453 def VMOVMSKPDr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
1454 "movmskpd\t{$src, $dst|$dst, $src}", [], SSEPackedDouble>, OpSize,
1456 def VMOVMSKPSYr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR256:$src),
1457 "movmskps\t{$src, $dst|$dst, $src}", [], SSEPackedSingle>, VEX;
1458 def VMOVMSKPDYr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR256:$src),
1459 "movmskpd\t{$src, $dst|$dst, $src}", [], SSEPackedDouble>, OpSize,
1462 //===----------------------------------------------------------------------===//
1463 // SSE 1 & 2 - Misc aliasing of packed SSE 1 & 2 instructions
1464 //===----------------------------------------------------------------------===//
1466 // Aliases of packed SSE1 & SSE2 instructions for scalar use. These all have
1467 // names that start with 'Fs'.
1469 // Alias instructions that map fld0 to pxor for sse.
1470 let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1471 canFoldAsLoad = 1 in {
1472 // FIXME: Set encoding to pseudo!
1473 def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins), "",
1474 [(set FR32:$dst, fp32imm0)]>,
1475 Requires<[HasSSE1]>, TB, OpSize;
1476 def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins), "",
1477 [(set FR64:$dst, fpimm0)]>,
1478 Requires<[HasSSE2]>, TB, OpSize;
1479 def VFsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins), "",
1480 [(set FR32:$dst, fp32imm0)]>,
1481 Requires<[HasAVX]>, TB, OpSize, VEX_4V;
1482 def VFsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins), "",
1483 [(set FR64:$dst, fpimm0)]>,
1484 Requires<[HasAVX]>, TB, OpSize, VEX_4V;
1487 // Alias instruction to do FR32 or FR64 reg-to-reg copy using movaps. Upper
1488 // bits are disregarded.
1489 let neverHasSideEffects = 1 in {
1490 def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
1491 "movaps\t{$src, $dst|$dst, $src}", []>;
1492 def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1493 "movapd\t{$src, $dst|$dst, $src}", []>;
1496 // Alias instruction to load FR32 or FR64 from f128mem using movaps. Upper
1497 // bits are disregarded.
1498 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1499 def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
1500 "movaps\t{$src, $dst|$dst, $src}",
1501 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
1502 def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
1503 "movapd\t{$src, $dst|$dst, $src}",
1504 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
1507 //===----------------------------------------------------------------------===//
1508 // SSE 1 & 2 - Logical Instructions
1509 //===----------------------------------------------------------------------===//
1511 /// sse12_fp_alias_pack_logical - SSE 1 & 2 aliased packed FP logical ops
1513 multiclass sse12_fp_alias_pack_logical<bits<8> opc, string OpcodeStr,
1515 defm V#NAME#PS : sse12_fp_packed<opc, !strconcat(OpcodeStr, "ps"), OpNode,
1516 FR32, f32, f128mem, memopfsf32, SSEPackedSingle, 0>, VEX_4V;
1518 defm V#NAME#PD : sse12_fp_packed<opc, !strconcat(OpcodeStr, "pd"), OpNode,
1519 FR64, f64, f128mem, memopfsf64, SSEPackedDouble, 0>, OpSize, VEX_4V;
1521 let Constraints = "$src1 = $dst" in {
1522 defm PS : sse12_fp_packed<opc, !strconcat(OpcodeStr, "ps"), OpNode, FR32,
1523 f32, f128mem, memopfsf32, SSEPackedSingle>, TB;
1525 defm PD : sse12_fp_packed<opc, !strconcat(OpcodeStr, "pd"), OpNode, FR64,
1526 f64, f128mem, memopfsf64, SSEPackedDouble>, TB, OpSize;
1530 // Alias bitwise logical operations using SSE logical ops on packed FP values.
1531 let mayLoad = 0 in {
1532 defm FsAND : sse12_fp_alias_pack_logical<0x54, "and", X86fand>;
1533 defm FsOR : sse12_fp_alias_pack_logical<0x56, "or", X86for>;
1534 defm FsXOR : sse12_fp_alias_pack_logical<0x57, "xor", X86fxor>;
1537 let neverHasSideEffects = 1, Pattern = []<dag>, isCommutable = 0 in
1538 defm FsANDN : sse12_fp_alias_pack_logical<0x55, "andn", undef>;
1540 /// sse12_fp_packed_logical - SSE 1 & 2 packed FP logical ops
1542 multiclass sse12_fp_packed_logical<bits<8> opc, string OpcodeStr,
1544 let Pattern = []<dag> in {
1545 defm V#NAME#PS : sse12_fp_packed_logical_rm<opc, VR128, SSEPackedSingle,
1546 !strconcat(OpcodeStr, "ps"), f128mem,
1547 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))],
1548 [(set VR128:$dst, (OpNode (bc_v2i64 (v4f32 VR128:$src1)),
1549 (memopv2i64 addr:$src2)))], 0>, VEX_4V;
1551 defm V#NAME#PD : sse12_fp_packed_logical_rm<opc, VR128, SSEPackedDouble,
1552 !strconcat(OpcodeStr, "pd"), f128mem,
1553 [(set VR128:$dst, (OpNode (bc_v2i64 (v2f64 VR128:$src1)),
1554 (bc_v2i64 (v2f64 VR128:$src2))))],
1555 [(set VR128:$dst, (OpNode (bc_v2i64 (v2f64 VR128:$src1)),
1556 (memopv2i64 addr:$src2)))], 0>,
1559 let Constraints = "$src1 = $dst" in {
1560 defm PS : sse12_fp_packed_logical_rm<opc, VR128, SSEPackedSingle,
1561 !strconcat(OpcodeStr, "ps"), f128mem,
1562 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))],
1563 [(set VR128:$dst, (OpNode (bc_v2i64 (v4f32 VR128:$src1)),
1564 (memopv2i64 addr:$src2)))]>, TB;
1566 defm PD : sse12_fp_packed_logical_rm<opc, VR128, SSEPackedDouble,
1567 !strconcat(OpcodeStr, "pd"), f128mem,
1568 [(set VR128:$dst, (OpNode (bc_v2i64 (v2f64 VR128:$src1)),
1569 (bc_v2i64 (v2f64 VR128:$src2))))],
1570 [(set VR128:$dst, (OpNode (bc_v2i64 (v2f64 VR128:$src1)),
1571 (memopv2i64 addr:$src2)))]>, TB, OpSize;
1575 /// sse12_fp_packed_logical_y - AVX 256-bit SSE 1 & 2 logical ops forms
1577 multiclass sse12_fp_packed_logical_y<bits<8> opc, string OpcodeStr,
1579 defm PSY : sse12_fp_packed_logical_rm<opc, VR256, SSEPackedSingle,
1580 !strconcat(OpcodeStr, "ps"), f256mem,
1581 [(set VR256:$dst, (v4i64 (OpNode VR256:$src1, VR256:$src2)))],
1582 [(set VR256:$dst, (OpNode (bc_v4i64 (v8f32 VR256:$src1)),
1583 (memopv4i64 addr:$src2)))], 0>, VEX_4V;
1585 defm PDY : sse12_fp_packed_logical_rm<opc, VR256, SSEPackedDouble,
1586 !strconcat(OpcodeStr, "pd"), f256mem,
1587 [(set VR256:$dst, (OpNode (bc_v4i64 (v4f64 VR256:$src1)),
1588 (bc_v4i64 (v4f64 VR256:$src2))))],
1589 [(set VR256:$dst, (OpNode (bc_v4i64 (v4f64 VR256:$src1)),
1590 (memopv4i64 addr:$src2)))], 0>,
1594 // AVX 256-bit packed logical ops forms
1595 defm VAND : sse12_fp_packed_logical_y<0x54, "and", and>;
1596 defm VOR : sse12_fp_packed_logical_y<0x56, "or", or>;
1597 defm VXOR : sse12_fp_packed_logical_y<0x57, "xor", xor>;
1598 defm VANDN : sse12_fp_packed_logical_y<0x55, "andn", X86andnp>;
1600 defm AND : sse12_fp_packed_logical<0x54, "and", and>;
1601 defm OR : sse12_fp_packed_logical<0x56, "or", or>;
1602 defm XOR : sse12_fp_packed_logical<0x57, "xor", xor>;
1603 let isCommutable = 0 in
1604 defm ANDN : sse12_fp_packed_logical<0x55, "andn", X86andnp>;
1606 //===----------------------------------------------------------------------===//
1607 // SSE 1 & 2 - Arithmetic Instructions
1608 //===----------------------------------------------------------------------===//
1610 /// basic_sse12_fp_binop_xxx - SSE 1 & 2 binops come in both scalar and
1613 /// In addition, we also have a special variant of the scalar form here to
1614 /// represent the associated intrinsic operation. This form is unlike the
1615 /// plain scalar form, in that it takes an entire vector (instead of a scalar)
1616 /// and leaves the top elements unmodified (therefore these cannot be commuted).
1618 /// These three forms can each be reg+reg or reg+mem.
1621 /// FIXME: once all 256-bit intrinsics are matched, cleanup and refactor those
1623 multiclass basic_sse12_fp_binop_s<bits<8> opc, string OpcodeStr, SDNode OpNode,
1625 defm SS : sse12_fp_scalar<opc, !strconcat(OpcodeStr, "ss"),
1626 OpNode, FR32, f32mem, Is2Addr>, XS;
1627 defm SD : sse12_fp_scalar<opc, !strconcat(OpcodeStr, "sd"),
1628 OpNode, FR64, f64mem, Is2Addr>, XD;
1631 multiclass basic_sse12_fp_binop_p<bits<8> opc, string OpcodeStr, SDNode OpNode,
1633 let mayLoad = 0 in {
1634 defm PS : sse12_fp_packed<opc, !strconcat(OpcodeStr, "ps"), OpNode, VR128,
1635 v4f32, f128mem, memopv4f32, SSEPackedSingle, Is2Addr>, TB;
1636 defm PD : sse12_fp_packed<opc, !strconcat(OpcodeStr, "pd"), OpNode, VR128,
1637 v2f64, f128mem, memopv2f64, SSEPackedDouble, Is2Addr>, TB, OpSize;
1641 multiclass basic_sse12_fp_binop_p_y<bits<8> opc, string OpcodeStr,
1643 let mayLoad = 0 in {
1644 defm PSY : sse12_fp_packed<opc, !strconcat(OpcodeStr, "ps"), OpNode, VR256,
1645 v8f32, f256mem, memopv8f32, SSEPackedSingle, 0>, TB;
1646 defm PDY : sse12_fp_packed<opc, !strconcat(OpcodeStr, "pd"), OpNode, VR256,
1647 v4f64, f256mem, memopv4f64, SSEPackedDouble, 0>, TB, OpSize;
1651 multiclass basic_sse12_fp_binop_s_int<bits<8> opc, string OpcodeStr,
1653 defm SS : sse12_fp_scalar_int<opc, OpcodeStr, VR128,
1654 !strconcat(OpcodeStr, "ss"), "", "_ss", ssmem, sse_load_f32, Is2Addr>, XS;
1655 defm SD : sse12_fp_scalar_int<opc, OpcodeStr, VR128,
1656 !strconcat(OpcodeStr, "sd"), "2", "_sd", sdmem, sse_load_f64, Is2Addr>, XD;
1659 multiclass basic_sse12_fp_binop_p_int<bits<8> opc, string OpcodeStr,
1661 defm PS : sse12_fp_packed_int<opc, OpcodeStr, VR128,
1662 !strconcat(OpcodeStr, "ps"), "sse", "_ps", f128mem, memopv4f32,
1663 SSEPackedSingle, Is2Addr>, TB;
1665 defm PD : sse12_fp_packed_int<opc, OpcodeStr, VR128,
1666 !strconcat(OpcodeStr, "pd"), "sse2", "_pd", f128mem, memopv2f64,
1667 SSEPackedDouble, Is2Addr>, TB, OpSize;
1670 multiclass basic_sse12_fp_binop_p_y_int<bits<8> opc, string OpcodeStr> {
1671 defm PSY : sse12_fp_packed_int<opc, OpcodeStr, VR256,
1672 !strconcat(OpcodeStr, "ps"), "avx", "_ps_256", f256mem, memopv8f32,
1673 SSEPackedSingle, 0>, TB;
1675 defm PDY : sse12_fp_packed_int<opc, OpcodeStr, VR256,
1676 !strconcat(OpcodeStr, "pd"), "avx", "_pd_256", f256mem, memopv4f64,
1677 SSEPackedDouble, 0>, TB, OpSize;
1680 // Binary Arithmetic instructions
1681 defm VADD : basic_sse12_fp_binop_s<0x58, "add", fadd, 0>,
1682 basic_sse12_fp_binop_s_int<0x58, "add", 0>,
1683 basic_sse12_fp_binop_p<0x58, "add", fadd, 0>,
1684 basic_sse12_fp_binop_p_y<0x58, "add", fadd>, VEX_4V;
1685 defm VMUL : basic_sse12_fp_binop_s<0x59, "mul", fmul, 0>,
1686 basic_sse12_fp_binop_s_int<0x59, "mul", 0>,
1687 basic_sse12_fp_binop_p<0x59, "mul", fmul, 0>,
1688 basic_sse12_fp_binop_p_y<0x59, "mul", fmul>, VEX_4V;
1690 let isCommutable = 0 in {
1691 defm VSUB : basic_sse12_fp_binop_s<0x5C, "sub", fsub, 0>,
1692 basic_sse12_fp_binop_s_int<0x5C, "sub", 0>,
1693 basic_sse12_fp_binop_p<0x5C, "sub", fsub, 0>,
1694 basic_sse12_fp_binop_p_y<0x5C, "sub", fsub>, VEX_4V;
1695 defm VDIV : basic_sse12_fp_binop_s<0x5E, "div", fdiv, 0>,
1696 basic_sse12_fp_binop_s_int<0x5E, "div", 0>,
1697 basic_sse12_fp_binop_p<0x5E, "div", fdiv, 0>,
1698 basic_sse12_fp_binop_p_y<0x5E, "div", fdiv>, VEX_4V;
1699 defm VMAX : basic_sse12_fp_binop_s<0x5F, "max", X86fmax, 0>,
1700 basic_sse12_fp_binop_s_int<0x5F, "max", 0>,
1701 basic_sse12_fp_binop_p<0x5F, "max", X86fmax, 0>,
1702 basic_sse12_fp_binop_p_int<0x5F, "max", 0>,
1703 basic_sse12_fp_binop_p_y<0x5F, "max", X86fmax>,
1704 basic_sse12_fp_binop_p_y_int<0x5F, "max">, VEX_4V;
1705 defm VMIN : basic_sse12_fp_binop_s<0x5D, "min", X86fmin, 0>,
1706 basic_sse12_fp_binop_s_int<0x5D, "min", 0>,
1707 basic_sse12_fp_binop_p<0x5D, "min", X86fmin, 0>,
1708 basic_sse12_fp_binop_p_int<0x5D, "min", 0>,
1709 basic_sse12_fp_binop_p_y_int<0x5D, "min">,
1710 basic_sse12_fp_binop_p_y<0x5D, "min", X86fmin>, VEX_4V;
1713 let Constraints = "$src1 = $dst" in {
1714 defm ADD : basic_sse12_fp_binop_s<0x58, "add", fadd>,
1715 basic_sse12_fp_binop_p<0x58, "add", fadd>,
1716 basic_sse12_fp_binop_s_int<0x58, "add">;
1717 defm MUL : basic_sse12_fp_binop_s<0x59, "mul", fmul>,
1718 basic_sse12_fp_binop_p<0x59, "mul", fmul>,
1719 basic_sse12_fp_binop_s_int<0x59, "mul">;
1721 let isCommutable = 0 in {
1722 defm SUB : basic_sse12_fp_binop_s<0x5C, "sub", fsub>,
1723 basic_sse12_fp_binop_p<0x5C, "sub", fsub>,
1724 basic_sse12_fp_binop_s_int<0x5C, "sub">;
1725 defm DIV : basic_sse12_fp_binop_s<0x5E, "div", fdiv>,
1726 basic_sse12_fp_binop_p<0x5E, "div", fdiv>,
1727 basic_sse12_fp_binop_s_int<0x5E, "div">;
1728 defm MAX : basic_sse12_fp_binop_s<0x5F, "max", X86fmax>,
1729 basic_sse12_fp_binop_p<0x5F, "max", X86fmax>,
1730 basic_sse12_fp_binop_s_int<0x5F, "max">,
1731 basic_sse12_fp_binop_p_int<0x5F, "max">;
1732 defm MIN : basic_sse12_fp_binop_s<0x5D, "min", X86fmin>,
1733 basic_sse12_fp_binop_p<0x5D, "min", X86fmin>,
1734 basic_sse12_fp_binop_s_int<0x5D, "min">,
1735 basic_sse12_fp_binop_p_int<0x5D, "min">;
1740 /// In addition, we also have a special variant of the scalar form here to
1741 /// represent the associated intrinsic operation. This form is unlike the
1742 /// plain scalar form, in that it takes an entire vector (instead of a
1743 /// scalar) and leaves the top elements undefined.
1745 /// And, we have a special variant form for a full-vector intrinsic form.
1747 /// sse1_fp_unop_s - SSE1 unops in scalar form.
1748 multiclass sse1_fp_unop_s<bits<8> opc, string OpcodeStr,
1749 SDNode OpNode, Intrinsic F32Int> {
1750 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
1751 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
1752 [(set FR32:$dst, (OpNode FR32:$src))]>;
1753 // For scalar unary operations, fold a load into the operation
1754 // only in OptForSize mode. It eliminates an instruction, but it also
1755 // eliminates a whole-register clobber (the load), so it introduces a
1756 // partial register update condition.
1757 def SSm : I<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
1758 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
1759 [(set FR32:$dst, (OpNode (load addr:$src)))]>, XS,
1760 Requires<[HasSSE1, OptForSize]>;
1761 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1762 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
1763 [(set VR128:$dst, (F32Int VR128:$src))]>;
1764 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
1765 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
1766 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
1769 /// sse1_fp_unop_s_avx - AVX SSE1 unops in scalar form.
1770 multiclass sse1_fp_unop_s_avx<bits<8> opc, string OpcodeStr,
1771 SDNode OpNode, Intrinsic F32Int> {
1772 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
1773 !strconcat(OpcodeStr,
1774 "ss\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>;
1775 def SSm : I<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
1776 !strconcat(OpcodeStr,
1777 "ss\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
1778 []>, XS, Requires<[HasAVX, OptForSize]>;
1779 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1780 !strconcat(OpcodeStr,
1781 "ss\t{$src, $dst, $dst|$dst, $dst, $src}"),
1782 [(set VR128:$dst, (F32Int VR128:$src))]>;
1783 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
1784 !strconcat(OpcodeStr,
1785 "ss\t{$src, $dst, $dst|$dst, $dst, $src}"),
1786 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
1789 /// sse1_fp_unop_p - SSE1 unops in packed form.
1790 multiclass sse1_fp_unop_p<bits<8> opc, string OpcodeStr, SDNode OpNode> {
1791 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1792 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1793 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]>;
1794 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1795 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1796 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
1799 /// sse1_fp_unop_p_y - AVX 256-bit SSE1 unops in packed form.
1800 multiclass sse1_fp_unop_p_y<bits<8> opc, string OpcodeStr, SDNode OpNode> {
1801 def PSYr : PSI<opc, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src),
1802 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1803 [(set VR256:$dst, (v8f32 (OpNode VR256:$src)))]>;
1804 def PSYm : PSI<opc, MRMSrcMem, (outs VR256:$dst), (ins f256mem:$src),
1805 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1806 [(set VR256:$dst, (OpNode (memopv8f32 addr:$src)))]>;
1809 /// sse1_fp_unop_p_int - SSE1 intrinsics unops in packed forms.
1810 multiclass sse1_fp_unop_p_int<bits<8> opc, string OpcodeStr,
1811 Intrinsic V4F32Int> {
1812 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1813 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1814 [(set VR128:$dst, (V4F32Int VR128:$src))]>;
1815 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1816 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1817 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
1820 /// sse1_fp_unop_p_y_int - AVX 256-bit intrinsics unops in packed forms.
1821 multiclass sse1_fp_unop_p_y_int<bits<8> opc, string OpcodeStr,
1822 Intrinsic V4F32Int> {
1823 def PSYr_Int : PSI<opc, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src),
1824 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1825 [(set VR256:$dst, (V4F32Int VR256:$src))]>;
1826 def PSYm_Int : PSI<opc, MRMSrcMem, (outs VR256:$dst), (ins f256mem:$src),
1827 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
1828 [(set VR256:$dst, (V4F32Int (memopv8f32 addr:$src)))]>;
1831 /// sse2_fp_unop_s - SSE2 unops in scalar form.
1832 multiclass sse2_fp_unop_s<bits<8> opc, string OpcodeStr,
1833 SDNode OpNode, Intrinsic F64Int> {
1834 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
1835 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1836 [(set FR64:$dst, (OpNode FR64:$src))]>;
1837 // See the comments in sse1_fp_unop_s for why this is OptForSize.
1838 def SDm : I<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
1839 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1840 [(set FR64:$dst, (OpNode (load addr:$src)))]>, XD,
1841 Requires<[HasSSE2, OptForSize]>;
1842 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1843 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1844 [(set VR128:$dst, (F64Int VR128:$src))]>;
1845 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
1846 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
1847 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1850 /// sse2_fp_unop_s_avx - AVX SSE2 unops in scalar form.
1851 multiclass sse2_fp_unop_s_avx<bits<8> opc, string OpcodeStr,
1852 SDNode OpNode, Intrinsic F64Int> {
1853 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
1854 !strconcat(OpcodeStr,
1855 "sd\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>;
1856 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1857 (ins FR64:$src1, f64mem:$src2),
1858 !strconcat(OpcodeStr,
1859 "sd\t{$src2, $src1, $dst|$dst, $src1, $src2}"), []>;
1860 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1861 !strconcat(OpcodeStr, "sd\t{$src, $dst, $dst|$dst, $dst, $src}"),
1862 [(set VR128:$dst, (F64Int VR128:$src))]>;
1863 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
1864 !strconcat(OpcodeStr, "sd\t{$src, $dst, $dst|$dst, $dst, $src}"),
1865 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1868 /// sse2_fp_unop_p - SSE2 unops in vector forms.
1869 multiclass sse2_fp_unop_p<bits<8> opc, string OpcodeStr,
1871 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1872 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1873 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]>;
1874 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1875 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1876 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
1879 /// sse2_fp_unop_p_y - AVX SSE2 256-bit unops in vector forms.
1880 multiclass sse2_fp_unop_p_y<bits<8> opc, string OpcodeStr, SDNode OpNode> {
1881 def PDYr : PDI<opc, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src),
1882 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1883 [(set VR256:$dst, (v4f64 (OpNode VR256:$src)))]>;
1884 def PDYm : PDI<opc, MRMSrcMem, (outs VR256:$dst), (ins f256mem:$src),
1885 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1886 [(set VR256:$dst, (OpNode (memopv4f64 addr:$src)))]>;
1889 /// sse2_fp_unop_p_int - SSE2 intrinsic unops in vector forms.
1890 multiclass sse2_fp_unop_p_int<bits<8> opc, string OpcodeStr,
1891 Intrinsic V2F64Int> {
1892 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1893 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1894 [(set VR128:$dst, (V2F64Int VR128:$src))]>;
1895 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1896 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1897 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
1900 /// sse2_fp_unop_p_y_int - AVX 256-bit intrinsic unops in vector forms.
1901 multiclass sse2_fp_unop_p_y_int<bits<8> opc, string OpcodeStr,
1902 Intrinsic V2F64Int> {
1903 def PDYr_Int : PDI<opc, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src),
1904 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1905 [(set VR256:$dst, (V2F64Int VR256:$src))]>;
1906 def PDYm_Int : PDI<opc, MRMSrcMem, (outs VR256:$dst), (ins f256mem:$src),
1907 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
1908 [(set VR256:$dst, (V2F64Int (memopv4f64 addr:$src)))]>;
1911 let Predicates = [HasAVX] in {
1913 defm VSQRT : sse1_fp_unop_s_avx<0x51, "vsqrt", fsqrt, int_x86_sse_sqrt_ss>,
1914 sse2_fp_unop_s_avx<0x51, "vsqrt", fsqrt, int_x86_sse2_sqrt_sd>,
1917 defm VSQRT : sse1_fp_unop_p<0x51, "vsqrt", fsqrt>,
1918 sse2_fp_unop_p<0x51, "vsqrt", fsqrt>,
1919 sse1_fp_unop_p_y<0x51, "vsqrt", fsqrt>,
1920 sse2_fp_unop_p_y<0x51, "vsqrt", fsqrt>,
1921 sse1_fp_unop_p_int<0x51, "vsqrt", int_x86_sse_sqrt_ps>,
1922 sse2_fp_unop_p_int<0x51, "vsqrt", int_x86_sse2_sqrt_pd>,
1923 sse1_fp_unop_p_y_int<0x51, "vsqrt", int_x86_avx_sqrt_ps_256>,
1924 sse2_fp_unop_p_y_int<0x51, "vsqrt", int_x86_avx_sqrt_pd_256>,
1927 // Reciprocal approximations. Note that these typically require refinement
1928 // in order to obtain suitable precision.
1929 defm VRSQRT : sse1_fp_unop_s_avx<0x52, "vrsqrt", X86frsqrt,
1930 int_x86_sse_rsqrt_ss>, VEX_4V;
1931 defm VRSQRT : sse1_fp_unop_p<0x52, "vrsqrt", X86frsqrt>,
1932 sse1_fp_unop_p_y<0x52, "vrsqrt", X86frsqrt>,
1933 sse1_fp_unop_p_y_int<0x52, "vrsqrt", int_x86_avx_rsqrt_ps_256>,
1934 sse1_fp_unop_p_int<0x52, "vrsqrt", int_x86_sse_rsqrt_ps>, VEX;
1936 defm VRCP : sse1_fp_unop_s_avx<0x53, "vrcp", X86frcp, int_x86_sse_rcp_ss>,
1938 defm VRCP : sse1_fp_unop_p<0x53, "vrcp", X86frcp>,
1939 sse1_fp_unop_p_y<0x53, "vrcp", X86frcp>,
1940 sse1_fp_unop_p_y_int<0x53, "vrcp", int_x86_avx_rcp_ps_256>,
1941 sse1_fp_unop_p_int<0x53, "vrcp", int_x86_sse_rcp_ps>, VEX;
1944 def : Pat<(f32 (fsqrt FR32:$src)),
1945 (VSQRTSSr (f32 (IMPLICIT_DEF)), FR32:$src)>, Requires<[HasAVX]>;
1946 def : Pat<(f64 (fsqrt FR64:$src)),
1947 (VSQRTSDr (f64 (IMPLICIT_DEF)), FR64:$src)>, Requires<[HasAVX]>;
1948 def : Pat<(f64 (fsqrt (load addr:$src))),
1949 (VSQRTSDm (f64 (IMPLICIT_DEF)), addr:$src)>,
1950 Requires<[HasAVX, OptForSize]>;
1951 def : Pat<(f32 (fsqrt (load addr:$src))),
1952 (VSQRTSSm (f32 (IMPLICIT_DEF)), addr:$src)>,
1953 Requires<[HasAVX, OptForSize]>;
1956 defm SQRT : sse1_fp_unop_s<0x51, "sqrt", fsqrt, int_x86_sse_sqrt_ss>,
1957 sse1_fp_unop_p<0x51, "sqrt", fsqrt>,
1958 sse1_fp_unop_p_int<0x51, "sqrt", int_x86_sse_sqrt_ps>,
1959 sse2_fp_unop_s<0x51, "sqrt", fsqrt, int_x86_sse2_sqrt_sd>,
1960 sse2_fp_unop_p<0x51, "sqrt", fsqrt>,
1961 sse2_fp_unop_p_int<0x51, "sqrt", int_x86_sse2_sqrt_pd>;
1963 // Reciprocal approximations. Note that these typically require refinement
1964 // in order to obtain suitable precision.
1965 defm RSQRT : sse1_fp_unop_s<0x52, "rsqrt", X86frsqrt, int_x86_sse_rsqrt_ss>,
1966 sse1_fp_unop_p<0x52, "rsqrt", X86frsqrt>,
1967 sse1_fp_unop_p_int<0x52, "rsqrt", int_x86_sse_rsqrt_ps>;
1968 defm RCP : sse1_fp_unop_s<0x53, "rcp", X86frcp, int_x86_sse_rcp_ss>,
1969 sse1_fp_unop_p<0x53, "rcp", X86frcp>,
1970 sse1_fp_unop_p_int<0x53, "rcp", int_x86_sse_rcp_ps>;
1972 // There is no f64 version of the reciprocal approximation instructions.
1974 //===----------------------------------------------------------------------===//
1975 // SSE 1 & 2 - Non-temporal stores
1976 //===----------------------------------------------------------------------===//
1978 let AddedComplexity = 400 in { // Prefer non-temporal versions
1979 def VMOVNTPSmr : VPSI<0x2B, MRMDestMem, (outs),
1980 (ins f128mem:$dst, VR128:$src),
1981 "movntps\t{$src, $dst|$dst, $src}",
1982 [(alignednontemporalstore (v4f32 VR128:$src),
1984 def VMOVNTPDmr : VPDI<0x2B, MRMDestMem, (outs),
1985 (ins f128mem:$dst, VR128:$src),
1986 "movntpd\t{$src, $dst|$dst, $src}",
1987 [(alignednontemporalstore (v2f64 VR128:$src),
1989 def VMOVNTDQ_64mr : VPDI<0xE7, MRMDestMem, (outs),
1990 (ins f128mem:$dst, VR128:$src),
1991 "movntdq\t{$src, $dst|$dst, $src}",
1992 [(alignednontemporalstore (v2f64 VR128:$src),
1995 let ExeDomain = SSEPackedInt in
1996 def VMOVNTDQmr : VPDI<0xE7, MRMDestMem, (outs),
1997 (ins f128mem:$dst, VR128:$src),
1998 "movntdq\t{$src, $dst|$dst, $src}",
1999 [(alignednontemporalstore (v4f32 VR128:$src),
2002 def : Pat<(alignednontemporalstore (v2i64 VR128:$src), addr:$dst),
2003 (VMOVNTDQmr addr:$dst, VR128:$src)>, Requires<[HasAVX]>;
2005 def VMOVNTPSYmr : VPSI<0x2B, MRMDestMem, (outs),
2006 (ins f256mem:$dst, VR256:$src),
2007 "movntps\t{$src, $dst|$dst, $src}",
2008 [(alignednontemporalstore (v8f32 VR256:$src),
2010 def VMOVNTPDYmr : VPDI<0x2B, MRMDestMem, (outs),
2011 (ins f256mem:$dst, VR256:$src),
2012 "movntpd\t{$src, $dst|$dst, $src}",
2013 [(alignednontemporalstore (v4f64 VR256:$src),
2015 def VMOVNTDQY_64mr : VPDI<0xE7, MRMDestMem, (outs),
2016 (ins f256mem:$dst, VR256:$src),
2017 "movntdq\t{$src, $dst|$dst, $src}",
2018 [(alignednontemporalstore (v4f64 VR256:$src),
2020 let ExeDomain = SSEPackedInt in
2021 def VMOVNTDQYmr : VPDI<0xE7, MRMDestMem, (outs),
2022 (ins f256mem:$dst, VR256:$src),
2023 "movntdq\t{$src, $dst|$dst, $src}",
2024 [(alignednontemporalstore (v8f32 VR256:$src),
2028 def : Pat<(int_x86_avx_movnt_dq_256 addr:$dst, VR256:$src),
2029 (VMOVNTDQYmr addr:$dst, VR256:$src)>;
2030 def : Pat<(int_x86_avx_movnt_pd_256 addr:$dst, VR256:$src),
2031 (VMOVNTPDYmr addr:$dst, VR256:$src)>;
2032 def : Pat<(int_x86_avx_movnt_ps_256 addr:$dst, VR256:$src),
2033 (VMOVNTPSYmr addr:$dst, VR256:$src)>;
2035 let AddedComplexity = 400 in { // Prefer non-temporal versions
2036 def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2037 "movntps\t{$src, $dst|$dst, $src}",
2038 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
2039 def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2040 "movntpd\t{$src, $dst|$dst, $src}",
2041 [(alignednontemporalstore(v2f64 VR128:$src), addr:$dst)]>;
2043 def MOVNTDQ_64mr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2044 "movntdq\t{$src, $dst|$dst, $src}",
2045 [(alignednontemporalstore (v2f64 VR128:$src), addr:$dst)]>;
2047 let ExeDomain = SSEPackedInt in
2048 def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
2049 "movntdq\t{$src, $dst|$dst, $src}",
2050 [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>;
2052 def : Pat<(alignednontemporalstore (v2i64 VR128:$src), addr:$dst),
2053 (MOVNTDQmr addr:$dst, VR128:$src)>;
2055 // There is no AVX form for instructions below this point
2056 def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
2057 "movnti{l}\t{$src, $dst|$dst, $src}",
2058 [(nontemporalstore (i32 GR32:$src), addr:$dst)]>,
2059 TB, Requires<[HasSSE2]>;
2060 def MOVNTI_64mr : RI<0xC3, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
2061 "movnti{q}\t{$src, $dst|$dst, $src}",
2062 [(nontemporalstore (i64 GR64:$src), addr:$dst)]>,
2063 TB, Requires<[HasSSE2]>;
2066 //===----------------------------------------------------------------------===//
2067 // SSE 1 & 2 - Misc Instructions (No AVX form)
2068 //===----------------------------------------------------------------------===//
2070 // Prefetch intrinsic.
2071 def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
2072 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3), (i32 1))]>;
2073 def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
2074 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2), (i32 1))]>;
2075 def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
2076 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1), (i32 1))]>;
2077 def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
2078 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0), (i32 1))]>;
2080 // Load, store, and memory fence
2081 def SFENCE : I<0xAE, MRM_F8, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>,
2082 TB, Requires<[HasSSE1]>;
2083 def : Pat<(X86SFence), (SFENCE)>;
2085 // Alias instructions that map zero vector to pxor / xorp* for sse.
2086 // We set canFoldAsLoad because this can be converted to a constant-pool
2087 // load of an all-zeros value if folding it would be beneficial.
2088 // FIXME: Change encoding to pseudo! This is blocked right now by the x86
2089 // JIT implementation, it does not expand the instructions below like
2090 // X86MCInstLower does.
2091 let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2092 isCodeGenOnly = 1 in {
2093 def V_SET0PS : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "",
2094 [(set VR128:$dst, (v4f32 immAllZerosV))]>;
2095 def V_SET0PD : PDI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "",
2096 [(set VR128:$dst, (v2f64 immAllZerosV))]>;
2097 let ExeDomain = SSEPackedInt in
2098 def V_SET0PI : PDI<0xEF, MRMInitReg, (outs VR128:$dst), (ins), "",
2099 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
2102 // The same as done above but for AVX. The 128-bit versions are the
2103 // same, but re-encoded. The 256-bit does not support PI version, and
2104 // doesn't need it because on sandy bridge the register is set to zero
2105 // at the rename stage without using any execution unit, so SET0PSY
2106 // and SET0PDY can be used for vector int instructions without penalty
2107 // FIXME: Change encoding to pseudo! This is blocked right now by the x86
2108 // JIT implementatioan, it does not expand the instructions below like
2109 // X86MCInstLower does.
2110 let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2111 isCodeGenOnly = 1, Predicates = [HasAVX] in {
2112 def AVX_SET0PS : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "",
2113 [(set VR128:$dst, (v4f32 immAllZerosV))]>, VEX_4V;
2114 def AVX_SET0PD : PDI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "",
2115 [(set VR128:$dst, (v2f64 immAllZerosV))]>, VEX_4V;
2116 def AVX_SET0PSY : PSI<0x57, MRMInitReg, (outs VR256:$dst), (ins), "",
2117 [(set VR256:$dst, (v8f32 immAllZerosV))]>, VEX_4V;
2118 def AVX_SET0PDY : PDI<0x57, MRMInitReg, (outs VR256:$dst), (ins), "",
2119 [(set VR256:$dst, (v4f64 immAllZerosV))]>, VEX_4V;
2120 let ExeDomain = SSEPackedInt in
2121 def AVX_SET0PI : PDI<0xEF, MRMInitReg, (outs VR128:$dst), (ins), "",
2122 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
2125 def : Pat<(v2i64 immAllZerosV), (V_SET0PI)>;
2126 def : Pat<(v8i16 immAllZerosV), (V_SET0PI)>;
2127 def : Pat<(v16i8 immAllZerosV), (V_SET0PI)>;
2129 def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2130 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), sub_ss))>;
2132 // AVX has no support for 256-bit integer instructions, but since the 128-bit
2133 // VPXOR instruction writes zero to its upper part, it's safe build zeros.
2134 def : Pat<(v8i32 immAllZerosV), (SUBREG_TO_REG (i32 0), (AVX_SET0PI), sub_xmm)>;
2135 def : Pat<(bc_v8i32 (v8f32 immAllZerosV)),
2136 (SUBREG_TO_REG (i32 0), (AVX_SET0PI), sub_xmm)>;
2138 def : Pat<(v4i64 immAllZerosV), (SUBREG_TO_REG (i64 0), (AVX_SET0PI), sub_xmm)>;
2139 def : Pat<(bc_v4i64 (v8f32 immAllZerosV)),
2140 (SUBREG_TO_REG (i64 0), (AVX_SET0PI), sub_xmm)>;
2142 //===----------------------------------------------------------------------===//
2143 // SSE 1 & 2 - Load/Store XCSR register
2144 //===----------------------------------------------------------------------===//
2146 def VLDMXCSR : VPSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
2147 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>, VEX;
2148 def VSTMXCSR : VPSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
2149 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>, VEX;
2151 def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
2152 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
2153 def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
2154 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
2156 //===---------------------------------------------------------------------===//
2157 // SSE2 - Move Aligned/Unaligned Packed Integer Instructions
2158 //===---------------------------------------------------------------------===//
2160 let ExeDomain = SSEPackedInt in { // SSE integer instructions
2162 let neverHasSideEffects = 1 in {
2163 def VMOVDQArr : VPDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2164 "movdqa\t{$src, $dst|$dst, $src}", []>, VEX;
2165 def VMOVDQAYrr : VPDI<0x6F, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src),
2166 "movdqa\t{$src, $dst|$dst, $src}", []>, VEX;
2168 def VMOVDQUrr : VPDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2169 "movdqu\t{$src, $dst|$dst, $src}", []>, XS, VEX;
2170 def VMOVDQUYrr : VPDI<0x6F, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src),
2171 "movdqu\t{$src, $dst|$dst, $src}", []>, XS, VEX;
2173 let canFoldAsLoad = 1, mayLoad = 1 in {
2174 def VMOVDQArm : VPDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2175 "movdqa\t{$src, $dst|$dst, $src}", []>, VEX;
2176 def VMOVDQAYrm : VPDI<0x6F, MRMSrcMem, (outs VR256:$dst), (ins i256mem:$src),
2177 "movdqa\t{$src, $dst|$dst, $src}", []>, VEX;
2178 let Predicates = [HasAVX] in {
2179 def VMOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2180 "vmovdqu\t{$src, $dst|$dst, $src}",[]>, XS, VEX;
2181 def VMOVDQUYrm : I<0x6F, MRMSrcMem, (outs VR256:$dst), (ins i256mem:$src),
2182 "vmovdqu\t{$src, $dst|$dst, $src}",[]>, XS, VEX;
2186 let mayStore = 1 in {
2187 def VMOVDQAmr : VPDI<0x7F, MRMDestMem, (outs),
2188 (ins i128mem:$dst, VR128:$src),
2189 "movdqa\t{$src, $dst|$dst, $src}", []>, VEX;
2190 def VMOVDQAYmr : VPDI<0x7F, MRMDestMem, (outs),
2191 (ins i256mem:$dst, VR256:$src),
2192 "movdqa\t{$src, $dst|$dst, $src}", []>, VEX;
2193 let Predicates = [HasAVX] in {
2194 def VMOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2195 "vmovdqu\t{$src, $dst|$dst, $src}",[]>, XS, VEX;
2196 def VMOVDQUYmr : I<0x7F, MRMDestMem, (outs), (ins i256mem:$dst, VR256:$src),
2197 "vmovdqu\t{$src, $dst|$dst, $src}",[]>, XS, VEX;
2201 let neverHasSideEffects = 1 in
2202 def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2203 "movdqa\t{$src, $dst|$dst, $src}", []>;
2205 def MOVDQUrr : I<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2206 "movdqu\t{$src, $dst|$dst, $src}",
2207 []>, XS, Requires<[HasSSE2]>;
2209 let canFoldAsLoad = 1, mayLoad = 1 in {
2210 def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2211 "movdqa\t{$src, $dst|$dst, $src}",
2212 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
2213 def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2214 "movdqu\t{$src, $dst|$dst, $src}",
2215 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
2216 XS, Requires<[HasSSE2]>;
2219 let mayStore = 1 in {
2220 def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2221 "movdqa\t{$src, $dst|$dst, $src}",
2222 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
2223 def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2224 "movdqu\t{$src, $dst|$dst, $src}",
2225 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
2226 XS, Requires<[HasSSE2]>;
2229 // Intrinsic forms of MOVDQU load and store
2230 def VMOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2231 "vmovdqu\t{$src, $dst|$dst, $src}",
2232 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
2233 XS, VEX, Requires<[HasAVX]>;
2235 def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
2236 "movdqu\t{$src, $dst|$dst, $src}",
2237 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
2238 XS, Requires<[HasSSE2]>;
2240 } // ExeDomain = SSEPackedInt
2242 def : Pat<(int_x86_avx_loadu_dq_256 addr:$src), (VMOVDQUYrm addr:$src)>;
2243 def : Pat<(int_x86_avx_storeu_dq_256 addr:$dst, VR256:$src),
2244 (VMOVDQUYmr addr:$dst, VR256:$src)>;
2246 //===---------------------------------------------------------------------===//
2247 // SSE2 - Packed Integer Arithmetic Instructions
2248 //===---------------------------------------------------------------------===//
2250 let ExeDomain = SSEPackedInt in { // SSE integer instructions
2252 multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
2253 bit IsCommutable = 0, bit Is2Addr = 1> {
2254 let isCommutable = IsCommutable in
2255 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
2256 (ins VR128:$src1, VR128:$src2),
2258 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2259 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2260 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
2261 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2262 (ins VR128:$src1, i128mem:$src2),
2264 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2265 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2266 [(set VR128:$dst, (IntId VR128:$src1,
2267 (bitconvert (memopv2i64 addr:$src2))))]>;
2270 multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
2271 string OpcodeStr, Intrinsic IntId,
2272 Intrinsic IntId2, bit Is2Addr = 1> {
2273 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
2274 (ins VR128:$src1, VR128:$src2),
2276 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2277 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2278 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
2279 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2280 (ins VR128:$src1, i128mem:$src2),
2282 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2283 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2284 [(set VR128:$dst, (IntId VR128:$src1,
2285 (bitconvert (memopv2i64 addr:$src2))))]>;
2286 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst),
2287 (ins VR128:$src1, i32i8imm:$src2),
2289 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2290 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2291 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
2294 /// PDI_binop_rm - Simple SSE2 binary operator.
2295 multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
2296 ValueType OpVT, bit IsCommutable = 0, bit Is2Addr = 1> {
2297 let isCommutable = IsCommutable in
2298 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
2299 (ins VR128:$src1, VR128:$src2),
2301 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2302 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2303 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]>;
2304 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2305 (ins VR128:$src1, i128mem:$src2),
2307 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2308 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2309 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
2310 (bitconvert (memopv2i64 addr:$src2)))))]>;
2313 /// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
2315 /// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
2316 /// to collapse (bitconvert VT to VT) into its operand.
2318 multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
2319 bit IsCommutable = 0, bit Is2Addr = 1> {
2320 let isCommutable = IsCommutable in
2321 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
2322 (ins VR128:$src1, VR128:$src2),
2324 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2325 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2326 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]>;
2327 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
2328 (ins VR128:$src1, i128mem:$src2),
2330 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2331 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2332 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2i64 addr:$src2)))]>;
2335 } // ExeDomain = SSEPackedInt
2337 // 128-bit Integer Arithmetic
2339 let Predicates = [HasAVX] in {
2340 defm VPADDB : PDI_binop_rm<0xFC, "vpaddb", add, v16i8, 1, 0 /*3addr*/>, VEX_4V;
2341 defm VPADDW : PDI_binop_rm<0xFD, "vpaddw", add, v8i16, 1, 0>, VEX_4V;
2342 defm VPADDD : PDI_binop_rm<0xFE, "vpaddd", add, v4i32, 1, 0>, VEX_4V;
2343 defm VPADDQ : PDI_binop_rm_v2i64<0xD4, "vpaddq", add, 1, 0>, VEX_4V;
2344 defm VPMULLW : PDI_binop_rm<0xD5, "vpmullw", mul, v8i16, 1, 0>, VEX_4V;
2345 defm VPSUBB : PDI_binop_rm<0xF8, "vpsubb", sub, v16i8, 0, 0>, VEX_4V;
2346 defm VPSUBW : PDI_binop_rm<0xF9, "vpsubw", sub, v8i16, 0, 0>, VEX_4V;
2347 defm VPSUBD : PDI_binop_rm<0xFA, "vpsubd", sub, v4i32, 0, 0>, VEX_4V;
2348 defm VPSUBQ : PDI_binop_rm_v2i64<0xFB, "vpsubq", sub, 0, 0>, VEX_4V;
2351 defm VPSUBSB : PDI_binop_rm_int<0xE8, "vpsubsb" , int_x86_sse2_psubs_b, 0, 0>,
2353 defm VPSUBSW : PDI_binop_rm_int<0xE9, "vpsubsw" , int_x86_sse2_psubs_w, 0, 0>,
2355 defm VPSUBUSB : PDI_binop_rm_int<0xD8, "vpsubusb", int_x86_sse2_psubus_b, 0, 0>,
2357 defm VPSUBUSW : PDI_binop_rm_int<0xD9, "vpsubusw", int_x86_sse2_psubus_w, 0, 0>,
2359 defm VPADDSB : PDI_binop_rm_int<0xEC, "vpaddsb" , int_x86_sse2_padds_b, 1, 0>,
2361 defm VPADDSW : PDI_binop_rm_int<0xED, "vpaddsw" , int_x86_sse2_padds_w, 1, 0>,
2363 defm VPADDUSB : PDI_binop_rm_int<0xDC, "vpaddusb", int_x86_sse2_paddus_b, 1, 0>,
2365 defm VPADDUSW : PDI_binop_rm_int<0xDD, "vpaddusw", int_x86_sse2_paddus_w, 1, 0>,
2367 defm VPMULHUW : PDI_binop_rm_int<0xE4, "vpmulhuw", int_x86_sse2_pmulhu_w, 1, 0>,
2369 defm VPMULHW : PDI_binop_rm_int<0xE5, "vpmulhw" , int_x86_sse2_pmulh_w, 1, 0>,
2371 defm VPMULUDQ : PDI_binop_rm_int<0xF4, "vpmuludq", int_x86_sse2_pmulu_dq, 1, 0>,
2373 defm VPMADDWD : PDI_binop_rm_int<0xF5, "vpmaddwd", int_x86_sse2_pmadd_wd, 1, 0>,
2375 defm VPAVGB : PDI_binop_rm_int<0xE0, "vpavgb", int_x86_sse2_pavg_b, 1, 0>,
2377 defm VPAVGW : PDI_binop_rm_int<0xE3, "vpavgw", int_x86_sse2_pavg_w, 1, 0>,
2379 defm VPMINUB : PDI_binop_rm_int<0xDA, "vpminub", int_x86_sse2_pminu_b, 1, 0>,
2381 defm VPMINSW : PDI_binop_rm_int<0xEA, "vpminsw", int_x86_sse2_pmins_w, 1, 0>,
2383 defm VPMAXUB : PDI_binop_rm_int<0xDE, "vpmaxub", int_x86_sse2_pmaxu_b, 1, 0>,
2385 defm VPMAXSW : PDI_binop_rm_int<0xEE, "vpmaxsw", int_x86_sse2_pmaxs_w, 1, 0>,
2387 defm VPSADBW : PDI_binop_rm_int<0xF6, "vpsadbw", int_x86_sse2_psad_bw, 1, 0>,
2391 let Constraints = "$src1 = $dst" in {
2392 defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
2393 defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
2394 defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
2395 defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
2396 defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
2397 defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
2398 defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
2399 defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
2400 defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
2403 defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
2404 defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
2405 defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
2406 defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
2407 defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
2408 defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
2409 defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
2410 defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
2411 defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
2412 defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w, 1>;
2413 defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
2414 defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
2415 defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
2416 defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
2417 defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
2418 defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
2419 defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
2420 defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
2421 defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
2423 } // Constraints = "$src1 = $dst"
2425 //===---------------------------------------------------------------------===//
2426 // SSE2 - Packed Integer Logical Instructions
2427 //===---------------------------------------------------------------------===//
2429 let Predicates = [HasAVX] in {
2430 defm VPSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "vpsllw",
2431 int_x86_sse2_psll_w, int_x86_sse2_pslli_w, 0>,
2433 defm VPSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "vpslld",
2434 int_x86_sse2_psll_d, int_x86_sse2_pslli_d, 0>,
2436 defm VPSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "vpsllq",
2437 int_x86_sse2_psll_q, int_x86_sse2_pslli_q, 0>,
2440 defm VPSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "vpsrlw",
2441 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w, 0>,
2443 defm VPSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "vpsrld",
2444 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d, 0>,
2446 defm VPSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "vpsrlq",
2447 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q, 0>,
2450 defm VPSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "vpsraw",
2451 int_x86_sse2_psra_w, int_x86_sse2_psrai_w, 0>,
2453 defm VPSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "vpsrad",
2454 int_x86_sse2_psra_d, int_x86_sse2_psrai_d, 0>,
2457 defm VPAND : PDI_binop_rm_v2i64<0xDB, "vpand", and, 1, 0>, VEX_4V;
2458 defm VPOR : PDI_binop_rm_v2i64<0xEB, "vpor" , or, 1, 0>, VEX_4V;
2459 defm VPXOR : PDI_binop_rm_v2i64<0xEF, "vpxor", xor, 1, 0>, VEX_4V;
2461 let ExeDomain = SSEPackedInt in {
2462 let neverHasSideEffects = 1 in {
2463 // 128-bit logical shifts.
2464 def VPSLLDQri : PDIi8<0x73, MRM7r,
2465 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
2466 "vpslldq\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>,
2468 def VPSRLDQri : PDIi8<0x73, MRM3r,
2469 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
2470 "vpsrldq\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>,
2472 // PSRADQri doesn't exist in SSE[1-3].
2474 def VPANDNrr : PDI<0xDF, MRMSrcReg,
2475 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2476 "vpandn\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2477 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2478 VR128:$src2)))]>, VEX_4V;
2480 def VPANDNrm : PDI<0xDF, MRMSrcMem,
2481 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2482 "vpandn\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2483 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2484 (memopv2i64 addr:$src2))))]>,
2489 let Constraints = "$src1 = $dst" in {
2490 defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
2491 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
2492 defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
2493 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
2494 defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
2495 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
2497 defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
2498 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
2499 defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
2500 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
2501 defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
2502 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
2504 defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
2505 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
2506 defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
2507 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
2509 defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2510 defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or, 1>;
2511 defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2513 let ExeDomain = SSEPackedInt in {
2514 let neverHasSideEffects = 1 in {
2515 // 128-bit logical shifts.
2516 def PSLLDQri : PDIi8<0x73, MRM7r,
2517 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
2518 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
2519 def PSRLDQri : PDIi8<0x73, MRM3r,
2520 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
2521 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
2522 // PSRADQri doesn't exist in SSE[1-3].
2524 def PANDNrr : PDI<0xDF, MRMSrcReg,
2525 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2526 "pandn\t{$src2, $dst|$dst, $src2}", []>;
2528 def PANDNrm : PDI<0xDF, MRMSrcMem,
2529 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2530 "pandn\t{$src2, $dst|$dst, $src2}", []>;
2532 } // Constraints = "$src1 = $dst"
2534 let Predicates = [HasAVX] in {
2535 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
2536 (v2i64 (VPSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
2537 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
2538 (v2i64 (VPSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
2539 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2540 (v2i64 (VPSLLDQri VR128:$src1, imm:$src2))>;
2541 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2542 (v2i64 (VPSRLDQri VR128:$src1, imm:$src2))>;
2543 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
2544 (v2f64 (VPSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
2546 // Shift up / down and insert zero's.
2547 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
2548 (v2i64 (VPSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
2549 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
2550 (v2i64 (VPSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
2553 let Predicates = [HasSSE2] in {
2554 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
2555 (v2i64 (PSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
2556 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
2557 (v2i64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
2558 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2559 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
2560 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2561 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
2562 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
2563 (v2f64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
2565 // Shift up / down and insert zero's.
2566 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
2567 (v2i64 (PSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
2568 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
2569 (v2i64 (PSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
2572 //===---------------------------------------------------------------------===//
2573 // SSE2 - Packed Integer Comparison Instructions
2574 //===---------------------------------------------------------------------===//
2576 let Predicates = [HasAVX] in {
2577 defm VPCMPEQB : PDI_binop_rm_int<0x74, "vpcmpeqb", int_x86_sse2_pcmpeq_b, 1,
2579 defm VPCMPEQW : PDI_binop_rm_int<0x75, "vpcmpeqw", int_x86_sse2_pcmpeq_w, 1,
2581 defm VPCMPEQD : PDI_binop_rm_int<0x76, "vpcmpeqd", int_x86_sse2_pcmpeq_d, 1,
2583 defm VPCMPGTB : PDI_binop_rm_int<0x64, "vpcmpgtb", int_x86_sse2_pcmpgt_b, 0,
2585 defm VPCMPGTW : PDI_binop_rm_int<0x65, "vpcmpgtw", int_x86_sse2_pcmpgt_w, 0,
2587 defm VPCMPGTD : PDI_binop_rm_int<0x66, "vpcmpgtd", int_x86_sse2_pcmpgt_d, 0,
2591 let Constraints = "$src1 = $dst" in {
2592 defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b, 1>;
2593 defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w, 1>;
2594 defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d, 1>;
2595 defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2596 defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2597 defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
2598 } // Constraints = "$src1 = $dst"
2600 def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
2601 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
2602 def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
2603 (PCMPEQBrm VR128:$src1, addr:$src2)>;
2604 def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
2605 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
2606 def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
2607 (PCMPEQWrm VR128:$src1, addr:$src2)>;
2608 def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
2609 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
2610 def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
2611 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2613 def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
2614 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
2615 def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
2616 (PCMPGTBrm VR128:$src1, addr:$src2)>;
2617 def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
2618 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
2619 def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
2620 (PCMPGTWrm VR128:$src1, addr:$src2)>;
2621 def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
2622 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
2623 def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
2624 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2626 //===---------------------------------------------------------------------===//
2627 // SSE2 - Packed Integer Pack Instructions
2628 //===---------------------------------------------------------------------===//
2630 let Predicates = [HasAVX] in {
2631 defm VPACKSSWB : PDI_binop_rm_int<0x63, "vpacksswb", int_x86_sse2_packsswb_128,
2633 defm VPACKSSDW : PDI_binop_rm_int<0x6B, "vpackssdw", int_x86_sse2_packssdw_128,
2635 defm VPACKUSWB : PDI_binop_rm_int<0x67, "vpackuswb", int_x86_sse2_packuswb_128,
2639 let Constraints = "$src1 = $dst" in {
2640 defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2641 defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2642 defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2643 } // Constraints = "$src1 = $dst"
2645 //===---------------------------------------------------------------------===//
2646 // SSE2 - Packed Integer Shuffle Instructions
2647 //===---------------------------------------------------------------------===//
2649 let ExeDomain = SSEPackedInt in {
2650 multiclass sse2_pshuffle<string OpcodeStr, ValueType vt, PatFrag pshuf_frag,
2652 def ri : Ii8<0x70, MRMSrcReg,
2653 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
2654 !strconcat(OpcodeStr,
2655 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
2656 [(set VR128:$dst, (vt (pshuf_frag:$src2 VR128:$src1,
2658 def mi : Ii8<0x70, MRMSrcMem,
2659 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
2660 !strconcat(OpcodeStr,
2661 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
2662 [(set VR128:$dst, (vt (pshuf_frag:$src2
2663 (bc_frag (memopv2i64 addr:$src1)),
2666 } // ExeDomain = SSEPackedInt
2668 let Predicates = [HasAVX] in {
2669 let AddedComplexity = 5 in
2670 defm VPSHUFD : sse2_pshuffle<"vpshufd", v4i32, pshufd, bc_v4i32>, OpSize,
2673 // SSE2 with ImmT == Imm8 and XS prefix.
2674 defm VPSHUFHW : sse2_pshuffle<"vpshufhw", v8i16, pshufhw, bc_v8i16>, XS,
2677 // SSE2 with ImmT == Imm8 and XD prefix.
2678 defm VPSHUFLW : sse2_pshuffle<"vpshuflw", v8i16, pshuflw, bc_v8i16>, XD,
2682 let Predicates = [HasSSE2] in {
2683 let AddedComplexity = 5 in
2684 defm PSHUFD : sse2_pshuffle<"pshufd", v4i32, pshufd, bc_v4i32>, TB, OpSize;
2686 // SSE2 with ImmT == Imm8 and XS prefix.
2687 defm PSHUFHW : sse2_pshuffle<"pshufhw", v8i16, pshufhw, bc_v8i16>, XS;
2689 // SSE2 with ImmT == Imm8 and XD prefix.
2690 defm PSHUFLW : sse2_pshuffle<"pshuflw", v8i16, pshuflw, bc_v8i16>, XD;
2693 //===---------------------------------------------------------------------===//
2694 // SSE2 - Packed Integer Unpack Instructions
2695 //===---------------------------------------------------------------------===//
2697 let ExeDomain = SSEPackedInt in {
2698 multiclass sse2_unpack<bits<8> opc, string OpcodeStr, ValueType vt,
2699 SDNode OpNode, PatFrag bc_frag, bit Is2Addr = 1> {
2700 def rr : PDI<opc, MRMSrcReg,
2701 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2703 !strconcat(OpcodeStr,"\t{$src2, $dst|$dst, $src2}"),
2704 !strconcat(OpcodeStr,"\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2705 [(set VR128:$dst, (vt (OpNode VR128:$src1, VR128:$src2)))]>;
2706 def rm : PDI<opc, MRMSrcMem,
2707 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2709 !strconcat(OpcodeStr,"\t{$src2, $dst|$dst, $src2}"),
2710 !strconcat(OpcodeStr,"\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
2711 [(set VR128:$dst, (OpNode VR128:$src1,
2712 (bc_frag (memopv2i64
2716 let Predicates = [HasAVX] in {
2717 defm VPUNPCKLBW : sse2_unpack<0x60, "vpunpcklbw", v16i8, X86Punpcklbw,
2718 bc_v16i8, 0>, VEX_4V;
2719 defm VPUNPCKLWD : sse2_unpack<0x61, "vpunpcklwd", v8i16, X86Punpcklwd,
2720 bc_v8i16, 0>, VEX_4V;
2721 defm VPUNPCKLDQ : sse2_unpack<0x62, "vpunpckldq", v4i32, X86Punpckldq,
2722 bc_v4i32, 0>, VEX_4V;
2724 /// FIXME: we could eliminate this and use sse2_unpack instead if tblgen
2725 /// knew to collapse (bitconvert VT to VT) into its operand.
2726 def VPUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
2727 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2728 "vpunpcklqdq\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2729 [(set VR128:$dst, (v2i64 (X86Punpcklqdq VR128:$src1,
2730 VR128:$src2)))]>, VEX_4V;
2731 def VPUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
2732 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2733 "vpunpcklqdq\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2734 [(set VR128:$dst, (v2i64 (X86Punpcklqdq VR128:$src1,
2735 (memopv2i64 addr:$src2))))]>, VEX_4V;
2737 defm VPUNPCKHBW : sse2_unpack<0x68, "vpunpckhbw", v16i8, X86Punpckhbw,
2738 bc_v16i8, 0>, VEX_4V;
2739 defm VPUNPCKHWD : sse2_unpack<0x69, "vpunpckhwd", v8i16, X86Punpckhwd,
2740 bc_v8i16, 0>, VEX_4V;
2741 defm VPUNPCKHDQ : sse2_unpack<0x6A, "vpunpckhdq", v4i32, X86Punpckhdq,
2742 bc_v4i32, 0>, VEX_4V;
2744 /// FIXME: we could eliminate this and use sse2_unpack instead if tblgen
2745 /// knew to collapse (bitconvert VT to VT) into its operand.
2746 def VPUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
2747 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2748 "vpunpckhqdq\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2749 [(set VR128:$dst, (v2i64 (X86Punpckhqdq VR128:$src1,
2750 VR128:$src2)))]>, VEX_4V;
2751 def VPUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
2752 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2753 "vpunpckhqdq\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2754 [(set VR128:$dst, (v2i64 (X86Punpckhqdq VR128:$src1,
2755 (memopv2i64 addr:$src2))))]>, VEX_4V;
2758 let Constraints = "$src1 = $dst" in {
2759 defm PUNPCKLBW : sse2_unpack<0x60, "punpcklbw", v16i8, X86Punpcklbw, bc_v16i8>;
2760 defm PUNPCKLWD : sse2_unpack<0x61, "punpcklwd", v8i16, X86Punpcklwd, bc_v8i16>;
2761 defm PUNPCKLDQ : sse2_unpack<0x62, "punpckldq", v4i32, X86Punpckldq, bc_v4i32>;
2763 /// FIXME: we could eliminate this and use sse2_unpack instead if tblgen
2764 /// knew to collapse (bitconvert VT to VT) into its operand.
2765 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
2766 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2767 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
2769 (v2i64 (X86Punpcklqdq VR128:$src1, VR128:$src2)))]>;
2770 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
2771 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2772 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
2774 (v2i64 (X86Punpcklqdq VR128:$src1,
2775 (memopv2i64 addr:$src2))))]>;
2777 defm PUNPCKHBW : sse2_unpack<0x68, "punpckhbw", v16i8, X86Punpckhbw, bc_v16i8>;
2778 defm PUNPCKHWD : sse2_unpack<0x69, "punpckhwd", v8i16, X86Punpckhwd, bc_v8i16>;
2779 defm PUNPCKHDQ : sse2_unpack<0x6A, "punpckhdq", v4i32, X86Punpckhdq, bc_v4i32>;
2781 /// FIXME: we could eliminate this and use sse2_unpack instead if tblgen
2782 /// knew to collapse (bitconvert VT to VT) into its operand.
2783 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
2784 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
2785 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
2787 (v2i64 (X86Punpckhqdq VR128:$src1, VR128:$src2)))]>;
2788 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
2789 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
2790 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
2792 (v2i64 (X86Punpckhqdq VR128:$src1,
2793 (memopv2i64 addr:$src2))))]>;
2796 } // ExeDomain = SSEPackedInt
2798 //===---------------------------------------------------------------------===//
2799 // SSE2 - Packed Integer Extract and Insert
2800 //===---------------------------------------------------------------------===//
2802 let ExeDomain = SSEPackedInt in {
2803 multiclass sse2_pinsrw<bit Is2Addr = 1> {
2804 def rri : Ii8<0xC4, MRMSrcReg,
2805 (outs VR128:$dst), (ins VR128:$src1,
2806 GR32:$src2, i32i8imm:$src3),
2808 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2809 "vpinsrw\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
2811 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
2812 def rmi : Ii8<0xC4, MRMSrcMem,
2813 (outs VR128:$dst), (ins VR128:$src1,
2814 i16mem:$src2, i32i8imm:$src3),
2816 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2817 "vpinsrw\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
2819 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2824 let Predicates = [HasAVX] in
2825 def VPEXTRWri : Ii8<0xC5, MRMSrcReg,
2826 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
2827 "vpextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2828 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
2829 imm:$src2))]>, OpSize, VEX;
2830 def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
2831 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
2832 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2833 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
2837 let Predicates = [HasAVX] in {
2838 defm VPINSRW : sse2_pinsrw<0>, OpSize, VEX_4V;
2839 def VPINSRWrr64i : Ii8<0xC4, MRMSrcReg, (outs VR128:$dst),
2840 (ins VR128:$src1, GR64:$src2, i32i8imm:$src3),
2841 "vpinsrw\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}",
2842 []>, OpSize, VEX_4V;
2845 let Constraints = "$src1 = $dst" in
2846 defm PINSRW : sse2_pinsrw, TB, OpSize, Requires<[HasSSE2]>;
2848 } // ExeDomain = SSEPackedInt
2850 //===---------------------------------------------------------------------===//
2851 // SSE2 - Packed Mask Creation
2852 //===---------------------------------------------------------------------===//
2854 let ExeDomain = SSEPackedInt in {
2856 def VPMOVMSKBrr : VPDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
2857 "pmovmskb\t{$src, $dst|$dst, $src}",
2858 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>, VEX;
2859 def VPMOVMSKBr64r : VPDI<0xD7, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src),
2860 "pmovmskb\t{$src, $dst|$dst, $src}", []>, VEX;
2861 def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
2862 "pmovmskb\t{$src, $dst|$dst, $src}",
2863 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2865 } // ExeDomain = SSEPackedInt
2867 //===---------------------------------------------------------------------===//
2868 // SSE2 - Conditional Store
2869 //===---------------------------------------------------------------------===//
2871 let ExeDomain = SSEPackedInt in {
2874 def VMASKMOVDQU : VPDI<0xF7, MRMSrcReg, (outs),
2875 (ins VR128:$src, VR128:$mask),
2876 "maskmovdqu\t{$mask, $src|$src, $mask}",
2877 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>, VEX;
2879 def VMASKMOVDQU64 : VPDI<0xF7, MRMSrcReg, (outs),
2880 (ins VR128:$src, VR128:$mask),
2881 "maskmovdqu\t{$mask, $src|$src, $mask}",
2882 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>, VEX;
2885 def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2886 "maskmovdqu\t{$mask, $src|$src, $mask}",
2887 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
2889 def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2890 "maskmovdqu\t{$mask, $src|$src, $mask}",
2891 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2893 } // ExeDomain = SSEPackedInt
2895 //===---------------------------------------------------------------------===//
2896 // SSE2 - Move Doubleword
2897 //===---------------------------------------------------------------------===//
2899 //===---------------------------------------------------------------------===//
2900 // Move Int Doubleword to Packed Double Int
2902 def VMOVDI2PDIrr : VPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2903 "movd\t{$src, $dst|$dst, $src}",
2905 (v4i32 (scalar_to_vector GR32:$src)))]>, VEX;
2906 def VMOVDI2PDIrm : VPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2907 "movd\t{$src, $dst|$dst, $src}",
2909 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>,
2911 def VMOV64toPQIrr : VRPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2912 "mov{d|q}\t{$src, $dst|$dst, $src}",
2914 (v2i64 (scalar_to_vector GR64:$src)))]>, VEX;
2915 def VMOV64toSDrr : VRPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
2916 "mov{d|q}\t{$src, $dst|$dst, $src}",
2917 [(set FR64:$dst, (bitconvert GR64:$src))]>, VEX;
2919 def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
2920 "movd\t{$src, $dst|$dst, $src}",
2922 (v4i32 (scalar_to_vector GR32:$src)))]>;
2923 def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
2924 "movd\t{$src, $dst|$dst, $src}",
2926 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2927 def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2928 "mov{d|q}\t{$src, $dst|$dst, $src}",
2930 (v2i64 (scalar_to_vector GR64:$src)))]>;
2931 def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src),
2932 "mov{d|q}\t{$src, $dst|$dst, $src}",
2933 [(set FR64:$dst, (bitconvert GR64:$src))]>;
2935 //===---------------------------------------------------------------------===//
2936 // Move Int Doubleword to Single Scalar
2938 def VMOVDI2SSrr : VPDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
2939 "movd\t{$src, $dst|$dst, $src}",
2940 [(set FR32:$dst, (bitconvert GR32:$src))]>, VEX;
2942 def VMOVDI2SSrm : VPDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
2943 "movd\t{$src, $dst|$dst, $src}",
2944 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>,
2946 def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
2947 "movd\t{$src, $dst|$dst, $src}",
2948 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2950 def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
2951 "movd\t{$src, $dst|$dst, $src}",
2952 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2954 //===---------------------------------------------------------------------===//
2955 // Move Packed Doubleword Int to Packed Double Int
2957 def VMOVPDI2DIrr : VPDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
2958 "movd\t{$src, $dst|$dst, $src}",
2959 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2961 def VMOVPDI2DImr : VPDI<0x7E, MRMDestMem, (outs),
2962 (ins i32mem:$dst, VR128:$src),
2963 "movd\t{$src, $dst|$dst, $src}",
2964 [(store (i32 (vector_extract (v4i32 VR128:$src),
2965 (iPTR 0))), addr:$dst)]>, VEX;
2966 def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
2967 "movd\t{$src, $dst|$dst, $src}",
2968 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2970 def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
2971 "movd\t{$src, $dst|$dst, $src}",
2972 [(store (i32 (vector_extract (v4i32 VR128:$src),
2973 (iPTR 0))), addr:$dst)]>;
2975 def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
2976 "mov{d|q}\t{$src, $dst|$dst, $src}",
2977 [(set GR64:$dst, (vector_extract (v2i64 VR128:$src),
2979 def MOV64toSDrm : S3SI<0x7E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src),
2980 "movq\t{$src, $dst|$dst, $src}",
2981 [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>;
2983 def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src),
2984 "mov{d|q}\t{$src, $dst|$dst, $src}",
2985 [(set GR64:$dst, (bitconvert FR64:$src))]>;
2986 def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src),
2987 "movq\t{$src, $dst|$dst, $src}",
2988 [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>;
2990 //===---------------------------------------------------------------------===//
2991 // Move Scalar Single to Double Int
2993 def VMOVSS2DIrr : VPDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
2994 "movd\t{$src, $dst|$dst, $src}",
2995 [(set GR32:$dst, (bitconvert FR32:$src))]>, VEX;
2996 def VMOVSS2DImr : VPDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
2997 "movd\t{$src, $dst|$dst, $src}",
2998 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>, VEX;
2999 def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
3000 "movd\t{$src, $dst|$dst, $src}",
3001 [(set GR32:$dst, (bitconvert FR32:$src))]>;
3002 def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
3003 "movd\t{$src, $dst|$dst, $src}",
3004 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
3006 //===---------------------------------------------------------------------===//
3007 // Patterns and instructions to describe movd/movq to XMM register zero-extends
3009 let AddedComplexity = 15 in {
3010 def VMOVZDI2PDIrr : VPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
3011 "movd\t{$src, $dst|$dst, $src}",
3012 [(set VR128:$dst, (v4i32 (X86vzmovl
3013 (v4i32 (scalar_to_vector GR32:$src)))))]>,
3015 def VMOVZQI2PQIrr : VPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
3016 "mov{d|q}\t{$src, $dst|$dst, $src}", // X86-64 only
3017 [(set VR128:$dst, (v2i64 (X86vzmovl
3018 (v2i64 (scalar_to_vector GR64:$src)))))]>,
3021 let AddedComplexity = 15 in {
3022 def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
3023 "movd\t{$src, $dst|$dst, $src}",
3024 [(set VR128:$dst, (v4i32 (X86vzmovl
3025 (v4i32 (scalar_to_vector GR32:$src)))))]>;
3026 def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
3027 "mov{d|q}\t{$src, $dst|$dst, $src}", // X86-64 only
3028 [(set VR128:$dst, (v2i64 (X86vzmovl
3029 (v2i64 (scalar_to_vector GR64:$src)))))]>;
3032 let AddedComplexity = 20 in {
3033 def VMOVZDI2PDIrm : VPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3034 "movd\t{$src, $dst|$dst, $src}",
3036 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
3037 (loadi32 addr:$src))))))]>,
3039 def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3040 "movd\t{$src, $dst|$dst, $src}",
3042 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
3043 (loadi32 addr:$src))))))]>;
3045 def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
3046 (MOVZDI2PDIrm addr:$src)>;
3047 def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
3048 (MOVZDI2PDIrm addr:$src)>;
3049 def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
3050 (MOVZDI2PDIrm addr:$src)>;
3053 // AVX 128-bit movd/movq instruction write zeros in the high 128-bit part.
3054 // Use regular 128-bit instructions to match 256-bit scalar_to_vec+zext.
3055 def : Pat<(v8i32 (X86vzmovl (insert_subvector undef,
3056 (v4i32 (scalar_to_vector GR32:$src)), (i32 0)))),
3057 (SUBREG_TO_REG (i32 0), (VMOVZDI2PDIrr GR32:$src), sub_xmm)>;
3058 def : Pat<(v4i64 (X86vzmovl (insert_subvector undef,
3059 (v2i64 (scalar_to_vector GR64:$src)), (i32 0)))),
3060 (SUBREG_TO_REG (i64 0), (VMOVZQI2PQIrr GR64:$src), sub_xmm)>;
3062 // These are the correct encodings of the instructions so that we know how to
3063 // read correct assembly, even though we continue to emit the wrong ones for
3064 // compatibility with Darwin's buggy assembler.
3065 def : InstAlias<"movq\t{$src, $dst|$dst, $src}",
3066 (MOV64toPQIrr VR128:$dst, GR64:$src), 0>;
3067 def : InstAlias<"movq\t{$src, $dst|$dst, $src}",
3068 (MOV64toSDrr FR64:$dst, GR64:$src), 0>;
3069 def : InstAlias<"movq\t{$src, $dst|$dst, $src}",
3070 (MOVPQIto64rr GR64:$dst, VR128:$src), 0>;
3071 def : InstAlias<"movq\t{$src, $dst|$dst, $src}",
3072 (MOVSDto64rr GR64:$dst, FR64:$src), 0>;
3073 def : InstAlias<"movq\t{$src, $dst|$dst, $src}",
3074 (VMOVZQI2PQIrr VR128:$dst, GR64:$src), 0>;
3075 def : InstAlias<"movq\t{$src, $dst|$dst, $src}",
3076 (MOVZQI2PQIrr VR128:$dst, GR64:$src), 0>;
3078 //===---------------------------------------------------------------------===//
3079 // SSE2 - Move Quadword
3080 //===---------------------------------------------------------------------===//
3082 //===---------------------------------------------------------------------===//
3083 // Move Quadword Int to Packed Quadword Int
3085 def VMOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3086 "vmovq\t{$src, $dst|$dst, $src}",
3088 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
3089 VEX, Requires<[HasAVX]>;
3090 def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3091 "movq\t{$src, $dst|$dst, $src}",
3093 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
3094 Requires<[HasSSE2]>; // SSE2 instruction with XS Prefix
3096 //===---------------------------------------------------------------------===//
3097 // Move Packed Quadword Int to Quadword Int
3099 def VMOVPQI2QImr : VPDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
3100 "movq\t{$src, $dst|$dst, $src}",
3101 [(store (i64 (vector_extract (v2i64 VR128:$src),
3102 (iPTR 0))), addr:$dst)]>, VEX;
3103 def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
3104 "movq\t{$src, $dst|$dst, $src}",
3105 [(store (i64 (vector_extract (v2i64 VR128:$src),
3106 (iPTR 0))), addr:$dst)]>;
3108 def : Pat<(f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))),
3109 (f64 (EXTRACT_SUBREG (v2f64 VR128:$src), sub_sd))>;
3111 //===---------------------------------------------------------------------===//
3112 // Store / copy lower 64-bits of a XMM register.
3114 def VMOVLQ128mr : VPDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
3115 "movq\t{$src, $dst|$dst, $src}",
3116 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>, VEX;
3117 def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
3118 "movq\t{$src, $dst|$dst, $src}",
3119 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
3121 let AddedComplexity = 20 in
3122 def VMOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3123 "vmovq\t{$src, $dst|$dst, $src}",
3125 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
3126 (loadi64 addr:$src))))))]>,
3127 XS, VEX, Requires<[HasAVX]>;
3129 let AddedComplexity = 20 in {
3130 def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3131 "movq\t{$src, $dst|$dst, $src}",
3133 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
3134 (loadi64 addr:$src))))))]>,
3135 XS, Requires<[HasSSE2]>;
3137 def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
3138 (MOVZQI2PQIrm addr:$src)>;
3139 def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
3140 (MOVZQI2PQIrm addr:$src)>;
3141 def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
3144 //===---------------------------------------------------------------------===//
3145 // Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
3146 // IA32 document. movq xmm1, xmm2 does clear the high bits.
3148 let AddedComplexity = 15 in
3149 def VMOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3150 "vmovq\t{$src, $dst|$dst, $src}",
3151 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
3152 XS, VEX, Requires<[HasAVX]>;
3153 let AddedComplexity = 15 in
3154 def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3155 "movq\t{$src, $dst|$dst, $src}",
3156 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
3157 XS, Requires<[HasSSE2]>;
3159 let AddedComplexity = 20 in
3160 def VMOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3161 "vmovq\t{$src, $dst|$dst, $src}",
3162 [(set VR128:$dst, (v2i64 (X86vzmovl
3163 (loadv2i64 addr:$src))))]>,
3164 XS, VEX, Requires<[HasAVX]>;
3165 let AddedComplexity = 20 in {
3166 def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3167 "movq\t{$src, $dst|$dst, $src}",
3168 [(set VR128:$dst, (v2i64 (X86vzmovl
3169 (loadv2i64 addr:$src))))]>,
3170 XS, Requires<[HasSSE2]>;
3172 def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
3173 (MOVZPQILo2PQIrm addr:$src)>;
3176 // Instructions to match in the assembler
3177 def VMOVQs64rr : VPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
3178 "movq\t{$src, $dst|$dst, $src}", []>, VEX, VEX_W;
3179 def VMOVQd64rr : VPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
3180 "movq\t{$src, $dst|$dst, $src}", []>, VEX, VEX_W;
3181 // Recognize "movd" with GR64 destination, but encode as a "movq"
3182 def VMOVQd64rr_alt : VPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src),
3183 "movd\t{$src, $dst|$dst, $src}", []>, VEX, VEX_W;
3185 // Instructions for the disassembler
3186 // xr = XMM register
3189 let Predicates = [HasAVX] in
3190 def VMOVQxrxr: I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3191 "vmovq\t{$src, $dst|$dst, $src}", []>, VEX, XS;
3192 def MOVQxrxr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3193 "movq\t{$src, $dst|$dst, $src}", []>, XS;
3195 //===---------------------------------------------------------------------===//
3196 // SSE2 - Misc Instructions
3197 //===---------------------------------------------------------------------===//
3200 def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
3201 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
3202 TB, Requires<[HasSSE2]>;
3204 // Load, store, and memory fence
3205 def LFENCE : I<0xAE, MRM_E8, (outs), (ins),
3206 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
3207 def MFENCE : I<0xAE, MRM_F0, (outs), (ins),
3208 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
3209 def : Pat<(X86LFence), (LFENCE)>;
3210 def : Pat<(X86MFence), (MFENCE)>;
3213 // Pause. This "instruction" is encoded as "rep; nop", so even though it
3214 // was introduced with SSE2, it's backward compatible.
3215 def PAUSE : I<0x90, RawFrm, (outs), (ins), "pause", []>, REP;
3217 // Alias instructions that map zero vector to pxor / xorp* for sse.
3218 // We set canFoldAsLoad because this can be converted to a constant-pool
3219 // load of an all-ones value if folding it would be beneficial.
3220 // FIXME: Change encoding to pseudo! This is blocked right now by the x86
3221 // JIT implementation, it does not expand the instructions below like
3222 // X86MCInstLower does.
3223 let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
3224 isCodeGenOnly = 1, ExeDomain = SSEPackedInt in
3225 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "",
3226 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
3227 let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
3228 isCodeGenOnly = 1, ExeDomain = SSEPackedInt, Predicates = [HasAVX] in
3229 def AVX_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "",
3230 [(set VR128:$dst, (v4i32 immAllOnesV))]>, VEX_4V;
3232 //===---------------------------------------------------------------------===//
3233 // SSE3 - Conversion Instructions
3234 //===---------------------------------------------------------------------===//
3236 // Convert Packed Double FP to Packed DW Integers
3237 let Predicates = [HasAVX] in {
3238 // The assembler can recognize rr 256-bit instructions by seeing a ymm
3239 // register, but the same isn't true when using memory operands instead.
3240 // Provide other assembly rr and rm forms to address this explicitly.
3241 def VCVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3242 "vcvtpd2dq\t{$src, $dst|$dst, $src}", []>, VEX;
3243 def VCVTPD2DQXrYr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR256:$src),
3244 "vcvtpd2dq\t{$src, $dst|$dst, $src}", []>, VEX;
3247 def VCVTPD2DQXrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3248 "vcvtpd2dqx\t{$src, $dst|$dst, $src}", []>, VEX;
3249 def VCVTPD2DQXrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
3250 "vcvtpd2dqx\t{$src, $dst|$dst, $src}", []>, VEX;
3253 def VCVTPD2DQYrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR256:$src),
3254 "vcvtpd2dqy\t{$src, $dst|$dst, $src}", []>, VEX;
3255 def VCVTPD2DQYrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f256mem:$src),
3256 "vcvtpd2dqy\t{$src, $dst|$dst, $src}", []>, VEX, VEX_L;
3259 def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
3260 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
3261 def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3262 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
3264 // Convert Packed DW Integers to Packed Double FP
3265 let Predicates = [HasAVX] in {
3266 def VCVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
3267 "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX;
3268 def VCVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3269 "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX;
3270 def VCVTDQ2PDYrm : S3SI<0xE6, MRMSrcMem, (outs VR256:$dst), (ins f128mem:$src),
3271 "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX;
3272 def VCVTDQ2PDYrr : S3SI<0xE6, MRMSrcReg, (outs VR256:$dst), (ins VR128:$src),
3273 "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX;
3276 def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
3277 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
3278 def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3279 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
3281 // AVX 256-bit register conversion intrinsics
3282 def : Pat<(int_x86_avx_cvtdq2_pd_256 VR128:$src),
3283 (VCVTDQ2PDYrr VR128:$src)>;
3284 def : Pat<(int_x86_avx_cvtdq2_pd_256 (memopv4i32 addr:$src)),
3285 (VCVTDQ2PDYrm addr:$src)>;
3287 def : Pat<(int_x86_avx_cvt_pd2dq_256 VR256:$src),
3288 (VCVTPD2DQYrr VR256:$src)>;
3289 def : Pat<(int_x86_avx_cvt_pd2dq_256 (memopv4f64 addr:$src)),
3290 (VCVTPD2DQYrm addr:$src)>;
3292 //===---------------------------------------------------------------------===//
3293 // SSE3 - Move Instructions
3294 //===---------------------------------------------------------------------===//
3296 //===---------------------------------------------------------------------===//
3297 // Replicate Single FP - MOVSHDUP and MOVSLDUP
3299 multiclass sse3_replicate_sfp<bits<8> op, SDNode OpNode, string OpcodeStr,
3300 ValueType vt, RegisterClass RC, PatFrag mem_frag,
3301 X86MemOperand x86memop> {
3302 def rr : S3SI<op, MRMSrcReg, (outs RC:$dst), (ins RC:$src),
3303 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3304 [(set RC:$dst, (vt (OpNode RC:$src)))]>;
3305 def rm : S3SI<op, MRMSrcMem, (outs RC:$dst), (ins x86memop:$src),
3306 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3307 [(set RC:$dst, (OpNode (mem_frag addr:$src)))]>;
3310 let Predicates = [HasAVX] in {
3311 defm VMOVSHDUP : sse3_replicate_sfp<0x16, X86Movshdup, "vmovshdup",
3312 v4f32, VR128, memopv4f32, f128mem>, VEX;
3313 defm VMOVSLDUP : sse3_replicate_sfp<0x12, X86Movsldup, "vmovsldup",
3314 v4f32, VR128, memopv4f32, f128mem>, VEX;
3315 defm VMOVSHDUPY : sse3_replicate_sfp<0x16, X86Movshdup, "vmovshdup",
3316 v8f32, VR256, memopv8f32, f256mem>, VEX;
3317 defm VMOVSLDUPY : sse3_replicate_sfp<0x12, X86Movsldup, "vmovsldup",
3318 v8f32, VR256, memopv8f32, f256mem>, VEX;
3320 defm MOVSHDUP : sse3_replicate_sfp<0x16, X86Movshdup, "movshdup", v4f32, VR128,
3321 memopv4f32, f128mem>;
3322 defm MOVSLDUP : sse3_replicate_sfp<0x12, X86Movsldup, "movsldup", v4f32, VR128,
3323 memopv4f32, f128mem>;
3325 let Predicates = [HasSSE3] in {
3326 def : Pat<(v4i32 (X86Movshdup VR128:$src)),
3327 (MOVSHDUPrr VR128:$src)>;
3328 def : Pat<(v4i32 (X86Movshdup (bc_v4i32 (memopv2i64 addr:$src)))),
3329 (MOVSHDUPrm addr:$src)>;
3330 def : Pat<(v4i32 (X86Movsldup VR128:$src)),
3331 (MOVSLDUPrr VR128:$src)>;
3332 def : Pat<(v4i32 (X86Movsldup (bc_v4i32 (memopv2i64 addr:$src)))),
3333 (MOVSLDUPrm addr:$src)>;
3336 let Predicates = [HasAVX] in {
3337 def : Pat<(v4i32 (X86Movshdup VR128:$src)),
3338 (VMOVSHDUPrr VR128:$src)>;
3339 def : Pat<(v4i32 (X86Movshdup (bc_v4i32 (memopv2i64 addr:$src)))),
3340 (VMOVSHDUPrm addr:$src)>;
3341 def : Pat<(v4i32 (X86Movsldup VR128:$src)),
3342 (VMOVSLDUPrr VR128:$src)>;
3343 def : Pat<(v4i32 (X86Movsldup (bc_v4i32 (memopv2i64 addr:$src)))),
3344 (VMOVSLDUPrm addr:$src)>;
3345 def : Pat<(v8i32 (X86Movshdup VR256:$src)),
3346 (VMOVSHDUPYrr VR256:$src)>;
3347 def : Pat<(v8i32 (X86Movshdup (bc_v8i32 (memopv4i64 addr:$src)))),
3348 (VMOVSHDUPYrm addr:$src)>;
3349 def : Pat<(v8i32 (X86Movsldup VR256:$src)),
3350 (VMOVSLDUPYrr VR256:$src)>;
3351 def : Pat<(v8i32 (X86Movsldup (bc_v8i32 (memopv4i64 addr:$src)))),
3352 (VMOVSLDUPYrm addr:$src)>;
3355 //===---------------------------------------------------------------------===//
3356 // Replicate Double FP - MOVDDUP
3358 multiclass sse3_replicate_dfp<string OpcodeStr> {
3359 def rr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3360 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3361 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
3362 def rm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
3363 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3365 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
3369 multiclass sse3_replicate_dfp_y<string OpcodeStr> {
3370 def rr : S3DI<0x12, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src),
3371 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3373 def rm : S3DI<0x12, MRMSrcMem, (outs VR256:$dst), (ins f256mem:$src),
3374 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3378 let Predicates = [HasAVX] in {
3379 // FIXME: Merge above classes when we have patterns for the ymm version
3380 defm VMOVDDUP : sse3_replicate_dfp<"vmovddup">, VEX;
3381 defm VMOVDDUPY : sse3_replicate_dfp_y<"vmovddup">, VEX;
3383 defm MOVDDUP : sse3_replicate_dfp<"movddup">;
3385 // Move Unaligned Integer
3386 let Predicates = [HasAVX] in {
3387 def VLDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3388 "vlddqu\t{$src, $dst|$dst, $src}",
3389 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>, VEX;
3390 def VLDDQUYrm : S3DI<0xF0, MRMSrcMem, (outs VR256:$dst), (ins i256mem:$src),
3391 "vlddqu\t{$src, $dst|$dst, $src}",
3392 [(set VR256:$dst, (int_x86_avx_ldu_dq_256 addr:$src))]>, VEX;
3394 def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3395 "lddqu\t{$src, $dst|$dst, $src}",
3396 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
3398 def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
3400 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
3402 // Several Move patterns
3403 let AddedComplexity = 5 in {
3404 def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
3405 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
3406 def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
3407 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
3408 def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
3409 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
3410 def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
3411 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
3414 //===---------------------------------------------------------------------===//
3415 // SSE3 - Arithmetic
3416 //===---------------------------------------------------------------------===//
3418 multiclass sse3_addsub<Intrinsic Int, string OpcodeStr, RegisterClass RC,
3419 X86MemOperand x86memop, bit Is2Addr = 1> {
3420 def rr : I<0xD0, MRMSrcReg,
3421 (outs RC:$dst), (ins RC:$src1, RC:$src2),
3423 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3424 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3425 [(set RC:$dst, (Int RC:$src1, RC:$src2))]>;
3426 def rm : I<0xD0, MRMSrcMem,
3427 (outs RC:$dst), (ins RC:$src1, x86memop:$src2),
3429 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3430 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3431 [(set RC:$dst, (Int RC:$src1, (memop addr:$src2)))]>;
3434 let Predicates = [HasAVX],
3435 ExeDomain = SSEPackedDouble in {
3436 defm VADDSUBPS : sse3_addsub<int_x86_sse3_addsub_ps, "vaddsubps", VR128,
3437 f128mem, 0>, TB, XD, VEX_4V;
3438 defm VADDSUBPD : sse3_addsub<int_x86_sse3_addsub_pd, "vaddsubpd", VR128,
3439 f128mem, 0>, TB, OpSize, VEX_4V;
3440 defm VADDSUBPSY : sse3_addsub<int_x86_avx_addsub_ps_256, "vaddsubps", VR256,
3441 f256mem, 0>, TB, XD, VEX_4V;
3442 defm VADDSUBPDY : sse3_addsub<int_x86_avx_addsub_pd_256, "vaddsubpd", VR256,
3443 f256mem, 0>, TB, OpSize, VEX_4V;
3445 let Constraints = "$src1 = $dst", Predicates = [HasSSE3],
3446 ExeDomain = SSEPackedDouble in {
3447 defm ADDSUBPS : sse3_addsub<int_x86_sse3_addsub_ps, "addsubps", VR128,
3449 defm ADDSUBPD : sse3_addsub<int_x86_sse3_addsub_pd, "addsubpd", VR128,
3450 f128mem>, TB, OpSize;
3453 //===---------------------------------------------------------------------===//
3454 // SSE3 Instructions
3455 //===---------------------------------------------------------------------===//
3458 multiclass S3D_Int<bits<8> o, string OpcodeStr, ValueType vt, RegisterClass RC,
3459 X86MemOperand x86memop, Intrinsic IntId, bit Is2Addr = 1> {
3460 def rr : S3DI<o, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
3462 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3463 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3464 [(set RC:$dst, (vt (IntId RC:$src1, RC:$src2)))]>;
3466 def rm : S3DI<o, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, x86memop:$src2),
3468 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3469 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3470 [(set RC:$dst, (vt (IntId RC:$src1, (memop addr:$src2))))]>;
3472 multiclass S3_Int<bits<8> o, string OpcodeStr, ValueType vt, RegisterClass RC,
3473 X86MemOperand x86memop, Intrinsic IntId, bit Is2Addr = 1> {
3474 def rr : S3I<o, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
3476 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3477 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3478 [(set RC:$dst, (vt (IntId RC:$src1, RC:$src2)))]>;
3480 def rm : S3I<o, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, x86memop:$src2),
3482 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3483 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3484 [(set RC:$dst, (vt (IntId RC:$src1, (memop addr:$src2))))]>;
3487 let Predicates = [HasAVX] in {
3488 defm VHADDPS : S3D_Int<0x7C, "vhaddps", v4f32, VR128, f128mem,
3489 int_x86_sse3_hadd_ps, 0>, VEX_4V;
3490 defm VHADDPD : S3_Int <0x7C, "vhaddpd", v2f64, VR128, f128mem,
3491 int_x86_sse3_hadd_pd, 0>, VEX_4V;
3492 defm VHSUBPS : S3D_Int<0x7D, "vhsubps", v4f32, VR128, f128mem,
3493 int_x86_sse3_hsub_ps, 0>, VEX_4V;
3494 defm VHSUBPD : S3_Int <0x7D, "vhsubpd", v2f64, VR128, f128mem,
3495 int_x86_sse3_hsub_pd, 0>, VEX_4V;
3496 defm VHADDPSY : S3D_Int<0x7C, "vhaddps", v8f32, VR256, f256mem,
3497 int_x86_avx_hadd_ps_256, 0>, VEX_4V;
3498 defm VHADDPDY : S3_Int <0x7C, "vhaddpd", v4f64, VR256, f256mem,
3499 int_x86_avx_hadd_pd_256, 0>, VEX_4V;
3500 defm VHSUBPSY : S3D_Int<0x7D, "vhsubps", v8f32, VR256, f256mem,
3501 int_x86_avx_hsub_ps_256, 0>, VEX_4V;
3502 defm VHSUBPDY : S3_Int <0x7D, "vhsubpd", v4f64, VR256, f256mem,
3503 int_x86_avx_hsub_pd_256, 0>, VEX_4V;
3506 let Constraints = "$src1 = $dst" in {
3507 defm HADDPS : S3D_Int<0x7C, "haddps", v4f32, VR128, f128mem,
3508 int_x86_sse3_hadd_ps>;
3509 defm HADDPD : S3_Int<0x7C, "haddpd", v2f64, VR128, f128mem,
3510 int_x86_sse3_hadd_pd>;
3511 defm HSUBPS : S3D_Int<0x7D, "hsubps", v4f32, VR128, f128mem,
3512 int_x86_sse3_hsub_ps>;
3513 defm HSUBPD : S3_Int<0x7D, "hsubpd", v2f64, VR128, f128mem,
3514 int_x86_sse3_hsub_pd>;
3517 //===---------------------------------------------------------------------===//
3518 // SSSE3 - Packed Absolute Instructions
3519 //===---------------------------------------------------------------------===//
3522 /// SS3I_unop_rm_int - Simple SSSE3 unary op whose type can be v*{i8,i16,i32}.
3523 multiclass SS3I_unop_rm_int<bits<8> opc, string OpcodeStr,
3524 PatFrag mem_frag128, Intrinsic IntId128> {
3525 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
3527 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3528 [(set VR128:$dst, (IntId128 VR128:$src))]>,
3531 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
3533 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3536 (bitconvert (mem_frag128 addr:$src))))]>, OpSize;
3539 let Predicates = [HasAVX] in {
3540 defm VPABSB : SS3I_unop_rm_int<0x1C, "vpabsb", memopv16i8,
3541 int_x86_ssse3_pabs_b_128>, VEX;
3542 defm VPABSW : SS3I_unop_rm_int<0x1D, "vpabsw", memopv8i16,
3543 int_x86_ssse3_pabs_w_128>, VEX;
3544 defm VPABSD : SS3I_unop_rm_int<0x1E, "vpabsd", memopv4i32,
3545 int_x86_ssse3_pabs_d_128>, VEX;
3548 defm PABSB : SS3I_unop_rm_int<0x1C, "pabsb", memopv16i8,
3549 int_x86_ssse3_pabs_b_128>;
3550 defm PABSW : SS3I_unop_rm_int<0x1D, "pabsw", memopv8i16,
3551 int_x86_ssse3_pabs_w_128>;
3552 defm PABSD : SS3I_unop_rm_int<0x1E, "pabsd", memopv4i32,
3553 int_x86_ssse3_pabs_d_128>;
3555 //===---------------------------------------------------------------------===//
3556 // SSSE3 - Packed Binary Operator Instructions
3557 //===---------------------------------------------------------------------===//
3559 /// SS3I_binop_rm_int - Simple SSSE3 bin op whose type can be v*{i8,i16,i32}.
3560 multiclass SS3I_binop_rm_int<bits<8> opc, string OpcodeStr,
3561 PatFrag mem_frag128, Intrinsic IntId128,
3563 let isCommutable = 1 in
3564 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
3565 (ins VR128:$src1, VR128:$src2),
3567 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3568 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3569 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3571 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
3572 (ins VR128:$src1, i128mem:$src2),
3574 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3575 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
3577 (IntId128 VR128:$src1,
3578 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3581 let Predicates = [HasAVX] in {
3582 let isCommutable = 0 in {
3583 defm VPHADDW : SS3I_binop_rm_int<0x01, "vphaddw", memopv8i16,
3584 int_x86_ssse3_phadd_w_128, 0>, VEX_4V;
3585 defm VPHADDD : SS3I_binop_rm_int<0x02, "vphaddd", memopv4i32,
3586 int_x86_ssse3_phadd_d_128, 0>, VEX_4V;
3587 defm VPHADDSW : SS3I_binop_rm_int<0x03, "vphaddsw", memopv8i16,
3588 int_x86_ssse3_phadd_sw_128, 0>, VEX_4V;
3589 defm VPHSUBW : SS3I_binop_rm_int<0x05, "vphsubw", memopv8i16,
3590 int_x86_ssse3_phsub_w_128, 0>, VEX_4V;
3591 defm VPHSUBD : SS3I_binop_rm_int<0x06, "vphsubd", memopv4i32,
3592 int_x86_ssse3_phsub_d_128, 0>, VEX_4V;
3593 defm VPHSUBSW : SS3I_binop_rm_int<0x07, "vphsubsw", memopv8i16,
3594 int_x86_ssse3_phsub_sw_128, 0>, VEX_4V;
3595 defm VPMADDUBSW : SS3I_binop_rm_int<0x04, "vpmaddubsw", memopv16i8,
3596 int_x86_ssse3_pmadd_ub_sw_128, 0>, VEX_4V;
3597 defm VPSHUFB : SS3I_binop_rm_int<0x00, "vpshufb", memopv16i8,
3598 int_x86_ssse3_pshuf_b_128, 0>, VEX_4V;
3599 defm VPSIGNB : SS3I_binop_rm_int<0x08, "vpsignb", memopv16i8,
3600 int_x86_ssse3_psign_b_128, 0>, VEX_4V;
3601 defm VPSIGNW : SS3I_binop_rm_int<0x09, "vpsignw", memopv8i16,
3602 int_x86_ssse3_psign_w_128, 0>, VEX_4V;
3603 defm VPSIGND : SS3I_binop_rm_int<0x0A, "vpsignd", memopv4i32,
3604 int_x86_ssse3_psign_d_128, 0>, VEX_4V;
3606 defm VPMULHRSW : SS3I_binop_rm_int<0x0B, "vpmulhrsw", memopv8i16,
3607 int_x86_ssse3_pmul_hr_sw_128, 0>, VEX_4V;
3610 // None of these have i8 immediate fields.
3611 let ImmT = NoImm, Constraints = "$src1 = $dst" in {
3612 let isCommutable = 0 in {
3613 defm PHADDW : SS3I_binop_rm_int<0x01, "phaddw", memopv8i16,
3614 int_x86_ssse3_phadd_w_128>;
3615 defm PHADDD : SS3I_binop_rm_int<0x02, "phaddd", memopv4i32,
3616 int_x86_ssse3_phadd_d_128>;
3617 defm PHADDSW : SS3I_binop_rm_int<0x03, "phaddsw", memopv8i16,
3618 int_x86_ssse3_phadd_sw_128>;
3619 defm PHSUBW : SS3I_binop_rm_int<0x05, "phsubw", memopv8i16,
3620 int_x86_ssse3_phsub_w_128>;
3621 defm PHSUBD : SS3I_binop_rm_int<0x06, "phsubd", memopv4i32,
3622 int_x86_ssse3_phsub_d_128>;
3623 defm PHSUBSW : SS3I_binop_rm_int<0x07, "phsubsw", memopv8i16,
3624 int_x86_ssse3_phsub_sw_128>;
3625 defm PMADDUBSW : SS3I_binop_rm_int<0x04, "pmaddubsw", memopv16i8,
3626 int_x86_ssse3_pmadd_ub_sw_128>;
3627 defm PSHUFB : SS3I_binop_rm_int<0x00, "pshufb", memopv16i8,
3628 int_x86_ssse3_pshuf_b_128>;
3629 defm PSIGNB : SS3I_binop_rm_int<0x08, "psignb", memopv16i8,
3630 int_x86_ssse3_psign_b_128>;
3631 defm PSIGNW : SS3I_binop_rm_int<0x09, "psignw", memopv8i16,
3632 int_x86_ssse3_psign_w_128>;
3633 defm PSIGND : SS3I_binop_rm_int<0x0A, "psignd", memopv4i32,
3634 int_x86_ssse3_psign_d_128>;
3636 defm PMULHRSW : SS3I_binop_rm_int<0x0B, "pmulhrsw", memopv8i16,
3637 int_x86_ssse3_pmul_hr_sw_128>;
3640 def : Pat<(X86pshufb VR128:$src, VR128:$mask),
3641 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
3642 def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
3643 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
3645 def : Pat<(X86psignb VR128:$src1, VR128:$src2),
3646 (PSIGNBrr128 VR128:$src1, VR128:$src2)>, Requires<[HasSSSE3]>;
3647 def : Pat<(X86psignw VR128:$src1, VR128:$src2),
3648 (PSIGNWrr128 VR128:$src1, VR128:$src2)>, Requires<[HasSSSE3]>;
3649 def : Pat<(X86psignd VR128:$src1, VR128:$src2),
3650 (PSIGNDrr128 VR128:$src1, VR128:$src2)>, Requires<[HasSSSE3]>;
3652 //===---------------------------------------------------------------------===//
3653 // SSSE3 - Packed Align Instruction Patterns
3654 //===---------------------------------------------------------------------===//
3656 multiclass ssse3_palign<string asm, bit Is2Addr = 1> {
3657 def R128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
3658 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3660 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3662 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
3664 def R128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
3665 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3667 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3669 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
3673 let Predicates = [HasAVX] in
3674 defm VPALIGN : ssse3_palign<"vpalignr", 0>, VEX_4V;
3675 let Constraints = "$src1 = $dst", Predicates = [HasSSSE3] in
3676 defm PALIGN : ssse3_palign<"palignr">;
3678 let Predicates = [HasSSSE3] in {
3679 def : Pat<(v4i32 (X86PAlign VR128:$src1, VR128:$src2, (i8 imm:$imm))),
3680 (PALIGNR128rr VR128:$src2, VR128:$src1, imm:$imm)>;
3681 def : Pat<(v4f32 (X86PAlign VR128:$src1, VR128:$src2, (i8 imm:$imm))),
3682 (PALIGNR128rr VR128:$src2, VR128:$src1, imm:$imm)>;
3683 def : Pat<(v8i16 (X86PAlign VR128:$src1, VR128:$src2, (i8 imm:$imm))),
3684 (PALIGNR128rr VR128:$src2, VR128:$src1, imm:$imm)>;
3685 def : Pat<(v16i8 (X86PAlign VR128:$src1, VR128:$src2, (i8 imm:$imm))),
3686 (PALIGNR128rr VR128:$src2, VR128:$src1, imm:$imm)>;
3689 let Predicates = [HasAVX] in {
3690 def : Pat<(v4i32 (X86PAlign VR128:$src1, VR128:$src2, (i8 imm:$imm))),
3691 (VPALIGNR128rr VR128:$src2, VR128:$src1, imm:$imm)>;
3692 def : Pat<(v4f32 (X86PAlign VR128:$src1, VR128:$src2, (i8 imm:$imm))),
3693 (VPALIGNR128rr VR128:$src2, VR128:$src1, imm:$imm)>;
3694 def : Pat<(v8i16 (X86PAlign VR128:$src1, VR128:$src2, (i8 imm:$imm))),
3695 (VPALIGNR128rr VR128:$src2, VR128:$src1, imm:$imm)>;
3696 def : Pat<(v16i8 (X86PAlign VR128:$src1, VR128:$src2, (i8 imm:$imm))),
3697 (VPALIGNR128rr VR128:$src2, VR128:$src1, imm:$imm)>;
3700 //===---------------------------------------------------------------------===//
3701 // SSSE3 Misc Instructions
3702 //===---------------------------------------------------------------------===//
3704 // Thread synchronization
3705 let usesCustomInserter = 1 in {
3706 def MONITOR : PseudoI<(outs), (ins i32mem:$src1, GR32:$src2, GR32:$src3),
3707 [(int_x86_sse3_monitor addr:$src1, GR32:$src2, GR32:$src3)]>;
3708 def MWAIT : PseudoI<(outs), (ins GR32:$src1, GR32:$src2),
3709 [(int_x86_sse3_mwait GR32:$src1, GR32:$src2)]>;
3712 let Uses = [EAX, ECX, EDX] in
3713 def MONITORrrr : I<0x01, MRM_C8, (outs), (ins), "monitor", []>, TB,
3714 Requires<[HasSSE3]>;
3715 let Uses = [ECX, EAX] in
3716 def MWAITrr : I<0x01, MRM_C9, (outs), (ins), "mwait", []>, TB,
3717 Requires<[HasSSE3]>;
3719 def : InstAlias<"mwait %eax, %ecx", (MWAITrr)>, Requires<[In32BitMode]>;
3720 def : InstAlias<"mwait %rax, %rcx", (MWAITrr)>, Requires<[In64BitMode]>;
3722 def : InstAlias<"monitor %eax, %ecx, %edx", (MONITORrrr)>,
3723 Requires<[In32BitMode]>;
3724 def : InstAlias<"monitor %rax, %rcx, %rdx", (MONITORrrr)>,
3725 Requires<[In64BitMode]>;
3727 //===---------------------------------------------------------------------===//
3728 // Non-Instruction Patterns
3729 //===---------------------------------------------------------------------===//
3731 // extload f32 -> f64. This matches load+fextend because we have a hack in
3732 // the isel (PreprocessForFPConvert) that can introduce loads after dag
3734 // Since these loads aren't folded into the fextend, we have to match it
3736 let Predicates = [HasSSE2] in
3737 def : Pat<(fextend (loadf32 addr:$src)),
3738 (CVTSS2SDrm addr:$src)>;
3740 // Bitcasts between 128-bit vector types. Return the original type since
3741 // no instruction is needed for the conversion
3742 let Predicates = [HasXMMInt] in {
3743 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
3744 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
3745 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
3746 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
3747 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
3748 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
3749 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
3750 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
3751 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
3752 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
3753 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
3754 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
3755 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
3756 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
3757 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
3758 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
3759 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
3760 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
3761 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
3762 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
3763 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
3764 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
3765 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
3766 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
3767 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
3768 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
3769 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
3770 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
3771 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
3772 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
3775 // Bitcasts between 256-bit vector types. Return the original type since
3776 // no instruction is needed for the conversion
3777 let Predicates = [HasAVX] in {
3778 def : Pat<(v4f64 (bitconvert (v8f32 VR256:$src))), (v4f64 VR256:$src)>;
3779 def : Pat<(v4f64 (bitconvert (v8i32 VR256:$src))), (v4f64 VR256:$src)>;
3780 def : Pat<(v4f64 (bitconvert (v4i64 VR256:$src))), (v4f64 VR256:$src)>;
3781 def : Pat<(v4f64 (bitconvert (v16i16 VR256:$src))), (v4f64 VR256:$src)>;
3782 def : Pat<(v4f64 (bitconvert (v32i8 VR256:$src))), (v4f64 VR256:$src)>;
3783 def : Pat<(v8f32 (bitconvert (v8i32 VR256:$src))), (v8f32 VR256:$src)>;
3784 def : Pat<(v8f32 (bitconvert (v4i64 VR256:$src))), (v8f32 VR256:$src)>;
3785 def : Pat<(v8f32 (bitconvert (v4f64 VR256:$src))), (v8f32 VR256:$src)>;
3786 def : Pat<(v8f32 (bitconvert (v32i8 VR256:$src))), (v8f32 VR256:$src)>;
3787 def : Pat<(v8f32 (bitconvert (v16i16 VR256:$src))), (v8f32 VR256:$src)>;
3788 def : Pat<(v4i64 (bitconvert (v8f32 VR256:$src))), (v4i64 VR256:$src)>;
3789 def : Pat<(v4i64 (bitconvert (v8i32 VR256:$src))), (v4i64 VR256:$src)>;
3790 def : Pat<(v4i64 (bitconvert (v4f64 VR256:$src))), (v4i64 VR256:$src)>;
3791 def : Pat<(v4i64 (bitconvert (v32i8 VR256:$src))), (v4i64 VR256:$src)>;
3792 def : Pat<(v4i64 (bitconvert (v16i16 VR256:$src))), (v4i64 VR256:$src)>;
3793 def : Pat<(v32i8 (bitconvert (v4f64 VR256:$src))), (v32i8 VR256:$src)>;
3794 def : Pat<(v32i8 (bitconvert (v4i64 VR256:$src))), (v32i8 VR256:$src)>;
3795 def : Pat<(v32i8 (bitconvert (v8f32 VR256:$src))), (v32i8 VR256:$src)>;
3796 def : Pat<(v32i8 (bitconvert (v8i32 VR256:$src))), (v32i8 VR256:$src)>;
3797 def : Pat<(v32i8 (bitconvert (v16i16 VR256:$src))), (v32i8 VR256:$src)>;
3798 def : Pat<(v8i32 (bitconvert (v32i8 VR256:$src))), (v8i32 VR256:$src)>;
3799 def : Pat<(v8i32 (bitconvert (v16i16 VR256:$src))), (v8i32 VR256:$src)>;
3800 def : Pat<(v8i32 (bitconvert (v8f32 VR256:$src))), (v8i32 VR256:$src)>;
3801 def : Pat<(v8i32 (bitconvert (v4i64 VR256:$src))), (v8i32 VR256:$src)>;
3802 def : Pat<(v8i32 (bitconvert (v4f64 VR256:$src))), (v8i32 VR256:$src)>;
3803 def : Pat<(v16i16 (bitconvert (v8f32 VR256:$src))), (v16i16 VR256:$src)>;
3804 def : Pat<(v16i16 (bitconvert (v8i32 VR256:$src))), (v16i16 VR256:$src)>;
3805 def : Pat<(v16i16 (bitconvert (v4i64 VR256:$src))), (v16i16 VR256:$src)>;
3806 def : Pat<(v16i16 (bitconvert (v4f64 VR256:$src))), (v16i16 VR256:$src)>;
3807 def : Pat<(v16i16 (bitconvert (v32i8 VR256:$src))), (v16i16 VR256:$src)>;
3810 // Move scalar to XMM zero-extended
3811 // movd to XMM register zero-extends
3812 let AddedComplexity = 15 in {
3813 // Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
3814 def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
3815 (MOVSDrr (v2f64 (V_SET0PS)), FR64:$src)>;
3816 def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
3817 (MOVSSrr (v4f32 (V_SET0PS)), FR32:$src)>;
3818 def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
3819 (MOVSSrr (v4f32 (V_SET0PS)),
3820 (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), sub_ss)))>;
3821 def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
3822 (MOVSSrr (v4i32 (V_SET0PI)),
3823 (EXTRACT_SUBREG (v4i32 VR128:$src), sub_ss))>;
3826 // Splat v2f64 / v2i64
3827 let AddedComplexity = 10 in {
3828 def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
3829 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
3830 def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
3831 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
3834 // Special unary SHUFPSrri case.
3835 def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
3836 (SHUFPSrri VR128:$src1, VR128:$src1,
3837 (SHUFFLE_get_shuf_imm VR128:$src3))>;
3838 let AddedComplexity = 5 in
3839 def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
3840 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3841 Requires<[HasSSE2]>;
3842 // Special unary SHUFPDrri case.
3843 def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
3844 (SHUFPDrri VR128:$src1, VR128:$src1,
3845 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3846 Requires<[HasSSE2]>;
3847 // Special unary SHUFPDrri case.
3848 def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
3849 (SHUFPDrri VR128:$src1, VR128:$src1,
3850 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3851 Requires<[HasSSE2]>;
3852 // Unary v4f32 shuffle with PSHUF* in order to fold a load.
3853 def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
3854 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3855 Requires<[HasSSE2]>;
3857 // Special binary v4i32 shuffle cases with SHUFPS.
3858 def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
3859 (SHUFPSrri VR128:$src1, VR128:$src2,
3860 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3861 Requires<[HasSSE2]>;
3862 def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
3863 (SHUFPSrmi VR128:$src1, addr:$src2,
3864 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3865 Requires<[HasSSE2]>;
3866 // Special binary v2i64 shuffle cases using SHUFPDrri.
3867 def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
3868 (SHUFPDrri VR128:$src1, VR128:$src2,
3869 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3870 Requires<[HasSSE2]>;
3872 let AddedComplexity = 20 in {
3873 // vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
3874 def : Pat<(v4i32 (movlhps VR128:$src1, VR128:$src2)),
3875 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
3877 // vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
3878 def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
3879 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
3881 // vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
3882 def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
3883 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
3884 def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
3885 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
3888 let AddedComplexity = 20 in {
3889 // vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
3890 def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
3891 (MOVLPSrm VR128:$src1, addr:$src2)>;
3892 def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
3893 (MOVLPDrm VR128:$src1, addr:$src2)>;
3894 def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
3895 (MOVLPSrm VR128:$src1, addr:$src2)>;
3896 def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
3897 (MOVLPDrm VR128:$src1, addr:$src2)>;
3900 // (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
3901 def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3902 (MOVLPSmr addr:$src1, VR128:$src2)>;
3903 def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3904 (MOVLPDmr addr:$src1, VR128:$src2)>;
3905 def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3907 (MOVLPSmr addr:$src1, VR128:$src2)>;
3908 def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
3909 (MOVLPDmr addr:$src1, VR128:$src2)>;
3911 let AddedComplexity = 15 in {
3912 // Setting the lowest element in the vector.
3913 def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
3914 (MOVSSrr (v4i32 VR128:$src1),
3915 (EXTRACT_SUBREG (v4i32 VR128:$src2), sub_ss))>;
3916 def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
3917 (MOVSDrr (v2i64 VR128:$src1),
3918 (EXTRACT_SUBREG (v2i64 VR128:$src2), sub_sd))>;
3920 // vector_shuffle v1, v2 <4, 5, 2, 3> using movsd
3921 def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
3922 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, sub_sd))>,
3923 Requires<[HasSSE2]>;
3924 def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
3925 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG VR128:$src2, sub_sd))>,
3926 Requires<[HasSSE2]>;
3929 // vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3930 // fall back to this for SSE1)
3931 def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
3932 (SHUFPSrri VR128:$src2, VR128:$src1,
3933 (SHUFFLE_get_shuf_imm VR128:$src3))>;
3935 // Set lowest element and zero upper elements.
3936 def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
3937 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
3939 // Use movaps / movups for SSE integer load / store (one byte shorter).
3940 // The instructions selected below are then converted to MOVDQA/MOVDQU
3941 // during the SSE domain pass.
3942 let Predicates = [HasSSE1] in {
3943 def : Pat<(alignedloadv4i32 addr:$src),
3944 (MOVAPSrm addr:$src)>;
3945 def : Pat<(loadv4i32 addr:$src),
3946 (MOVUPSrm addr:$src)>;
3947 def : Pat<(alignedloadv2i64 addr:$src),
3948 (MOVAPSrm addr:$src)>;
3949 def : Pat<(loadv2i64 addr:$src),
3950 (MOVUPSrm addr:$src)>;
3952 def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3953 (MOVAPSmr addr:$dst, VR128:$src)>;
3954 def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3955 (MOVAPSmr addr:$dst, VR128:$src)>;
3956 def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3957 (MOVAPSmr addr:$dst, VR128:$src)>;
3958 def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3959 (MOVAPSmr addr:$dst, VR128:$src)>;
3960 def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3961 (MOVUPSmr addr:$dst, VR128:$src)>;
3962 def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3963 (MOVUPSmr addr:$dst, VR128:$src)>;
3964 def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3965 (MOVUPSmr addr:$dst, VR128:$src)>;
3966 def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3967 (MOVUPSmr addr:$dst, VR128:$src)>;
3970 // Use vmovaps/vmovups for AVX integer load/store.
3971 let Predicates = [HasAVX] in {
3972 // 128-bit load/store
3973 def : Pat<(alignedloadv4i32 addr:$src),
3974 (VMOVAPSrm addr:$src)>;
3975 def : Pat<(loadv4i32 addr:$src),
3976 (VMOVUPSrm addr:$src)>;
3977 def : Pat<(alignedloadv2i64 addr:$src),
3978 (VMOVAPSrm addr:$src)>;
3979 def : Pat<(loadv2i64 addr:$src),
3980 (VMOVUPSrm addr:$src)>;
3982 def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3983 (VMOVAPSmr addr:$dst, VR128:$src)>;
3984 def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3985 (VMOVAPSmr addr:$dst, VR128:$src)>;
3986 def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3987 (VMOVAPSmr addr:$dst, VR128:$src)>;
3988 def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3989 (VMOVAPSmr addr:$dst, VR128:$src)>;
3990 def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3991 (VMOVUPSmr addr:$dst, VR128:$src)>;
3992 def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3993 (VMOVUPSmr addr:$dst, VR128:$src)>;
3994 def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3995 (VMOVUPSmr addr:$dst, VR128:$src)>;
3996 def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3997 (VMOVUPSmr addr:$dst, VR128:$src)>;
3999 // 256-bit load/store
4000 def : Pat<(alignedloadv4i64 addr:$src),
4001 (VMOVAPSYrm addr:$src)>;
4002 def : Pat<(loadv4i64 addr:$src),
4003 (VMOVUPSYrm addr:$src)>;
4004 def : Pat<(alignedloadv8i32 addr:$src),
4005 (VMOVAPSYrm addr:$src)>;
4006 def : Pat<(loadv8i32 addr:$src),
4007 (VMOVUPSYrm addr:$src)>;
4008 def : Pat<(alignedstore (v4i64 VR256:$src), addr:$dst),
4009 (VMOVAPSYmr addr:$dst, VR256:$src)>;
4010 def : Pat<(alignedstore (v8i32 VR256:$src), addr:$dst),
4011 (VMOVAPSYmr addr:$dst, VR256:$src)>;
4012 def : Pat<(store (v4i64 VR256:$src), addr:$dst),
4013 (VMOVUPSYmr addr:$dst, VR256:$src)>;
4014 def : Pat<(store (v8i32 VR256:$src), addr:$dst),
4015 (VMOVUPSYmr addr:$dst, VR256:$src)>;
4018 //===----------------------------------------------------------------------===//
4019 // SSE4.1 - Packed Move with Sign/Zero Extend
4020 //===----------------------------------------------------------------------===//
4022 multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
4023 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
4024 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
4025 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
4027 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
4028 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
4030 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
4034 let Predicates = [HasAVX] in {
4035 defm VPMOVSXBW : SS41I_binop_rm_int8<0x20, "vpmovsxbw", int_x86_sse41_pmovsxbw>,
4037 defm VPMOVSXWD : SS41I_binop_rm_int8<0x23, "vpmovsxwd", int_x86_sse41_pmovsxwd>,
4039 defm VPMOVSXDQ : SS41I_binop_rm_int8<0x25, "vpmovsxdq", int_x86_sse41_pmovsxdq>,
4041 defm VPMOVZXBW : SS41I_binop_rm_int8<0x30, "vpmovzxbw", int_x86_sse41_pmovzxbw>,
4043 defm VPMOVZXWD : SS41I_binop_rm_int8<0x33, "vpmovzxwd", int_x86_sse41_pmovzxwd>,
4045 defm VPMOVZXDQ : SS41I_binop_rm_int8<0x35, "vpmovzxdq", int_x86_sse41_pmovzxdq>,
4049 defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
4050 defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
4051 defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
4052 defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
4053 defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
4054 defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
4056 // Common patterns involving scalar load.
4057 def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
4058 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
4059 def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
4060 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
4062 def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
4063 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
4064 def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
4065 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
4067 def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
4068 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
4069 def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
4070 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
4072 def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
4073 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
4074 def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
4075 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
4077 def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
4078 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
4079 def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
4080 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
4082 def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
4083 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
4084 def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
4085 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
4088 multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
4089 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
4090 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
4091 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
4093 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
4094 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
4096 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
4100 let Predicates = [HasAVX] in {
4101 defm VPMOVSXBD : SS41I_binop_rm_int4<0x21, "vpmovsxbd", int_x86_sse41_pmovsxbd>,
4103 defm VPMOVSXWQ : SS41I_binop_rm_int4<0x24, "vpmovsxwq", int_x86_sse41_pmovsxwq>,
4105 defm VPMOVZXBD : SS41I_binop_rm_int4<0x31, "vpmovzxbd", int_x86_sse41_pmovzxbd>,
4107 defm VPMOVZXWQ : SS41I_binop_rm_int4<0x34, "vpmovzxwq", int_x86_sse41_pmovzxwq>,
4111 defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
4112 defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
4113 defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
4114 defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
4116 // Common patterns involving scalar load
4117 def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
4118 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
4119 def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
4120 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
4122 def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
4123 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
4124 def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
4125 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
4128 multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
4129 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
4130 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
4131 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
4133 // Expecting a i16 load any extended to i32 value.
4134 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
4135 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
4136 [(set VR128:$dst, (IntId (bitconvert
4137 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
4141 let Predicates = [HasAVX] in {
4142 defm VPMOVSXBQ : SS41I_binop_rm_int2<0x22, "vpmovsxbq", int_x86_sse41_pmovsxbq>,
4144 defm VPMOVZXBQ : SS41I_binop_rm_int2<0x32, "vpmovzxbq", int_x86_sse41_pmovzxbq>,
4147 defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
4148 defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
4150 // Common patterns involving scalar load
4151 def : Pat<(int_x86_sse41_pmovsxbq
4152 (bitconvert (v4i32 (X86vzmovl
4153 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
4154 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
4156 def : Pat<(int_x86_sse41_pmovzxbq
4157 (bitconvert (v4i32 (X86vzmovl
4158 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
4159 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
4161 //===----------------------------------------------------------------------===//
4162 // SSE4.1 - Extract Instructions
4163 //===----------------------------------------------------------------------===//
4165 /// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
4166 multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
4167 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
4168 (ins VR128:$src1, i32i8imm:$src2),
4169 !strconcat(OpcodeStr,
4170 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4171 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
4173 def mr : SS4AIi8<opc, MRMDestMem, (outs),
4174 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
4175 !strconcat(OpcodeStr,
4176 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4179 // There's an AssertZext in the way of writing the store pattern
4180 // (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
4183 let Predicates = [HasAVX] in {
4184 defm VPEXTRB : SS41I_extract8<0x14, "vpextrb">, VEX;
4185 def VPEXTRBrr64 : SS4AIi8<0x14, MRMDestReg, (outs GR64:$dst),
4186 (ins VR128:$src1, i32i8imm:$src2),
4187 "vpextrb\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>, OpSize, VEX;
4190 defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
4193 /// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
4194 multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
4195 def mr : SS4AIi8<opc, MRMDestMem, (outs),
4196 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
4197 !strconcat(OpcodeStr,
4198 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4201 // There's an AssertZext in the way of writing the store pattern
4202 // (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
4205 let Predicates = [HasAVX] in
4206 defm VPEXTRW : SS41I_extract16<0x15, "vpextrw">, VEX;
4208 defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
4211 /// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
4212 multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
4213 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
4214 (ins VR128:$src1, i32i8imm:$src2),
4215 !strconcat(OpcodeStr,
4216 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4218 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
4219 def mr : SS4AIi8<opc, MRMDestMem, (outs),
4220 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
4221 !strconcat(OpcodeStr,
4222 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4223 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
4224 addr:$dst)]>, OpSize;
4227 let Predicates = [HasAVX] in
4228 defm VPEXTRD : SS41I_extract32<0x16, "vpextrd">, VEX;
4230 defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
4232 /// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
4233 multiclass SS41I_extract64<bits<8> opc, string OpcodeStr> {
4234 def rr : SS4AIi8<opc, MRMDestReg, (outs GR64:$dst),
4235 (ins VR128:$src1, i32i8imm:$src2),
4236 !strconcat(OpcodeStr,
4237 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4239 (extractelt (v2i64 VR128:$src1), imm:$src2))]>, OpSize, REX_W;
4240 def mr : SS4AIi8<opc, MRMDestMem, (outs),
4241 (ins i64mem:$dst, VR128:$src1, i32i8imm:$src2),
4242 !strconcat(OpcodeStr,
4243 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4244 [(store (extractelt (v2i64 VR128:$src1), imm:$src2),
4245 addr:$dst)]>, OpSize, REX_W;
4248 let Predicates = [HasAVX] in
4249 defm VPEXTRQ : SS41I_extract64<0x16, "vpextrq">, VEX, VEX_W;
4251 defm PEXTRQ : SS41I_extract64<0x16, "pextrq">;
4253 /// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
4255 multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
4256 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
4257 (ins VR128:$src1, i32i8imm:$src2),
4258 !strconcat(OpcodeStr,
4259 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4261 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
4263 def mr : SS4AIi8<opc, MRMDestMem, (outs),
4264 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
4265 !strconcat(OpcodeStr,
4266 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4267 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
4268 addr:$dst)]>, OpSize;
4271 let Predicates = [HasAVX] in {
4272 defm VEXTRACTPS : SS41I_extractf32<0x17, "vextractps">, VEX;
4273 def VEXTRACTPSrr64 : SS4AIi8<0x17, MRMDestReg, (outs GR64:$dst),
4274 (ins VR128:$src1, i32i8imm:$src2),
4275 "vextractps \t{$src2, $src1, $dst|$dst, $src1, $src2}",
4278 defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
4280 // Also match an EXTRACTPS store when the store is done as f32 instead of i32.
4281 def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
4284 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
4285 Requires<[HasSSE41]>;
4287 //===----------------------------------------------------------------------===//
4288 // SSE4.1 - Insert Instructions
4289 //===----------------------------------------------------------------------===//
4291 multiclass SS41I_insert8<bits<8> opc, string asm, bit Is2Addr = 1> {
4292 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
4293 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
4295 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4297 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4299 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
4300 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
4301 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
4303 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4305 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4307 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
4308 imm:$src3))]>, OpSize;
4311 let Predicates = [HasAVX] in
4312 defm VPINSRB : SS41I_insert8<0x20, "vpinsrb", 0>, VEX_4V;
4313 let Constraints = "$src1 = $dst" in
4314 defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
4316 multiclass SS41I_insert32<bits<8> opc, string asm, bit Is2Addr = 1> {
4317 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
4318 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
4320 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4322 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4324 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
4326 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
4327 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
4329 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4331 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4333 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
4334 imm:$src3)))]>, OpSize;
4337 let Predicates = [HasAVX] in
4338 defm VPINSRD : SS41I_insert32<0x22, "vpinsrd", 0>, VEX_4V;
4339 let Constraints = "$src1 = $dst" in
4340 defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
4342 multiclass SS41I_insert64<bits<8> opc, string asm, bit Is2Addr = 1> {
4343 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
4344 (ins VR128:$src1, GR64:$src2, i32i8imm:$src3),
4346 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4348 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4350 (v2i64 (insertelt VR128:$src1, GR64:$src2, imm:$src3)))]>,
4352 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
4353 (ins VR128:$src1, i64mem:$src2, i32i8imm:$src3),
4355 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4357 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4359 (v2i64 (insertelt VR128:$src1, (loadi64 addr:$src2),
4360 imm:$src3)))]>, OpSize;
4363 let Predicates = [HasAVX] in
4364 defm VPINSRQ : SS41I_insert64<0x22, "vpinsrq", 0>, VEX_4V, VEX_W;
4365 let Constraints = "$src1 = $dst" in
4366 defm PINSRQ : SS41I_insert64<0x22, "pinsrq">, REX_W;
4368 // insertps has a few different modes, there's the first two here below which
4369 // are optimized inserts that won't zero arbitrary elements in the destination
4370 // vector. The next one matches the intrinsic and could zero arbitrary elements
4371 // in the target vector.
4372 multiclass SS41I_insertf32<bits<8> opc, string asm, bit Is2Addr = 1> {
4373 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
4374 (ins VR128:$src1, VR128:$src2, u32u8imm:$src3),
4376 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4378 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4380 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
4382 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
4383 (ins VR128:$src1, f32mem:$src2, u32u8imm:$src3),
4385 !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4387 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4389 (X86insrtps VR128:$src1,
4390 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
4391 imm:$src3))]>, OpSize;
4394 let Constraints = "$src1 = $dst" in
4395 defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
4396 let Predicates = [HasAVX] in
4397 defm VINSERTPS : SS41I_insertf32<0x21, "vinsertps", 0>, VEX_4V;
4399 def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
4400 (VINSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>,
4402 def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
4403 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>,
4404 Requires<[HasSSE41]>;
4406 //===----------------------------------------------------------------------===//
4407 // SSE4.1 - Round Instructions
4408 //===----------------------------------------------------------------------===//
4410 multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd, string OpcodeStr,
4411 X86MemOperand x86memop, RegisterClass RC,
4412 PatFrag mem_frag32, PatFrag mem_frag64,
4413 Intrinsic V4F32Int, Intrinsic V2F64Int> {
4414 // Intrinsic operation, reg.
4415 // Vector intrinsic operation, reg
4416 def PSr : SS4AIi8<opcps, MRMSrcReg,
4417 (outs RC:$dst), (ins RC:$src1, i32i8imm:$src2),
4418 !strconcat(OpcodeStr,
4419 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4420 [(set RC:$dst, (V4F32Int RC:$src1, imm:$src2))]>,
4423 // Vector intrinsic operation, mem
4424 def PSm : Ii8<opcps, MRMSrcMem,
4425 (outs RC:$dst), (ins f256mem:$src1, i32i8imm:$src2),
4426 !strconcat(OpcodeStr,
4427 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4429 (V4F32Int (mem_frag32 addr:$src1),imm:$src2))]>,
4431 Requires<[HasSSE41]>;
4433 // Vector intrinsic operation, reg
4434 def PDr : SS4AIi8<opcpd, MRMSrcReg,
4435 (outs RC:$dst), (ins RC:$src1, i32i8imm:$src2),
4436 !strconcat(OpcodeStr,
4437 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4438 [(set RC:$dst, (V2F64Int RC:$src1, imm:$src2))]>,
4441 // Vector intrinsic operation, mem
4442 def PDm : SS4AIi8<opcpd, MRMSrcMem,
4443 (outs RC:$dst), (ins f256mem:$src1, i32i8imm:$src2),
4444 !strconcat(OpcodeStr,
4445 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4447 (V2F64Int (mem_frag64 addr:$src1),imm:$src2))]>,
4451 multiclass sse41_fp_unop_rm_avx_p<bits<8> opcps, bits<8> opcpd,
4452 RegisterClass RC, X86MemOperand x86memop, string OpcodeStr> {
4453 // Intrinsic operation, reg.
4454 // Vector intrinsic operation, reg
4455 def PSr_AVX : SS4AIi8<opcps, MRMSrcReg,
4456 (outs RC:$dst), (ins RC:$src1, i32i8imm:$src2),
4457 !strconcat(OpcodeStr,
4458 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4461 // Vector intrinsic operation, mem
4462 def PSm_AVX : Ii8<opcps, MRMSrcMem,
4463 (outs RC:$dst), (ins x86memop:$src1, i32i8imm:$src2),
4464 !strconcat(OpcodeStr,
4465 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4466 []>, TA, OpSize, Requires<[HasSSE41]>;
4468 // Vector intrinsic operation, reg
4469 def PDr_AVX : SS4AIi8<opcpd, MRMSrcReg,
4470 (outs RC:$dst), (ins RC:$src1, i32i8imm:$src2),
4471 !strconcat(OpcodeStr,
4472 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4475 // Vector intrinsic operation, mem
4476 def PDm_AVX : SS4AIi8<opcpd, MRMSrcMem,
4477 (outs RC:$dst), (ins x86memop:$src1, i32i8imm:$src2),
4478 !strconcat(OpcodeStr,
4479 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
4483 multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
4486 Intrinsic F64Int, bit Is2Addr = 1> {
4487 // Intrinsic operation, reg.
4488 def SSr : SS4AIi8<opcss, MRMSrcReg,
4489 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
4491 !strconcat(OpcodeStr,
4492 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4493 !strconcat(OpcodeStr,
4494 "ss\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4495 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
4498 // Intrinsic operation, mem.
4499 def SSm : SS4AIi8<opcss, MRMSrcMem,
4500 (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
4502 !strconcat(OpcodeStr,
4503 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4504 !strconcat(OpcodeStr,
4505 "ss\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4507 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
4510 // Intrinsic operation, reg.
4511 def SDr : SS4AIi8<opcsd, MRMSrcReg,
4512 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
4514 !strconcat(OpcodeStr,
4515 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4516 !strconcat(OpcodeStr,
4517 "sd\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4518 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
4521 // Intrinsic operation, mem.
4522 def SDm : SS4AIi8<opcsd, MRMSrcMem,
4523 (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
4525 !strconcat(OpcodeStr,
4526 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4527 !strconcat(OpcodeStr,
4528 "sd\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4530 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
4534 multiclass sse41_fp_binop_rm_avx_s<bits<8> opcss, bits<8> opcsd,
4536 // Intrinsic operation, reg.
4537 def SSr_AVX : SS4AIi8<opcss, MRMSrcReg,
4538 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
4539 !strconcat(OpcodeStr,
4540 "ss\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
4543 // Intrinsic operation, mem.
4544 def SSm_AVX : SS4AIi8<opcss, MRMSrcMem,
4545 (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
4546 !strconcat(OpcodeStr,
4547 "ss\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
4550 // Intrinsic operation, reg.
4551 def SDr_AVX : SS4AIi8<opcsd, MRMSrcReg,
4552 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
4553 !strconcat(OpcodeStr,
4554 "sd\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
4557 // Intrinsic operation, mem.
4558 def SDm_AVX : SS4AIi8<opcsd, MRMSrcMem,
4559 (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
4560 !strconcat(OpcodeStr,
4561 "sd\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
4565 // FP round - roundss, roundps, roundsd, roundpd
4566 let Predicates = [HasAVX] in {
4568 defm VROUND : sse41_fp_unop_rm<0x08, 0x09, "vround", f128mem, VR128,
4569 memopv4f32, memopv2f64,
4570 int_x86_sse41_round_ps,
4571 int_x86_sse41_round_pd>, VEX;
4572 defm VROUNDY : sse41_fp_unop_rm<0x08, 0x09, "vround", f256mem, VR256,
4573 memopv8f32, memopv4f64,
4574 int_x86_avx_round_ps_256,
4575 int_x86_avx_round_pd_256>, VEX;
4576 defm VROUND : sse41_fp_binop_rm<0x0A, 0x0B, "vround",
4577 int_x86_sse41_round_ss,
4578 int_x86_sse41_round_sd, 0>, VEX_4V;
4580 // Instructions for the assembler
4581 defm VROUND : sse41_fp_unop_rm_avx_p<0x08, 0x09, VR128, f128mem, "vround">,
4583 defm VROUNDY : sse41_fp_unop_rm_avx_p<0x08, 0x09, VR256, f256mem, "vround">,
4585 defm VROUND : sse41_fp_binop_rm_avx_s<0x0A, 0x0B, "vround">, VEX_4V;
4588 defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round", f128mem, VR128,
4589 memopv4f32, memopv2f64,
4590 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
4591 let Constraints = "$src1 = $dst" in
4592 defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
4593 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
4595 //===----------------------------------------------------------------------===//
4596 // SSE4.1 - Packed Bit Test
4597 //===----------------------------------------------------------------------===//
4599 // ptest instruction we'll lower to this in X86ISelLowering primarily from
4600 // the intel intrinsic that corresponds to this.
4601 let Defs = [EFLAGS], Predicates = [HasAVX] in {
4602 def VPTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
4603 "vptest\t{$src2, $src1|$src1, $src2}",
4604 [(set EFLAGS, (X86ptest VR128:$src1, (v4f32 VR128:$src2)))]>,
4606 def VPTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
4607 "vptest\t{$src2, $src1|$src1, $src2}",
4608 [(set EFLAGS,(X86ptest VR128:$src1, (memopv4f32 addr:$src2)))]>,
4611 def VPTESTYrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR256:$src1, VR256:$src2),
4612 "vptest\t{$src2, $src1|$src1, $src2}",
4613 [(set EFLAGS, (X86ptest VR256:$src1, (v4i64 VR256:$src2)))]>,
4615 def VPTESTYrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR256:$src1, i256mem:$src2),
4616 "vptest\t{$src2, $src1|$src1, $src2}",
4617 [(set EFLAGS,(X86ptest VR256:$src1, (memopv4i64 addr:$src2)))]>,
4621 let Defs = [EFLAGS] in {
4622 def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
4623 "ptest \t{$src2, $src1|$src1, $src2}",
4624 [(set EFLAGS, (X86ptest VR128:$src1, (v4f32 VR128:$src2)))]>,
4626 def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
4627 "ptest \t{$src2, $src1|$src1, $src2}",
4628 [(set EFLAGS, (X86ptest VR128:$src1, (memopv4f32 addr:$src2)))]>,
4632 // The bit test instructions below are AVX only
4633 multiclass avx_bittest<bits<8> opc, string OpcodeStr, RegisterClass RC,
4634 X86MemOperand x86memop, PatFrag mem_frag, ValueType vt> {
4635 def rr : SS48I<opc, MRMSrcReg, (outs), (ins RC:$src1, RC:$src2),
4636 !strconcat(OpcodeStr, "\t{$src2, $src1|$src1, $src2}"),
4637 [(set EFLAGS, (X86testp RC:$src1, (vt RC:$src2)))]>, OpSize, VEX;
4638 def rm : SS48I<opc, MRMSrcMem, (outs), (ins RC:$src1, x86memop:$src2),
4639 !strconcat(OpcodeStr, "\t{$src2, $src1|$src1, $src2}"),
4640 [(set EFLAGS, (X86testp RC:$src1, (mem_frag addr:$src2)))]>,
4644 let Defs = [EFLAGS], Predicates = [HasAVX] in {
4645 defm VTESTPS : avx_bittest<0x0E, "vtestps", VR128, f128mem, memopv4f32, v4f32>;
4646 defm VTESTPSY : avx_bittest<0x0E, "vtestps", VR256, f256mem, memopv8f32, v8f32>;
4647 defm VTESTPD : avx_bittest<0x0F, "vtestpd", VR128, f128mem, memopv2f64, v2f64>;
4648 defm VTESTPDY : avx_bittest<0x0F, "vtestpd", VR256, f256mem, memopv4f64, v4f64>;
4651 //===----------------------------------------------------------------------===//
4652 // SSE4.1 - Misc Instructions
4653 //===----------------------------------------------------------------------===//
4655 def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4656 "popcnt{w}\t{$src, $dst|$dst, $src}",
4657 [(set GR16:$dst, (ctpop GR16:$src))]>, OpSize, XS;
4658 def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4659 "popcnt{w}\t{$src, $dst|$dst, $src}",
4660 [(set GR16:$dst, (ctpop (loadi16 addr:$src)))]>, OpSize, XS;
4662 def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4663 "popcnt{l}\t{$src, $dst|$dst, $src}",
4664 [(set GR32:$dst, (ctpop GR32:$src))]>, XS;
4665 def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4666 "popcnt{l}\t{$src, $dst|$dst, $src}",
4667 [(set GR32:$dst, (ctpop (loadi32 addr:$src)))]>, XS;
4669 def POPCNT64rr : RI<0xB8, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4670 "popcnt{q}\t{$src, $dst|$dst, $src}",
4671 [(set GR64:$dst, (ctpop GR64:$src))]>, XS;
4672 def POPCNT64rm : RI<0xB8, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4673 "popcnt{q}\t{$src, $dst|$dst, $src}",
4674 [(set GR64:$dst, (ctpop (loadi64 addr:$src)))]>, XS;
4678 // SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
4679 multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
4680 Intrinsic IntId128> {
4681 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
4683 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
4684 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
4685 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
4687 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
4690 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
4693 let Predicates = [HasAVX] in
4694 defm VPHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "vphminposuw",
4695 int_x86_sse41_phminposuw>, VEX;
4696 defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
4697 int_x86_sse41_phminposuw>;
4699 /// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
4700 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
4701 Intrinsic IntId128, bit Is2Addr = 1> {
4702 let isCommutable = 1 in
4703 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
4704 (ins VR128:$src1, VR128:$src2),
4706 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4707 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4708 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>, OpSize;
4709 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
4710 (ins VR128:$src1, i128mem:$src2),
4712 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4713 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4715 (IntId128 VR128:$src1,
4716 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
4719 let Predicates = [HasAVX] in {
4720 let isCommutable = 0 in
4721 defm VPACKUSDW : SS41I_binop_rm_int<0x2B, "vpackusdw", int_x86_sse41_packusdw,
4723 defm VPCMPEQQ : SS41I_binop_rm_int<0x29, "vpcmpeqq", int_x86_sse41_pcmpeqq,
4725 defm VPMINSB : SS41I_binop_rm_int<0x38, "vpminsb", int_x86_sse41_pminsb,
4727 defm VPMINSD : SS41I_binop_rm_int<0x39, "vpminsd", int_x86_sse41_pminsd,
4729 defm VPMINUD : SS41I_binop_rm_int<0x3B, "vpminud", int_x86_sse41_pminud,
4731 defm VPMINUW : SS41I_binop_rm_int<0x3A, "vpminuw", int_x86_sse41_pminuw,
4733 defm VPMAXSB : SS41I_binop_rm_int<0x3C, "vpmaxsb", int_x86_sse41_pmaxsb,
4735 defm VPMAXSD : SS41I_binop_rm_int<0x3D, "vpmaxsd", int_x86_sse41_pmaxsd,
4737 defm VPMAXUD : SS41I_binop_rm_int<0x3F, "vpmaxud", int_x86_sse41_pmaxud,
4739 defm VPMAXUW : SS41I_binop_rm_int<0x3E, "vpmaxuw", int_x86_sse41_pmaxuw,
4741 defm VPMULDQ : SS41I_binop_rm_int<0x28, "vpmuldq", int_x86_sse41_pmuldq,
4745 let Constraints = "$src1 = $dst" in {
4746 let isCommutable = 0 in
4747 defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw", int_x86_sse41_packusdw>;
4748 defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq", int_x86_sse41_pcmpeqq>;
4749 defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb", int_x86_sse41_pminsb>;
4750 defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd", int_x86_sse41_pminsd>;
4751 defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud", int_x86_sse41_pminud>;
4752 defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw", int_x86_sse41_pminuw>;
4753 defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb", int_x86_sse41_pmaxsb>;
4754 defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd", int_x86_sse41_pmaxsd>;
4755 defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud", int_x86_sse41_pmaxud>;
4756 defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw", int_x86_sse41_pmaxuw>;
4757 defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq>;
4760 def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
4761 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
4762 def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
4763 (PCMPEQQrm VR128:$src1, addr:$src2)>;
4765 /// SS48I_binop_rm - Simple SSE41 binary operator.
4766 multiclass SS48I_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
4767 ValueType OpVT, bit Is2Addr = 1> {
4768 let isCommutable = 1 in
4769 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
4770 (ins VR128:$src1, VR128:$src2),
4772 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4773 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4774 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]>,
4776 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
4777 (ins VR128:$src1, i128mem:$src2),
4779 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4780 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4781 [(set VR128:$dst, (OpNode VR128:$src1,
4782 (bc_v4i32 (memopv2i64 addr:$src2))))]>,
4786 let Predicates = [HasAVX] in
4787 defm VPMULLD : SS48I_binop_rm<0x40, "vpmulld", mul, v4i32, 0>, VEX_4V;
4788 let Constraints = "$src1 = $dst" in
4789 defm PMULLD : SS48I_binop_rm<0x40, "pmulld", mul, v4i32>;
4791 /// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
4792 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
4793 Intrinsic IntId, RegisterClass RC, PatFrag memop_frag,
4794 X86MemOperand x86memop, bit Is2Addr = 1> {
4795 let isCommutable = 1 in
4796 def rri : SS4AIi8<opc, MRMSrcReg, (outs RC:$dst),
4797 (ins RC:$src1, RC:$src2, u32u8imm:$src3),
4799 !strconcat(OpcodeStr,
4800 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4801 !strconcat(OpcodeStr,
4802 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4803 [(set RC:$dst, (IntId RC:$src1, RC:$src2, imm:$src3))]>,
4805 def rmi : SS4AIi8<opc, MRMSrcMem, (outs RC:$dst),
4806 (ins RC:$src1, x86memop:$src2, u32u8imm:$src3),
4808 !strconcat(OpcodeStr,
4809 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
4810 !strconcat(OpcodeStr,
4811 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}")),
4814 (bitconvert (memop_frag addr:$src2)), imm:$src3))]>,
4818 let Predicates = [HasAVX] in {
4819 let isCommutable = 0 in {
4820 defm VBLENDPS : SS41I_binop_rmi_int<0x0C, "vblendps", int_x86_sse41_blendps,
4821 VR128, memopv16i8, i128mem, 0>, VEX_4V;
4822 defm VBLENDPD : SS41I_binop_rmi_int<0x0D, "vblendpd", int_x86_sse41_blendpd,
4823 VR128, memopv16i8, i128mem, 0>, VEX_4V;
4824 defm VBLENDPSY : SS41I_binop_rmi_int<0x0C, "vblendps",
4825 int_x86_avx_blend_ps_256, VR256, memopv32i8, i256mem, 0>, VEX_4V;
4826 defm VBLENDPDY : SS41I_binop_rmi_int<0x0D, "vblendpd",
4827 int_x86_avx_blend_pd_256, VR256, memopv32i8, i256mem, 0>, VEX_4V;
4828 defm VPBLENDW : SS41I_binop_rmi_int<0x0E, "vpblendw", int_x86_sse41_pblendw,
4829 VR128, memopv16i8, i128mem, 0>, VEX_4V;
4830 defm VMPSADBW : SS41I_binop_rmi_int<0x42, "vmpsadbw", int_x86_sse41_mpsadbw,
4831 VR128, memopv16i8, i128mem, 0>, VEX_4V;
4833 defm VDPPS : SS41I_binop_rmi_int<0x40, "vdpps", int_x86_sse41_dpps,
4834 VR128, memopv16i8, i128mem, 0>, VEX_4V;
4835 defm VDPPD : SS41I_binop_rmi_int<0x41, "vdppd", int_x86_sse41_dppd,
4836 VR128, memopv16i8, i128mem, 0>, VEX_4V;
4837 defm VDPPSY : SS41I_binop_rmi_int<0x40, "vdpps", int_x86_avx_dp_ps_256,
4838 VR256, memopv32i8, i256mem, 0>, VEX_4V;
4841 let Constraints = "$src1 = $dst" in {
4842 let isCommutable = 0 in {
4843 defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps", int_x86_sse41_blendps,
4844 VR128, memopv16i8, i128mem>;
4845 defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd", int_x86_sse41_blendpd,
4846 VR128, memopv16i8, i128mem>;
4847 defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw", int_x86_sse41_pblendw,
4848 VR128, memopv16i8, i128mem>;
4849 defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw", int_x86_sse41_mpsadbw,
4850 VR128, memopv16i8, i128mem>;
4852 defm DPPS : SS41I_binop_rmi_int<0x40, "dpps", int_x86_sse41_dpps,
4853 VR128, memopv16i8, i128mem>;
4854 defm DPPD : SS41I_binop_rmi_int<0x41, "dppd", int_x86_sse41_dppd,
4855 VR128, memopv16i8, i128mem>;
4858 /// SS41I_quaternary_int_avx - AVX SSE 4.1 with 4 operators
4859 let Predicates = [HasAVX] in {
4860 multiclass SS41I_quaternary_int_avx<bits<8> opc, string OpcodeStr,
4861 RegisterClass RC, X86MemOperand x86memop,
4862 PatFrag mem_frag, Intrinsic IntId> {
4863 def rr : I<opc, MRMSrcReg, (outs RC:$dst),
4864 (ins RC:$src1, RC:$src2, RC:$src3),
4865 !strconcat(OpcodeStr,
4866 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
4867 [(set RC:$dst, (IntId RC:$src1, RC:$src2, RC:$src3))],
4868 SSEPackedInt>, OpSize, TA, VEX_4V, VEX_I8IMM;
4870 def rm : I<opc, MRMSrcMem, (outs RC:$dst),
4871 (ins RC:$src1, x86memop:$src2, RC:$src3),
4872 !strconcat(OpcodeStr,
4873 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
4875 (IntId RC:$src1, (bitconvert (mem_frag addr:$src2)),
4877 SSEPackedInt>, OpSize, TA, VEX_4V, VEX_I8IMM;
4881 defm VBLENDVPD : SS41I_quaternary_int_avx<0x4B, "vblendvpd", VR128, i128mem,
4882 memopv16i8, int_x86_sse41_blendvpd>;
4883 defm VBLENDVPS : SS41I_quaternary_int_avx<0x4A, "vblendvps", VR128, i128mem,
4884 memopv16i8, int_x86_sse41_blendvps>;
4885 defm VPBLENDVB : SS41I_quaternary_int_avx<0x4C, "vpblendvb", VR128, i128mem,
4886 memopv16i8, int_x86_sse41_pblendvb>;
4887 defm VBLENDVPDY : SS41I_quaternary_int_avx<0x4B, "vblendvpd", VR256, i256mem,
4888 memopv32i8, int_x86_avx_blendv_pd_256>;
4889 defm VBLENDVPSY : SS41I_quaternary_int_avx<0x4A, "vblendvps", VR256, i256mem,
4890 memopv32i8, int_x86_avx_blendv_ps_256>;
4892 /// SS41I_ternary_int - SSE 4.1 ternary operator
4893 let Uses = [XMM0], Constraints = "$src1 = $dst" in {
4894 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
4895 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
4896 (ins VR128:$src1, VR128:$src2),
4897 !strconcat(OpcodeStr,
4898 "\t{$src2, $dst|$dst, $src2}"),
4899 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
4902 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
4903 (ins VR128:$src1, i128mem:$src2),
4904 !strconcat(OpcodeStr,
4905 "\t{$src2, $dst|$dst, $src2}"),
4908 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
4912 defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
4913 defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
4914 defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
4916 def : Pat<(X86pblendv VR128:$src1, VR128:$src2, XMM0),
4917 (PBLENDVBrr0 VR128:$src1, VR128:$src2)>;
4919 let Predicates = [HasAVX] in
4920 def VMOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
4921 "vmovntdqa\t{$src, $dst|$dst, $src}",
4922 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>,
4924 def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
4925 "movntdqa\t{$src, $dst|$dst, $src}",
4926 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>,
4929 //===----------------------------------------------------------------------===//
4930 // SSE4.2 - Compare Instructions
4931 //===----------------------------------------------------------------------===//
4933 /// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
4934 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
4935 Intrinsic IntId128, bit Is2Addr = 1> {
4936 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
4937 (ins VR128:$src1, VR128:$src2),
4939 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4940 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4941 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
4943 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
4944 (ins VR128:$src1, i128mem:$src2),
4946 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
4947 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
4949 (IntId128 VR128:$src1,
4950 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
4953 let Predicates = [HasAVX] in
4954 defm VPCMPGTQ : SS42I_binop_rm_int<0x37, "vpcmpgtq", int_x86_sse42_pcmpgtq,
4956 let Constraints = "$src1 = $dst" in
4957 defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
4959 def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
4960 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
4961 def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
4962 (PCMPGTQrm VR128:$src1, addr:$src2)>;
4964 //===----------------------------------------------------------------------===//
4965 // SSE4.2 - String/text Processing Instructions
4966 //===----------------------------------------------------------------------===//
4968 // Packed Compare Implicit Length Strings, Return Mask
4969 multiclass pseudo_pcmpistrm<string asm> {
4970 def REG : PseudoI<(outs VR128:$dst),
4971 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
4972 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
4974 def MEM : PseudoI<(outs VR128:$dst),
4975 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
4976 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128
4977 VR128:$src1, (load addr:$src2), imm:$src3))]>;
4980 let Defs = [EFLAGS], usesCustomInserter = 1 in {
4981 defm PCMPISTRM128 : pseudo_pcmpistrm<"#PCMPISTRM128">, Requires<[HasSSE42]>;
4982 defm VPCMPISTRM128 : pseudo_pcmpistrm<"#VPCMPISTRM128">, Requires<[HasAVX]>;
4985 let Defs = [XMM0, EFLAGS], Predicates = [HasAVX] in {
4986 def VPCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
4987 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
4988 "vpcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize, VEX;
4989 def VPCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
4990 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
4991 "vpcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize, VEX;
4994 let Defs = [XMM0, EFLAGS] in {
4995 def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
4996 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
4997 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
4998 def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
4999 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
5000 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
5003 // Packed Compare Explicit Length Strings, Return Mask
5004 multiclass pseudo_pcmpestrm<string asm> {
5005 def REG : PseudoI<(outs VR128:$dst),
5006 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
5007 [(set VR128:$dst, (int_x86_sse42_pcmpestrm128
5008 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5))]>;
5009 def MEM : PseudoI<(outs VR128:$dst),
5010 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
5011 [(set VR128:$dst, (int_x86_sse42_pcmpestrm128
5012 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5))]>;
5015 let Defs = [EFLAGS], Uses = [EAX, EDX], usesCustomInserter = 1 in {
5016 defm PCMPESTRM128 : pseudo_pcmpestrm<"#PCMPESTRM128">, Requires<[HasSSE42]>;
5017 defm VPCMPESTRM128 : pseudo_pcmpestrm<"#VPCMPESTRM128">, Requires<[HasAVX]>;
5020 let Predicates = [HasAVX],
5021 Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
5022 def VPCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
5023 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
5024 "vpcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize, VEX;
5025 def VPCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
5026 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
5027 "vpcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize, VEX;
5030 let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
5031 def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
5032 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
5033 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
5034 def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
5035 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
5036 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
5039 // Packed Compare Implicit Length Strings, Return Index
5040 let Defs = [ECX, EFLAGS] in {
5041 multiclass SS42AI_pcmpistri<Intrinsic IntId128, string asm = "pcmpistri"> {
5042 def rr : SS42AI<0x63, MRMSrcReg, (outs),
5043 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
5044 !strconcat(asm, "\t{$src3, $src2, $src1|$src1, $src2, $src3}"),
5045 [(set ECX, (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
5046 (implicit EFLAGS)]>, OpSize;
5047 def rm : SS42AI<0x63, MRMSrcMem, (outs),
5048 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
5049 !strconcat(asm, "\t{$src3, $src2, $src1|$src1, $src2, $src3}"),
5050 [(set ECX, (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
5051 (implicit EFLAGS)]>, OpSize;
5055 let Predicates = [HasAVX] in {
5056 defm VPCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128, "vpcmpistri">,
5058 defm VPCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128, "vpcmpistri">,
5060 defm VPCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128, "vpcmpistri">,
5062 defm VPCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128, "vpcmpistri">,
5064 defm VPCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128, "vpcmpistri">,
5066 defm VPCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128, "vpcmpistri">,
5070 defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
5071 defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
5072 defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
5073 defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
5074 defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
5075 defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
5077 // Packed Compare Explicit Length Strings, Return Index
5078 let Defs = [ECX, EFLAGS], Uses = [EAX, EDX] in {
5079 multiclass SS42AI_pcmpestri<Intrinsic IntId128, string asm = "pcmpestri"> {
5080 def rr : SS42AI<0x61, MRMSrcReg, (outs),
5081 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
5082 !strconcat(asm, "\t{$src5, $src3, $src1|$src1, $src3, $src5}"),
5083 [(set ECX, (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
5084 (implicit EFLAGS)]>, OpSize;
5085 def rm : SS42AI<0x61, MRMSrcMem, (outs),
5086 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
5087 !strconcat(asm, "\t{$src5, $src3, $src1|$src1, $src3, $src5}"),
5089 (IntId128 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5)),
5090 (implicit EFLAGS)]>, OpSize;
5094 let Predicates = [HasAVX] in {
5095 defm VPCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128, "vpcmpestri">,
5097 defm VPCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128, "vpcmpestri">,
5099 defm VPCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128, "vpcmpestri">,
5101 defm VPCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128, "vpcmpestri">,
5103 defm VPCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128, "vpcmpestri">,
5105 defm VPCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128, "vpcmpestri">,
5109 defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
5110 defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
5111 defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
5112 defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
5113 defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
5114 defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;
5116 //===----------------------------------------------------------------------===//
5117 // SSE4.2 - CRC Instructions
5118 //===----------------------------------------------------------------------===//
5120 // No CRC instructions have AVX equivalents
5122 // crc intrinsic instruction
5123 // This set of instructions are only rm, the only difference is the size
5125 let Constraints = "$src1 = $dst" in {
5126 def CRC32r32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
5127 (ins GR32:$src1, i8mem:$src2),
5128 "crc32{b} \t{$src2, $src1|$src1, $src2}",
5130 (int_x86_sse42_crc32_32_8 GR32:$src1,
5131 (load addr:$src2)))]>;
5132 def CRC32r32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
5133 (ins GR32:$src1, GR8:$src2),
5134 "crc32{b} \t{$src2, $src1|$src1, $src2}",
5136 (int_x86_sse42_crc32_32_8 GR32:$src1, GR8:$src2))]>;
5137 def CRC32r32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
5138 (ins GR32:$src1, i16mem:$src2),
5139 "crc32{w} \t{$src2, $src1|$src1, $src2}",
5141 (int_x86_sse42_crc32_32_16 GR32:$src1,
5142 (load addr:$src2)))]>,
5144 def CRC32r32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
5145 (ins GR32:$src1, GR16:$src2),
5146 "crc32{w} \t{$src2, $src1|$src1, $src2}",
5148 (int_x86_sse42_crc32_32_16 GR32:$src1, GR16:$src2))]>,
5150 def CRC32r32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
5151 (ins GR32:$src1, i32mem:$src2),
5152 "crc32{l} \t{$src2, $src1|$src1, $src2}",
5154 (int_x86_sse42_crc32_32_32 GR32:$src1,
5155 (load addr:$src2)))]>;
5156 def CRC32r32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
5157 (ins GR32:$src1, GR32:$src2),
5158 "crc32{l} \t{$src2, $src1|$src1, $src2}",
5160 (int_x86_sse42_crc32_32_32 GR32:$src1, GR32:$src2))]>;
5161 def CRC32r64m8 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
5162 (ins GR64:$src1, i8mem:$src2),
5163 "crc32{b} \t{$src2, $src1|$src1, $src2}",
5165 (int_x86_sse42_crc32_64_8 GR64:$src1,
5166 (load addr:$src2)))]>,
5168 def CRC32r64r8 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
5169 (ins GR64:$src1, GR8:$src2),
5170 "crc32{b} \t{$src2, $src1|$src1, $src2}",
5172 (int_x86_sse42_crc32_64_8 GR64:$src1, GR8:$src2))]>,
5174 def CRC32r64m64 : SS42FI<0xF1, MRMSrcMem, (outs GR64:$dst),
5175 (ins GR64:$src1, i64mem:$src2),
5176 "crc32{q} \t{$src2, $src1|$src1, $src2}",
5178 (int_x86_sse42_crc32_64_64 GR64:$src1,
5179 (load addr:$src2)))]>,
5181 def CRC32r64r64 : SS42FI<0xF1, MRMSrcReg, (outs GR64:$dst),
5182 (ins GR64:$src1, GR64:$src2),
5183 "crc32{q} \t{$src2, $src1|$src1, $src2}",
5185 (int_x86_sse42_crc32_64_64 GR64:$src1, GR64:$src2))]>,
5189 //===----------------------------------------------------------------------===//
5190 // AES-NI Instructions
5191 //===----------------------------------------------------------------------===//
5193 multiclass AESI_binop_rm_int<bits<8> opc, string OpcodeStr,
5194 Intrinsic IntId128, bit Is2Addr = 1> {
5195 def rr : AES8I<opc, MRMSrcReg, (outs VR128:$dst),
5196 (ins VR128:$src1, VR128:$src2),
5198 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
5199 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
5200 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
5202 def rm : AES8I<opc, MRMSrcMem, (outs VR128:$dst),
5203 (ins VR128:$src1, i128mem:$src2),
5205 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
5206 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
5208 (IntId128 VR128:$src1,
5209 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
5212 // Perform One Round of an AES Encryption/Decryption Flow
5213 let Predicates = [HasAVX, HasAES] in {
5214 defm VAESENC : AESI_binop_rm_int<0xDC, "vaesenc",
5215 int_x86_aesni_aesenc, 0>, VEX_4V;
5216 defm VAESENCLAST : AESI_binop_rm_int<0xDD, "vaesenclast",
5217 int_x86_aesni_aesenclast, 0>, VEX_4V;
5218 defm VAESDEC : AESI_binop_rm_int<0xDE, "vaesdec",
5219 int_x86_aesni_aesdec, 0>, VEX_4V;
5220 defm VAESDECLAST : AESI_binop_rm_int<0xDF, "vaesdeclast",
5221 int_x86_aesni_aesdeclast, 0>, VEX_4V;
5224 let Constraints = "$src1 = $dst" in {
5225 defm AESENC : AESI_binop_rm_int<0xDC, "aesenc",
5226 int_x86_aesni_aesenc>;
5227 defm AESENCLAST : AESI_binop_rm_int<0xDD, "aesenclast",
5228 int_x86_aesni_aesenclast>;
5229 defm AESDEC : AESI_binop_rm_int<0xDE, "aesdec",
5230 int_x86_aesni_aesdec>;
5231 defm AESDECLAST : AESI_binop_rm_int<0xDF, "aesdeclast",
5232 int_x86_aesni_aesdeclast>;
5235 def : Pat<(v2i64 (int_x86_aesni_aesenc VR128:$src1, VR128:$src2)),
5236 (AESENCrr VR128:$src1, VR128:$src2)>;
5237 def : Pat<(v2i64 (int_x86_aesni_aesenc VR128:$src1, (memop addr:$src2))),
5238 (AESENCrm VR128:$src1, addr:$src2)>;
5239 def : Pat<(v2i64 (int_x86_aesni_aesenclast VR128:$src1, VR128:$src2)),
5240 (AESENCLASTrr VR128:$src1, VR128:$src2)>;
5241 def : Pat<(v2i64 (int_x86_aesni_aesenclast VR128:$src1, (memop addr:$src2))),
5242 (AESENCLASTrm VR128:$src1, addr:$src2)>;
5243 def : Pat<(v2i64 (int_x86_aesni_aesdec VR128:$src1, VR128:$src2)),
5244 (AESDECrr VR128:$src1, VR128:$src2)>;
5245 def : Pat<(v2i64 (int_x86_aesni_aesdec VR128:$src1, (memop addr:$src2))),
5246 (AESDECrm VR128:$src1, addr:$src2)>;
5247 def : Pat<(v2i64 (int_x86_aesni_aesdeclast VR128:$src1, VR128:$src2)),
5248 (AESDECLASTrr VR128:$src1, VR128:$src2)>;
5249 def : Pat<(v2i64 (int_x86_aesni_aesdeclast VR128:$src1, (memop addr:$src2))),
5250 (AESDECLASTrm VR128:$src1, addr:$src2)>;
5252 // Perform the AES InvMixColumn Transformation
5253 let Predicates = [HasAVX, HasAES] in {
5254 def VAESIMCrr : AES8I<0xDB, MRMSrcReg, (outs VR128:$dst),
5256 "vaesimc\t{$src1, $dst|$dst, $src1}",
5258 (int_x86_aesni_aesimc VR128:$src1))]>,
5260 def VAESIMCrm : AES8I<0xDB, MRMSrcMem, (outs VR128:$dst),
5261 (ins i128mem:$src1),
5262 "vaesimc\t{$src1, $dst|$dst, $src1}",
5264 (int_x86_aesni_aesimc (bitconvert (memopv2i64 addr:$src1))))]>,
5267 def AESIMCrr : AES8I<0xDB, MRMSrcReg, (outs VR128:$dst),
5269 "aesimc\t{$src1, $dst|$dst, $src1}",
5271 (int_x86_aesni_aesimc VR128:$src1))]>,
5273 def AESIMCrm : AES8I<0xDB, MRMSrcMem, (outs VR128:$dst),
5274 (ins i128mem:$src1),
5275 "aesimc\t{$src1, $dst|$dst, $src1}",
5277 (int_x86_aesni_aesimc (bitconvert (memopv2i64 addr:$src1))))]>,
5280 // AES Round Key Generation Assist
5281 let Predicates = [HasAVX, HasAES] in {
5282 def VAESKEYGENASSIST128rr : AESAI<0xDF, MRMSrcReg, (outs VR128:$dst),
5283 (ins VR128:$src1, i8imm:$src2),
5284 "vaeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}",
5286 (int_x86_aesni_aeskeygenassist VR128:$src1, imm:$src2))]>,
5288 def VAESKEYGENASSIST128rm : AESAI<0xDF, MRMSrcMem, (outs VR128:$dst),
5289 (ins i128mem:$src1, i8imm:$src2),
5290 "vaeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}",
5292 (int_x86_aesni_aeskeygenassist (bitconvert (memopv2i64 addr:$src1)),
5296 def AESKEYGENASSIST128rr : AESAI<0xDF, MRMSrcReg, (outs VR128:$dst),
5297 (ins VR128:$src1, i8imm:$src2),
5298 "aeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}",
5300 (int_x86_aesni_aeskeygenassist VR128:$src1, imm:$src2))]>,
5302 def AESKEYGENASSIST128rm : AESAI<0xDF, MRMSrcMem, (outs VR128:$dst),
5303 (ins i128mem:$src1, i8imm:$src2),
5304 "aeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}",
5306 (int_x86_aesni_aeskeygenassist (bitconvert (memopv2i64 addr:$src1)),
5310 //===----------------------------------------------------------------------===//
5311 // CLMUL Instructions
5312 //===----------------------------------------------------------------------===//
5314 // Carry-less Multiplication instructions
5315 let Constraints = "$src1 = $dst" in {
5316 def PCLMULQDQrr : CLMULIi8<0x44, MRMSrcReg, (outs VR128:$dst),
5317 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
5318 "pclmulqdq\t{$src3, $src2, $dst|$dst, $src2, $src3}",
5321 def PCLMULQDQrm : CLMULIi8<0x44, MRMSrcMem, (outs VR128:$dst),
5322 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
5323 "pclmulqdq\t{$src3, $src2, $dst|$dst, $src2, $src3}",
5327 // AVX carry-less Multiplication instructions
5328 def VPCLMULQDQrr : AVXCLMULIi8<0x44, MRMSrcReg, (outs VR128:$dst),
5329 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
5330 "vpclmulqdq\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}",
5333 def VPCLMULQDQrm : AVXCLMULIi8<0x44, MRMSrcMem, (outs VR128:$dst),
5334 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
5335 "vpclmulqdq\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}",
5339 multiclass pclmul_alias<string asm, int immop> {
5340 def : InstAlias<!strconcat("pclmul", asm,
5341 "dq {$src, $dst|$dst, $src}"),
5342 (PCLMULQDQrr VR128:$dst, VR128:$src, immop)>;
5344 def : InstAlias<!strconcat("pclmul", asm,
5345 "dq {$src, $dst|$dst, $src}"),
5346 (PCLMULQDQrm VR128:$dst, i128mem:$src, immop)>;
5348 def : InstAlias<!strconcat("vpclmul", asm,
5349 "dq {$src2, $src1, $dst|$dst, $src1, $src2}"),
5350 (VPCLMULQDQrr VR128:$dst, VR128:$src1, VR128:$src2, immop)>;
5352 def : InstAlias<!strconcat("vpclmul", asm,
5353 "dq {$src2, $src1, $dst|$dst, $src1, $src2}"),
5354 (VPCLMULQDQrm VR128:$dst, VR128:$src1, i128mem:$src2, immop)>;
5356 defm : pclmul_alias<"hqhq", 0x11>;
5357 defm : pclmul_alias<"hqlq", 0x01>;
5358 defm : pclmul_alias<"lqhq", 0x10>;
5359 defm : pclmul_alias<"lqlq", 0x00>;
5361 //===----------------------------------------------------------------------===//
5363 //===----------------------------------------------------------------------===//
5365 //===----------------------------------------------------------------------===//
5366 // VBROADCAST - Load from memory and broadcast to all elements of the
5367 // destination operand
5369 class avx_broadcast<bits<8> opc, string OpcodeStr, RegisterClass RC,
5370 X86MemOperand x86memop, Intrinsic Int> :
5371 AVX8I<opc, MRMSrcMem, (outs RC:$dst), (ins x86memop:$src),
5372 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
5373 [(set RC:$dst, (Int addr:$src))]>, VEX;
5375 def VBROADCASTSS : avx_broadcast<0x18, "vbroadcastss", VR128, f32mem,
5376 int_x86_avx_vbroadcastss>;
5377 def VBROADCASTSSY : avx_broadcast<0x18, "vbroadcastss", VR256, f32mem,
5378 int_x86_avx_vbroadcastss_256>;
5379 def VBROADCASTSD : avx_broadcast<0x19, "vbroadcastsd", VR256, f64mem,
5380 int_x86_avx_vbroadcast_sd_256>;
5381 def VBROADCASTF128 : avx_broadcast<0x1A, "vbroadcastf128", VR256, f128mem,
5382 int_x86_avx_vbroadcastf128_pd_256>;
5384 def : Pat<(int_x86_avx_vbroadcastf128_ps_256 addr:$src),
5385 (VBROADCASTF128 addr:$src)>;
5387 //===----------------------------------------------------------------------===//
5388 // VINSERTF128 - Insert packed floating-point values
5390 def VINSERTF128rr : AVXAIi8<0x18, MRMSrcReg, (outs VR256:$dst),
5391 (ins VR256:$src1, VR128:$src2, i8imm:$src3),
5392 "vinsertf128\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}",
5394 def VINSERTF128rm : AVXAIi8<0x18, MRMSrcMem, (outs VR256:$dst),
5395 (ins VR256:$src1, f128mem:$src2, i8imm:$src3),
5396 "vinsertf128\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}",
5399 def : Pat<(int_x86_avx_vinsertf128_pd_256 VR256:$src1, VR128:$src2, imm:$src3),
5400 (VINSERTF128rr VR256:$src1, VR128:$src2, imm:$src3)>;
5401 def : Pat<(int_x86_avx_vinsertf128_ps_256 VR256:$src1, VR128:$src2, imm:$src3),
5402 (VINSERTF128rr VR256:$src1, VR128:$src2, imm:$src3)>;
5403 def : Pat<(int_x86_avx_vinsertf128_si_256 VR256:$src1, VR128:$src2, imm:$src3),
5404 (VINSERTF128rr VR256:$src1, VR128:$src2, imm:$src3)>;
5406 def : Pat<(vinsertf128_insert:$ins (v8f32 VR256:$src1), (v4f32 VR128:$src2),
5408 (VINSERTF128rr VR256:$src1, VR128:$src2,
5409 (INSERT_get_vinsertf128_imm VR256:$ins))>;
5410 def : Pat<(vinsertf128_insert:$ins (v4f64 VR256:$src1), (v2f64 VR128:$src2),
5412 (VINSERTF128rr VR256:$src1, VR128:$src2,
5413 (INSERT_get_vinsertf128_imm VR256:$ins))>;
5414 def : Pat<(vinsertf128_insert:$ins (v8i32 VR256:$src1), (v4i32 VR128:$src2),
5416 (VINSERTF128rr VR256:$src1, VR128:$src2,
5417 (INSERT_get_vinsertf128_imm VR256:$ins))>;
5418 def : Pat<(vinsertf128_insert:$ins (v4i64 VR256:$src1), (v2i64 VR128:$src2),
5420 (VINSERTF128rr VR256:$src1, VR128:$src2,
5421 (INSERT_get_vinsertf128_imm VR256:$ins))>;
5422 def : Pat<(vinsertf128_insert:$ins (v32i8 VR256:$src1), (v16i8 VR128:$src2),
5424 (VINSERTF128rr VR256:$src1, VR128:$src2,
5425 (INSERT_get_vinsertf128_imm VR256:$ins))>;
5426 def : Pat<(vinsertf128_insert:$ins (v16i16 VR256:$src1), (v8i16 VR128:$src2),
5428 (VINSERTF128rr VR256:$src1, VR128:$src2,
5429 (INSERT_get_vinsertf128_imm VR256:$ins))>;
5431 // Special COPY patterns
5432 def : Pat<(insert_subvector undef, (v2i64 VR128:$src), (i32 0)),
5433 (INSERT_SUBREG (v4i64 (IMPLICIT_DEF)), VR128:$src, sub_xmm)>;
5434 def : Pat<(insert_subvector undef, (v2f64 VR128:$src), (i32 0)),
5435 (INSERT_SUBREG (v4f64 (IMPLICIT_DEF)), VR128:$src, sub_xmm)>;
5436 def : Pat<(insert_subvector undef, (v4i32 VR128:$src), (i32 0)),
5437 (INSERT_SUBREG (v8i32 (IMPLICIT_DEF)), VR128:$src, sub_xmm)>;
5438 def : Pat<(insert_subvector undef, (v4f32 VR128:$src), (i32 0)),
5439 (INSERT_SUBREG (v8f32 (IMPLICIT_DEF)), VR128:$src, sub_xmm)>;
5440 def : Pat<(insert_subvector undef, (v8i16 VR128:$src), (i32 0)),
5441 (INSERT_SUBREG (v16i16 (IMPLICIT_DEF)), VR128:$src, sub_xmm)>;
5442 def : Pat<(insert_subvector undef, (v16i8 VR128:$src), (i32 0)),
5443 (INSERT_SUBREG (v32i8 (IMPLICIT_DEF)), VR128:$src, sub_xmm)>;
5445 //===----------------------------------------------------------------------===//
5446 // VEXTRACTF128 - Extract packed floating-point values
5448 def VEXTRACTF128rr : AVXAIi8<0x19, MRMDestReg, (outs VR128:$dst),
5449 (ins VR256:$src1, i8imm:$src2),
5450 "vextractf128\t{$src2, $src1, $dst|$dst, $src1, $src2}",
5452 def VEXTRACTF128mr : AVXAIi8<0x19, MRMDestMem, (outs),
5453 (ins f128mem:$dst, VR256:$src1, i8imm:$src2),
5454 "vextractf128\t{$src2, $src1, $dst|$dst, $src1, $src2}",
5457 def : Pat<(int_x86_avx_vextractf128_pd_256 VR256:$src1, imm:$src2),
5458 (VEXTRACTF128rr VR256:$src1, imm:$src2)>;
5459 def : Pat<(int_x86_avx_vextractf128_ps_256 VR256:$src1, imm:$src2),
5460 (VEXTRACTF128rr VR256:$src1, imm:$src2)>;
5461 def : Pat<(int_x86_avx_vextractf128_si_256 VR256:$src1, imm:$src2),
5462 (VEXTRACTF128rr VR256:$src1, imm:$src2)>;
5464 def : Pat<(vextractf128_extract:$ext VR256:$src1, (i32 imm)),
5465 (v4f32 (VEXTRACTF128rr
5466 (v8f32 VR256:$src1),
5467 (EXTRACT_get_vextractf128_imm VR128:$ext)))>;
5468 def : Pat<(vextractf128_extract:$ext VR256:$src1, (i32 imm)),
5469 (v2f64 (VEXTRACTF128rr
5470 (v4f64 VR256:$src1),
5471 (EXTRACT_get_vextractf128_imm VR128:$ext)))>;
5472 def : Pat<(vextractf128_extract:$ext VR256:$src1, (i32 imm)),
5473 (v4i32 (VEXTRACTF128rr
5474 (v8i32 VR256:$src1),
5475 (EXTRACT_get_vextractf128_imm VR128:$ext)))>;
5476 def : Pat<(vextractf128_extract:$ext VR256:$src1, (i32 imm)),
5477 (v2i64 (VEXTRACTF128rr
5478 (v4i64 VR256:$src1),
5479 (EXTRACT_get_vextractf128_imm VR128:$ext)))>;
5480 def : Pat<(vextractf128_extract:$ext VR256:$src1, (i32 imm)),
5481 (v8i16 (VEXTRACTF128rr
5482 (v16i16 VR256:$src1),
5483 (EXTRACT_get_vextractf128_imm VR128:$ext)))>;
5484 def : Pat<(vextractf128_extract:$ext VR256:$src1, (i32 imm)),
5485 (v16i8 (VEXTRACTF128rr
5486 (v32i8 VR256:$src1),
5487 (EXTRACT_get_vextractf128_imm VR128:$ext)))>;
5489 // Special COPY patterns
5490 def : Pat<(v4i32 (extract_subvector (v8i32 VR256:$src), (i32 0))),
5491 (v4i32 (EXTRACT_SUBREG (v8i32 VR256:$src), sub_xmm))>;
5492 def : Pat<(v4f32 (extract_subvector (v8f32 VR256:$src), (i32 0))),
5493 (v4f32 (EXTRACT_SUBREG (v8f32 VR256:$src), sub_xmm))>;
5495 def : Pat<(v2i64 (extract_subvector (v4i64 VR256:$src), (i32 0))),
5496 (v2i64 (EXTRACT_SUBREG (v4i64 VR256:$src), sub_xmm))>;
5497 def : Pat<(v2f64 (extract_subvector (v4f64 VR256:$src), (i32 0))),
5498 (v2f64 (EXTRACT_SUBREG (v4f64 VR256:$src), sub_xmm))>;
5501 //===----------------------------------------------------------------------===//
5502 // VMASKMOV - Conditional SIMD Packed Loads and Stores
5504 multiclass avx_movmask_rm<bits<8> opc_rm, bits<8> opc_mr, string OpcodeStr,
5505 Intrinsic IntLd, Intrinsic IntLd256,
5506 Intrinsic IntSt, Intrinsic IntSt256,
5507 PatFrag pf128, PatFrag pf256> {
5508 def rm : AVX8I<opc_rm, MRMSrcMem, (outs VR128:$dst),
5509 (ins VR128:$src1, f128mem:$src2),
5510 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
5511 [(set VR128:$dst, (IntLd addr:$src2, VR128:$src1))]>,
5513 def Yrm : AVX8I<opc_rm, MRMSrcMem, (outs VR256:$dst),
5514 (ins VR256:$src1, f256mem:$src2),
5515 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
5516 [(set VR256:$dst, (IntLd256 addr:$src2, VR256:$src1))]>,
5518 def mr : AVX8I<opc_mr, MRMDestMem, (outs),
5519 (ins f128mem:$dst, VR128:$src1, VR128:$src2),
5520 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
5521 [(IntSt addr:$dst, VR128:$src1, VR128:$src2)]>, VEX_4V;
5522 def Ymr : AVX8I<opc_mr, MRMDestMem, (outs),
5523 (ins f256mem:$dst, VR256:$src1, VR256:$src2),
5524 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
5525 [(IntSt256 addr:$dst, VR256:$src1, VR256:$src2)]>, VEX_4V;
5528 defm VMASKMOVPS : avx_movmask_rm<0x2C, 0x2E, "vmaskmovps",
5529 int_x86_avx_maskload_ps,
5530 int_x86_avx_maskload_ps_256,
5531 int_x86_avx_maskstore_ps,
5532 int_x86_avx_maskstore_ps_256,
5533 memopv4f32, memopv8f32>;
5534 defm VMASKMOVPD : avx_movmask_rm<0x2D, 0x2F, "vmaskmovpd",
5535 int_x86_avx_maskload_pd,
5536 int_x86_avx_maskload_pd_256,
5537 int_x86_avx_maskstore_pd,
5538 int_x86_avx_maskstore_pd_256,
5539 memopv2f64, memopv4f64>;
5541 //===----------------------------------------------------------------------===//
5542 // VPERM - Permute Floating-Point Values
5544 multiclass avx_permil<bits<8> opc_rm, bits<8> opc_rmi, string OpcodeStr,
5545 RegisterClass RC, X86MemOperand x86memop_f,
5546 X86MemOperand x86memop_i, PatFrag f_frag, PatFrag i_frag,
5547 Intrinsic IntVar, Intrinsic IntImm> {
5548 def rr : AVX8I<opc_rm, MRMSrcReg, (outs RC:$dst),
5549 (ins RC:$src1, RC:$src2),
5550 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
5551 [(set RC:$dst, (IntVar RC:$src1, RC:$src2))]>, VEX_4V;
5552 def rm : AVX8I<opc_rm, MRMSrcMem, (outs RC:$dst),
5553 (ins RC:$src1, x86memop_i:$src2),
5554 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
5555 [(set RC:$dst, (IntVar RC:$src1, (i_frag addr:$src2)))]>, VEX_4V;
5557 def ri : AVXAIi8<opc_rmi, MRMSrcReg, (outs RC:$dst),
5558 (ins RC:$src1, i8imm:$src2),
5559 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
5560 [(set RC:$dst, (IntImm RC:$src1, imm:$src2))]>, VEX;
5561 def mi : AVXAIi8<opc_rmi, MRMSrcMem, (outs RC:$dst),
5562 (ins x86memop_f:$src1, i8imm:$src2),
5563 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
5564 [(set RC:$dst, (IntImm (f_frag addr:$src1), imm:$src2))]>, VEX;
5567 defm VPERMILPS : avx_permil<0x0C, 0x04, "vpermilps", VR128, f128mem, i128mem,
5568 memopv4f32, memopv4i32,
5569 int_x86_avx_vpermilvar_ps,
5570 int_x86_avx_vpermil_ps>;
5571 defm VPERMILPSY : avx_permil<0x0C, 0x04, "vpermilps", VR256, f256mem, i256mem,
5572 memopv8f32, memopv8i32,
5573 int_x86_avx_vpermilvar_ps_256,
5574 int_x86_avx_vpermil_ps_256>;
5575 defm VPERMILPD : avx_permil<0x0D, 0x05, "vpermilpd", VR128, f128mem, i128mem,
5576 memopv2f64, memopv2i64,
5577 int_x86_avx_vpermilvar_pd,
5578 int_x86_avx_vpermil_pd>;
5579 defm VPERMILPDY : avx_permil<0x0D, 0x05, "vpermilpd", VR256, f256mem, i256mem,
5580 memopv4f64, memopv4i64,
5581 int_x86_avx_vpermilvar_pd_256,
5582 int_x86_avx_vpermil_pd_256>;
5584 def VPERM2F128rr : AVXAIi8<0x06, MRMSrcReg, (outs VR256:$dst),
5585 (ins VR256:$src1, VR256:$src2, i8imm:$src3),
5586 "vperm2f128\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}",
5588 def VPERM2F128rm : AVXAIi8<0x06, MRMSrcMem, (outs VR256:$dst),
5589 (ins VR256:$src1, f256mem:$src2, i8imm:$src3),
5590 "vperm2f128\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}",
5593 def : Pat<(int_x86_avx_vperm2f128_ps_256 VR256:$src1, VR256:$src2, imm:$src3),
5594 (VPERM2F128rr VR256:$src1, VR256:$src2, imm:$src3)>;
5595 def : Pat<(int_x86_avx_vperm2f128_pd_256 VR256:$src1, VR256:$src2, imm:$src3),
5596 (VPERM2F128rr VR256:$src1, VR256:$src2, imm:$src3)>;
5597 def : Pat<(int_x86_avx_vperm2f128_si_256 VR256:$src1, VR256:$src2, imm:$src3),
5598 (VPERM2F128rr VR256:$src1, VR256:$src2, imm:$src3)>;
5600 def : Pat<(int_x86_avx_vperm2f128_ps_256
5601 VR256:$src1, (memopv8f32 addr:$src2), imm:$src3),
5602 (VPERM2F128rm VR256:$src1, addr:$src2, imm:$src3)>;
5603 def : Pat<(int_x86_avx_vperm2f128_pd_256
5604 VR256:$src1, (memopv4f64 addr:$src2), imm:$src3),
5605 (VPERM2F128rm VR256:$src1, addr:$src2, imm:$src3)>;
5606 def : Pat<(int_x86_avx_vperm2f128_si_256
5607 VR256:$src1, (memopv8i32 addr:$src2), imm:$src3),
5608 (VPERM2F128rm VR256:$src1, addr:$src2, imm:$src3)>;
5610 // Shuffle with VPERMIL instructions
5611 def : Pat<(v8f32 (X86VPermilpsy VR256:$src1, (i8 imm:$imm))),
5612 (VPERMILPSYri VR256:$src1, imm:$imm)>;
5613 def : Pat<(v4f64 (X86VPermilpdy VR256:$src1, (i8 imm:$imm))),
5614 (VPERMILPDYri VR256:$src1, imm:$imm)>;
5615 def : Pat<(v8i32 (X86VPermilpsy VR256:$src1, (i8 imm:$imm))),
5616 (VPERMILPSYri VR256:$src1, imm:$imm)>;
5617 def : Pat<(v4i64 (X86VPermilpdy VR256:$src1, (i8 imm:$imm))),
5618 (VPERMILPDYri VR256:$src1, imm:$imm)>;
5620 //===----------------------------------------------------------------------===//
5621 // VZERO - Zero YMM registers
5623 // Zero All YMM registers
5624 def VZEROALL : I<0x77, RawFrm, (outs), (ins), "vzeroall",
5625 [(int_x86_avx_vzeroall)]>, VEX, VEX_L, Requires<[HasAVX]>;
5627 // Zero Upper bits of YMM registers
5628 def VZEROUPPER : I<0x77, RawFrm, (outs), (ins), "vzeroupper",
5629 [(int_x86_avx_vzeroupper)]>, VEX, Requires<[HasAVX]>;
5631 //===----------------------------------------------------------------------===//
5632 // SSE Shuffle pattern fragments
5633 //===----------------------------------------------------------------------===//
5635 // This is part of a "work in progress" refactoring. The idea is that all
5636 // vector shuffles are going to be translated into target specific nodes and
5637 // directly matched by the patterns below (which can be changed along the way)
5638 // The AVX version of some but not all of them are described here, and more
5639 // should come in a near future.
5641 // Shuffle with PSHUFD instruction folding loads. The first two patterns match
5642 // SSE2 loads, which are always promoted to v2i64. The last one should match
5643 // the SSE1 case, where the only legal load is v4f32, but there is no PSHUFD
5644 // in SSE2, how does it ever worked? Anyway, the pattern will remain here until
5645 // we investigate further.
5646 def : Pat<(v4i32 (X86PShufd (bc_v4i32 (memopv2i64 addr:$src1)),
5648 (VPSHUFDmi addr:$src1, imm:$imm)>, Requires<[HasAVX]>;
5649 def : Pat<(v4i32 (X86PShufd (bc_v4i32 (memopv2i64 addr:$src1)),
5651 (PSHUFDmi addr:$src1, imm:$imm)>;
5652 def : Pat<(v4i32 (X86PShufd (bc_v4i32 (memopv4f32 addr:$src1)),
5654 (PSHUFDmi addr:$src1, imm:$imm)>; // FIXME: has this ever worked?
5656 // Shuffle with PSHUFD instruction.
5657 def : Pat<(v4f32 (X86PShufd VR128:$src1, (i8 imm:$imm))),
5658 (VPSHUFDri VR128:$src1, imm:$imm)>, Requires<[HasAVX]>;
5659 def : Pat<(v4f32 (X86PShufd VR128:$src1, (i8 imm:$imm))),
5660 (PSHUFDri VR128:$src1, imm:$imm)>;
5662 def : Pat<(v4i32 (X86PShufd VR128:$src1, (i8 imm:$imm))),
5663 (VPSHUFDri VR128:$src1, imm:$imm)>, Requires<[HasAVX]>;
5664 def : Pat<(v4i32 (X86PShufd VR128:$src1, (i8 imm:$imm))),
5665 (PSHUFDri VR128:$src1, imm:$imm)>;
5667 // Shuffle with SHUFPD instruction.
5668 def : Pat<(v2f64 (X86Shufps VR128:$src1,
5669 (memopv2f64 addr:$src2), (i8 imm:$imm))),
5670 (VSHUFPDrmi VR128:$src1, addr:$src2, imm:$imm)>, Requires<[HasAVX]>;
5671 def : Pat<(v2f64 (X86Shufps VR128:$src1,
5672 (memopv2f64 addr:$src2), (i8 imm:$imm))),
5673 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$imm)>;
5675 def : Pat<(v2i64 (X86Shufpd VR128:$src1, VR128:$src2, (i8 imm:$imm))),
5676 (VSHUFPDrri VR128:$src1, VR128:$src2, imm:$imm)>, Requires<[HasAVX]>;
5677 def : Pat<(v2i64 (X86Shufpd VR128:$src1, VR128:$src2, (i8 imm:$imm))),
5678 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$imm)>;
5680 def : Pat<(v2f64 (X86Shufpd VR128:$src1, VR128:$src2, (i8 imm:$imm))),
5681 (VSHUFPDrri VR128:$src1, VR128:$src2, imm:$imm)>, Requires<[HasAVX]>;
5682 def : Pat<(v2f64 (X86Shufpd VR128:$src1, VR128:$src2, (i8 imm:$imm))),
5683 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$imm)>;
5685 // Shuffle with SHUFPS instruction.
5686 def : Pat<(v4f32 (X86Shufps VR128:$src1,
5687 (memopv4f32 addr:$src2), (i8 imm:$imm))),
5688 (VSHUFPSrmi VR128:$src1, addr:$src2, imm:$imm)>, Requires<[HasAVX]>;
5689 def : Pat<(v4f32 (X86Shufps VR128:$src1,
5690 (memopv4f32 addr:$src2), (i8 imm:$imm))),
5691 (SHUFPSrmi VR128:$src1, addr:$src2, imm:$imm)>;
5693 def : Pat<(v4f32 (X86Shufps VR128:$src1, VR128:$src2, (i8 imm:$imm))),
5694 (VSHUFPSrri VR128:$src1, VR128:$src2, imm:$imm)>, Requires<[HasAVX]>;
5695 def : Pat<(v4f32 (X86Shufps VR128:$src1, VR128:$src2, (i8 imm:$imm))),
5696 (SHUFPSrri VR128:$src1, VR128:$src2, imm:$imm)>;
5698 def : Pat<(v4i32 (X86Shufps VR128:$src1,
5699 (bc_v4i32 (memopv2i64 addr:$src2)), (i8 imm:$imm))),
5700 (VSHUFPSrmi VR128:$src1, addr:$src2, imm:$imm)>, Requires<[HasAVX]>;
5701 def : Pat<(v4i32 (X86Shufps VR128:$src1,
5702 (bc_v4i32 (memopv2i64 addr:$src2)), (i8 imm:$imm))),
5703 (SHUFPSrmi VR128:$src1, addr:$src2, imm:$imm)>;
5705 def : Pat<(v4i32 (X86Shufps VR128:$src1, VR128:$src2, (i8 imm:$imm))),
5706 (VSHUFPSrri VR128:$src1, VR128:$src2, imm:$imm)>, Requires<[HasAVX]>;
5707 def : Pat<(v4i32 (X86Shufps VR128:$src1, VR128:$src2, (i8 imm:$imm))),
5708 (SHUFPSrri VR128:$src1, VR128:$src2, imm:$imm)>;
5710 // Shuffle with MOVHLPS instruction
5711 def : Pat<(v4f32 (X86Movhlps VR128:$src1, VR128:$src2)),
5712 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
5713 def : Pat<(v4i32 (X86Movhlps VR128:$src1, VR128:$src2)),
5714 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
5716 // Shuffle with MOVDDUP instruction
5717 def : Pat<(X86Movddup (memopv2f64 addr:$src)),
5718 (VMOVDDUPrm addr:$src)>, Requires<[HasAVX]>;
5719 def : Pat<(X86Movddup (memopv2f64 addr:$src)),
5720 (MOVDDUPrm addr:$src)>;
5722 def : Pat<(X86Movddup (bc_v2f64 (memopv4f32 addr:$src))),
5723 (VMOVDDUPrm addr:$src)>, Requires<[HasAVX]>;
5724 def : Pat<(X86Movddup (bc_v2f64 (memopv4f32 addr:$src))),
5725 (MOVDDUPrm addr:$src)>;
5727 def : Pat<(X86Movddup (bc_v2f64 (memopv2i64 addr:$src))),
5728 (VMOVDDUPrm addr:$src)>, Requires<[HasAVX]>;
5729 def : Pat<(X86Movddup (bc_v2f64 (memopv2i64 addr:$src))),
5730 (MOVDDUPrm addr:$src)>;
5732 def : Pat<(X86Movddup (v2f64 (scalar_to_vector (loadf64 addr:$src)))),
5733 (VMOVDDUPrm addr:$src)>, Requires<[HasAVX]>;
5734 def : Pat<(X86Movddup (v2f64 (scalar_to_vector (loadf64 addr:$src)))),
5735 (MOVDDUPrm addr:$src)>;
5737 def : Pat<(X86Movddup (bc_v2f64
5738 (v2i64 (scalar_to_vector (loadi64 addr:$src))))),
5739 (VMOVDDUPrm addr:$src)>, Requires<[HasAVX]>;
5740 def : Pat<(X86Movddup (bc_v2f64
5741 (v2i64 (scalar_to_vector (loadi64 addr:$src))))),
5742 (MOVDDUPrm addr:$src)>;
5745 // Shuffle with UNPCKLPS
5746 def : Pat<(v4f32 (X86Unpcklps VR128:$src1, (memopv4f32 addr:$src2))),
5747 (VUNPCKLPSrm VR128:$src1, addr:$src2)>, Requires<[HasAVX]>;
5748 def : Pat<(v8f32 (X86Unpcklpsy VR256:$src1, (memopv8f32 addr:$src2))),
5749 (VUNPCKLPSYrm VR256:$src1, addr:$src2)>, Requires<[HasAVX]>;
5750 def : Pat<(v4f32 (X86Unpcklps VR128:$src1, (memopv4f32 addr:$src2))),
5751 (UNPCKLPSrm VR128:$src1, addr:$src2)>;
5753 def : Pat<(v4f32 (X86Unpcklps VR128:$src1, VR128:$src2)),
5754 (VUNPCKLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasAVX]>;
5755 def : Pat<(v8f32 (X86Unpcklpsy VR256:$src1, VR256:$src2)),
5756 (VUNPCKLPSYrr VR256:$src1, VR256:$src2)>, Requires<[HasAVX]>;
5757 def : Pat<(v4f32 (X86Unpcklps VR128:$src1, VR128:$src2)),
5758 (UNPCKLPSrr VR128:$src1, VR128:$src2)>;
5760 // Shuffle with UNPCKHPS
5761 def : Pat<(v4f32 (X86Unpckhps VR128:$src1, (memopv4f32 addr:$src2))),
5762 (VUNPCKHPSrm VR128:$src1, addr:$src2)>, Requires<[HasAVX]>;
5763 def : Pat<(v4f32 (X86Unpckhps VR128:$src1, (memopv4f32 addr:$src2))),
5764 (UNPCKHPSrm VR128:$src1, addr:$src2)>;
5766 def : Pat<(v4f32 (X86Unpckhps VR128:$src1, VR128:$src2)),
5767 (VUNPCKHPSrr VR128:$src1, VR128:$src2)>, Requires<[HasAVX]>;
5768 def : Pat<(v4f32 (X86Unpckhps VR128:$src1, VR128:$src2)),
5769 (UNPCKHPSrr VR128:$src1, VR128:$src2)>;
5771 // Shuffle with VUNPCKHPSY
5772 def : Pat<(v8f32 (X86Unpckhpsy VR256:$src1, (memopv8f32 addr:$src2))),
5773 (VUNPCKHPSYrm VR256:$src1, addr:$src2)>, Requires<[HasAVX]>;
5774 def : Pat<(v8f32 (X86Unpckhpsy VR256:$src1, VR256:$src2)),
5775 (VUNPCKHPSYrr VR256:$src1, VR256:$src2)>, Requires<[HasAVX]>;
5777 // Shuffle with UNPCKLPD
5778 def : Pat<(v2f64 (X86Unpcklpd VR128:$src1, (memopv2f64 addr:$src2))),
5779 (VUNPCKLPDrm VR128:$src1, addr:$src2)>, Requires<[HasAVX]>;
5780 def : Pat<(v4f64 (X86Unpcklpdy VR256:$src1, (memopv4f64 addr:$src2))),
5781 (VUNPCKLPDYrm VR256:$src1, addr:$src2)>, Requires<[HasAVX]>;
5782 def : Pat<(v2f64 (X86Unpcklpd VR128:$src1, (memopv2f64 addr:$src2))),
5783 (UNPCKLPDrm VR128:$src1, addr:$src2)>;
5785 def : Pat<(v2f64 (X86Unpcklpd VR128:$src1, VR128:$src2)),
5786 (VUNPCKLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasAVX]>;
5787 def : Pat<(v4f64 (X86Unpcklpdy VR256:$src1, VR256:$src2)),
5788 (VUNPCKLPDYrr VR256:$src1, VR256:$src2)>, Requires<[HasAVX]>;
5789 def : Pat<(v2f64 (X86Unpcklpd VR128:$src1, VR128:$src2)),
5790 (UNPCKLPDrr VR128:$src1, VR128:$src2)>;
5792 // Shuffle with UNPCKHPD
5793 def : Pat<(v2f64 (X86Unpckhpd VR128:$src1, (memopv2f64 addr:$src2))),
5794 (VUNPCKHPDrm VR128:$src1, addr:$src2)>, Requires<[HasAVX]>;
5795 def : Pat<(v2f64 (X86Unpckhpd VR128:$src1, (memopv2f64 addr:$src2))),
5796 (UNPCKHPDrm VR128:$src1, addr:$src2)>;
5798 def : Pat<(v2f64 (X86Unpckhpd VR128:$src1, VR128:$src2)),
5799 (VUNPCKHPDrr VR128:$src1, VR128:$src2)>, Requires<[HasAVX]>;
5800 def : Pat<(v2f64 (X86Unpckhpd VR128:$src1, VR128:$src2)),
5801 (UNPCKHPDrr VR128:$src1, VR128:$src2)>;
5803 // Shuffle with VUNPCKHPDY
5804 def : Pat<(v4f64 (X86Unpckhpdy VR256:$src1, (memopv4f64 addr:$src2))),
5805 (VUNPCKHPDYrm VR256:$src1, addr:$src2)>, Requires<[HasAVX]>;
5806 def : Pat<(v4f64 (X86Unpckhpdy VR256:$src1, VR256:$src2)),
5807 (VUNPCKHPDYrr VR256:$src1, VR256:$src2)>, Requires<[HasAVX]>;
5809 // Shuffle with MOVLHPS
5810 def : Pat<(X86Movlhps VR128:$src1,
5811 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))),
5812 (MOVHPSrm VR128:$src1, addr:$src2)>;
5813 def : Pat<(X86Movlhps VR128:$src1,
5814 (bc_v4i32 (v2i64 (X86vzload addr:$src2)))),
5815 (MOVHPSrm VR128:$src1, addr:$src2)>;
5816 def : Pat<(v4f32 (X86Movlhps VR128:$src1, VR128:$src2)),
5817 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
5818 def : Pat<(v4i32 (X86Movlhps VR128:$src1, VR128:$src2)),
5819 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
5820 def : Pat<(v2i64 (X86Movlhps VR128:$src1, VR128:$src2)),
5821 (MOVLHPSrr (v2i64 VR128:$src1), VR128:$src2)>;
5823 // FIXME: Instead of X86Movddup, there should be a X86Unpcklpd here, the problem
5824 // is during lowering, where it's not possible to recognize the load fold cause
5825 // it has two uses through a bitcast. One use disappears at isel time and the
5826 // fold opportunity reappears.
5827 def : Pat<(v2f64 (X86Movddup VR128:$src)),
5828 (UNPCKLPDrr VR128:$src, VR128:$src)>;
5830 // Shuffle with MOVLHPD
5831 def : Pat<(v2f64 (X86Movlhpd VR128:$src1,
5832 (scalar_to_vector (loadf64 addr:$src2)))),
5833 (MOVHPDrm VR128:$src1, addr:$src2)>;
5835 // FIXME: Instead of X86Unpcklpd, there should be a X86Movlhpd here, the problem
5836 // is during lowering, where it's not possible to recognize the load fold cause
5837 // it has two uses through a bitcast. One use disappears at isel time and the
5838 // fold opportunity reappears.
5839 def : Pat<(v2f64 (X86Unpcklpd VR128:$src1,
5840 (scalar_to_vector (loadf64 addr:$src2)))),
5841 (MOVHPDrm VR128:$src1, addr:$src2)>;
5843 // Shuffle with MOVSS
5844 def : Pat<(v4f32 (X86Movss VR128:$src1, (scalar_to_vector FR32:$src2))),
5845 (MOVSSrr VR128:$src1, FR32:$src2)>;
5846 def : Pat<(v4i32 (X86Movss VR128:$src1, VR128:$src2)),
5847 (MOVSSrr (v4i32 VR128:$src1),
5848 (EXTRACT_SUBREG (v4i32 VR128:$src2), sub_ss))>;
5849 def : Pat<(v4f32 (X86Movss VR128:$src1, VR128:$src2)),
5850 (MOVSSrr (v4f32 VR128:$src1),
5851 (EXTRACT_SUBREG (v4f32 VR128:$src2), sub_ss))>;
5852 // FIXME: Instead of a X86Movss there should be a X86Movlps here, the problem
5853 // is during lowering, where it's not possible to recognize the load fold cause
5854 // it has two uses through a bitcast. One use disappears at isel time and the
5855 // fold opportunity reappears.
5856 def : Pat<(X86Movss VR128:$src1,
5857 (bc_v4i32 (v2i64 (load addr:$src2)))),
5858 (MOVLPSrm VR128:$src1, addr:$src2)>;
5860 // Shuffle with MOVSD
5861 def : Pat<(v2f64 (X86Movsd VR128:$src1, (scalar_to_vector FR64:$src2))),
5862 (MOVSDrr VR128:$src1, FR64:$src2)>;
5863 def : Pat<(v2i64 (X86Movsd VR128:$src1, VR128:$src2)),
5864 (MOVSDrr (v2i64 VR128:$src1),
5865 (EXTRACT_SUBREG (v2i64 VR128:$src2), sub_sd))>;
5866 def : Pat<(v2f64 (X86Movsd VR128:$src1, VR128:$src2)),
5867 (MOVSDrr (v2f64 VR128:$src1),
5868 (EXTRACT_SUBREG (v2f64 VR128:$src2), sub_sd))>;
5869 def : Pat<(v4f32 (X86Movsd VR128:$src1, VR128:$src2)),
5870 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG (v4f32 VR128:$src2), sub_sd))>;
5871 def : Pat<(v4i32 (X86Movsd VR128:$src1, VR128:$src2)),
5872 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG (v4i32 VR128:$src2), sub_sd))>;
5874 // Shuffle with PSHUFHW
5875 def : Pat<(v8i16 (X86PShufhw VR128:$src, (i8 imm:$imm))),
5876 (PSHUFHWri VR128:$src, imm:$imm)>;
5877 def : Pat<(v8i16 (X86PShufhw (bc_v8i16 (memopv2i64 addr:$src)), (i8 imm:$imm))),
5878 (PSHUFHWmi addr:$src, imm:$imm)>;
5880 // Shuffle with PSHUFLW
5881 def : Pat<(v8i16 (X86PShuflw VR128:$src, (i8 imm:$imm))),
5882 (PSHUFLWri VR128:$src, imm:$imm)>;
5883 def : Pat<(v8i16 (X86PShuflw (bc_v8i16 (memopv2i64 addr:$src)), (i8 imm:$imm))),
5884 (PSHUFLWmi addr:$src, imm:$imm)>;
5886 // Shuffle with MOVLPS
5887 def : Pat<(v4f32 (X86Movlps VR128:$src1, (load addr:$src2))),
5888 (MOVLPSrm VR128:$src1, addr:$src2)>;
5889 def : Pat<(v4i32 (X86Movlps VR128:$src1, (load addr:$src2))),
5890 (MOVLPSrm VR128:$src1, addr:$src2)>;
5891 def : Pat<(X86Movlps VR128:$src1,
5892 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))),
5893 (MOVLPSrm VR128:$src1, addr:$src2)>;
5894 // FIXME: Instead of a X86Movlps there should be a X86Movsd here, the problem
5895 // is during lowering, where it's not possible to recognize the load fold cause
5896 // it has two uses through a bitcast. One use disappears at isel time and the
5897 // fold opportunity reappears.
5898 def : Pat<(v4f32 (X86Movlps VR128:$src1, VR128:$src2)),
5899 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG (v4f32 VR128:$src2), sub_sd))>;
5901 def : Pat<(v4i32 (X86Movlps VR128:$src1, VR128:$src2)),
5902 (MOVSDrr VR128:$src1, (EXTRACT_SUBREG (v4i32 VR128:$src2), sub_sd))>;
5904 // Shuffle with MOVLPD
5905 def : Pat<(v2f64 (X86Movlpd VR128:$src1, (load addr:$src2))),
5906 (MOVLPDrm VR128:$src1, addr:$src2)>;
5907 def : Pat<(v2i64 (X86Movlpd VR128:$src1, (load addr:$src2))),
5908 (MOVLPDrm VR128:$src1, addr:$src2)>;
5909 def : Pat<(v2f64 (X86Movlpd VR128:$src1,
5910 (scalar_to_vector (loadf64 addr:$src2)))),
5911 (MOVLPDrm VR128:$src1, addr:$src2)>;
5913 // Extra patterns to match stores with MOVHPS/PD and MOVLPS/PD
5914 def : Pat<(store (f64 (vector_extract
5915 (v2f64 (X86Unpckhps VR128:$src, (undef))), (iPTR 0))),addr:$dst),
5916 (MOVHPSmr addr:$dst, VR128:$src)>;
5917 def : Pat<(store (f64 (vector_extract
5918 (v2f64 (X86Unpckhpd VR128:$src, (undef))), (iPTR 0))),addr:$dst),
5919 (MOVHPDmr addr:$dst, VR128:$src)>;
5921 def : Pat<(store (v4f32 (X86Movlps (load addr:$src1), VR128:$src2)),addr:$src1),
5922 (MOVLPSmr addr:$src1, VR128:$src2)>;
5923 def : Pat<(store (v4i32 (X86Movlps
5924 (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)), addr:$src1),
5925 (MOVLPSmr addr:$src1, VR128:$src2)>;
5927 def : Pat<(store (v2f64 (X86Movlpd (load addr:$src1), VR128:$src2)),addr:$src1),
5928 (MOVLPDmr addr:$src1, VR128:$src2)>;
5929 def : Pat<(store (v2i64 (X86Movlpd (load addr:$src1), VR128:$src2)),addr:$src1),
5930 (MOVLPDmr addr:$src1, VR128:$src2)>;