1 //===-- X86InstrXOP.td - XOP Instruction Set ---------------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes XOP (eXtended OPerations)
11 //===----------------------------------------------------------------------===//
13 multiclass xop2op<bits<8> opc, string OpcodeStr, Intrinsic Int> {
14 def rr : IXOP<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
15 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
16 [(set VR128:$dst, (Int VR128:$src))]>, XOP, Sched<[SchedWritePHAdd.XMM]>;
17 def rm : IXOP<opc, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
18 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
19 [(set VR128:$dst, (Int (load addr:$src)))]>, XOP,
20 Sched<[SchedWritePHAdd.XMM.Folded, SchedWritePHAdd.XMM.ReadAfterFold]>;
23 let ExeDomain = SSEPackedInt in {
24 defm VPHSUBWD : xop2op<0xE2, "vphsubwd", int_x86_xop_vphsubwd>;
25 defm VPHSUBDQ : xop2op<0xE3, "vphsubdq", int_x86_xop_vphsubdq>;
26 defm VPHSUBBW : xop2op<0xE1, "vphsubbw", int_x86_xop_vphsubbw>;
27 defm VPHADDWQ : xop2op<0xC7, "vphaddwq", int_x86_xop_vphaddwq>;
28 defm VPHADDWD : xop2op<0xC6, "vphaddwd", int_x86_xop_vphaddwd>;
29 defm VPHADDUWQ : xop2op<0xD7, "vphadduwq", int_x86_xop_vphadduwq>;
30 defm VPHADDUWD : xop2op<0xD6, "vphadduwd", int_x86_xop_vphadduwd>;
31 defm VPHADDUDQ : xop2op<0xDB, "vphaddudq", int_x86_xop_vphaddudq>;
32 defm VPHADDUBW : xop2op<0xD1, "vphaddubw", int_x86_xop_vphaddubw>;
33 defm VPHADDUBQ : xop2op<0xD3, "vphaddubq", int_x86_xop_vphaddubq>;
34 defm VPHADDUBD : xop2op<0xD2, "vphaddubd", int_x86_xop_vphaddubd>;
35 defm VPHADDDQ : xop2op<0xCB, "vphadddq", int_x86_xop_vphadddq>;
36 defm VPHADDBW : xop2op<0xC1, "vphaddbw", int_x86_xop_vphaddbw>;
37 defm VPHADDBQ : xop2op<0xC3, "vphaddbq", int_x86_xop_vphaddbq>;
38 defm VPHADDBD : xop2op<0xC2, "vphaddbd", int_x86_xop_vphaddbd>;
41 // Scalar load 2 addr operand instructions
42 multiclass xop2opsld<bits<8> opc, string OpcodeStr, Intrinsic Int,
43 Operand memop, ComplexPattern mem_cpat,
44 X86FoldableSchedWrite sched> {
45 def rr : IXOP<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
46 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
47 [(set VR128:$dst, (Int VR128:$src))]>, XOP, Sched<[sched]>;
48 def rm : IXOP<opc, MRMSrcMem, (outs VR128:$dst), (ins memop:$src),
49 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
50 [(set VR128:$dst, (Int mem_cpat:$src))]>, XOP,
51 Sched<[sched.Folded, sched.ReadAfterFold]>;
54 multiclass xop2op128<bits<8> opc, string OpcodeStr, Intrinsic Int,
55 X86FoldableSchedWrite sched> {
56 def rr : IXOP<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
57 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
58 [(set VR128:$dst, (Int VR128:$src))]>, XOP, Sched<[sched]>;
59 def rm : IXOP<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
60 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
61 [(set VR128:$dst, (Int (load addr:$src)))]>, XOP,
62 Sched<[sched.Folded, sched.ReadAfterFold]>;
65 multiclass xop2op256<bits<8> opc, string OpcodeStr, Intrinsic Int,
66 X86FoldableSchedWrite sched> {
67 def Yrr : IXOP<opc, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src),
68 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
69 [(set VR256:$dst, (Int VR256:$src))]>, XOP, VEX_L, Sched<[sched]>;
70 def Yrm : IXOP<opc, MRMSrcMem, (outs VR256:$dst), (ins f256mem:$src),
71 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
72 [(set VR256:$dst, (Int (load addr:$src)))]>, XOP, VEX_L,
73 Sched<[sched.Folded, sched.ReadAfterFold]>;
76 let ExeDomain = SSEPackedSingle in {
77 defm VFRCZSS : xop2opsld<0x82, "vfrczss", int_x86_xop_vfrcz_ss,
78 ssmem, sse_load_f32, SchedWriteFRnd.Scl>;
79 defm VFRCZPS : xop2op128<0x80, "vfrczps", int_x86_xop_vfrcz_ps,
81 defm VFRCZPS : xop2op256<0x80, "vfrczps", int_x86_xop_vfrcz_ps_256,
85 let ExeDomain = SSEPackedDouble in {
86 defm VFRCZSD : xop2opsld<0x83, "vfrczsd", int_x86_xop_vfrcz_sd,
87 sdmem, sse_load_f64, SchedWriteFRnd.Scl>;
88 defm VFRCZPD : xop2op128<0x81, "vfrczpd", int_x86_xop_vfrcz_pd,
90 defm VFRCZPD : xop2op256<0x81, "vfrczpd", int_x86_xop_vfrcz_pd_256,
94 multiclass xop3op<bits<8> opc, string OpcodeStr, SDNode OpNode,
95 ValueType vt128, X86FoldableSchedWrite sched> {
96 def rr : IXOP<opc, MRMSrcReg4VOp3, (outs VR128:$dst),
97 (ins VR128:$src1, VR128:$src2),
98 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
100 (vt128 (OpNode (vt128 VR128:$src1), (vt128 VR128:$src2))))]>,
102 def rm : IXOP<opc, MRMSrcMem, (outs VR128:$dst),
103 (ins VR128:$src1, i128mem:$src2),
104 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
106 (vt128 (OpNode (vt128 VR128:$src1),
107 (vt128 (load addr:$src2)))))]>,
108 XOP_4V, VEX_W, Sched<[sched.Folded, sched.ReadAfterFold]>;
109 def mr : IXOP<opc, MRMSrcMem4VOp3, (outs VR128:$dst),
110 (ins i128mem:$src1, VR128:$src2),
111 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
113 (vt128 (OpNode (vt128 (load addr:$src1)),
114 (vt128 VR128:$src2))))]>,
115 XOP, Sched<[sched.Folded, sched.ReadAfterFold]>;
117 let isCodeGenOnly = 1, ForceDisassemble = 1, hasSideEffects = 0 in
118 def rr_REV : IXOP<opc, MRMSrcReg, (outs VR128:$dst),
119 (ins VR128:$src1, VR128:$src2),
120 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
122 XOP_4V, VEX_W, Sched<[sched]>, FoldGenData<NAME#rr>;
125 let ExeDomain = SSEPackedInt in {
126 defm VPROTB : xop3op<0x90, "vprotb", rotl, v16i8, SchedWriteVarVecShift.XMM>;
127 defm VPROTD : xop3op<0x92, "vprotd", rotl, v4i32, SchedWriteVarVecShift.XMM>;
128 defm VPROTQ : xop3op<0x93, "vprotq", rotl, v2i64, SchedWriteVarVecShift.XMM>;
129 defm VPROTW : xop3op<0x91, "vprotw", rotl, v8i16, SchedWriteVarVecShift.XMM>;
130 defm VPSHAB : xop3op<0x98, "vpshab", X86vpsha, v16i8, SchedWriteVarVecShift.XMM>;
131 defm VPSHAD : xop3op<0x9A, "vpshad", X86vpsha, v4i32, SchedWriteVarVecShift.XMM>;
132 defm VPSHAQ : xop3op<0x9B, "vpshaq", X86vpsha, v2i64, SchedWriteVarVecShift.XMM>;
133 defm VPSHAW : xop3op<0x99, "vpshaw", X86vpsha, v8i16, SchedWriteVarVecShift.XMM>;
134 defm VPSHLB : xop3op<0x94, "vpshlb", X86vpshl, v16i8, SchedWriteVarVecShift.XMM>;
135 defm VPSHLD : xop3op<0x96, "vpshld", X86vpshl, v4i32, SchedWriteVarVecShift.XMM>;
136 defm VPSHLQ : xop3op<0x97, "vpshlq", X86vpshl, v2i64, SchedWriteVarVecShift.XMM>;
137 defm VPSHLW : xop3op<0x95, "vpshlw", X86vpshl, v8i16, SchedWriteVarVecShift.XMM>;
140 multiclass xop3opimm<bits<8> opc, string OpcodeStr, SDNode OpNode,
141 ValueType vt128, X86FoldableSchedWrite sched> {
142 def ri : IXOPi8<opc, MRMSrcReg, (outs VR128:$dst),
143 (ins VR128:$src1, u8imm:$src2),
144 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
146 (vt128 (OpNode (vt128 VR128:$src1), imm:$src2)))]>,
148 def mi : IXOPi8<opc, MRMSrcMem, (outs VR128:$dst),
149 (ins i128mem:$src1, u8imm:$src2),
150 !strconcat(OpcodeStr, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
152 (vt128 (OpNode (vt128 (load addr:$src1)), imm:$src2)))]>,
153 XOP, Sched<[sched.Folded, sched.ReadAfterFold]>;
156 let ExeDomain = SSEPackedInt in {
157 defm VPROTB : xop3opimm<0xC0, "vprotb", X86vrotli, v16i8,
158 SchedWriteVecShiftImm.XMM>;
159 defm VPROTD : xop3opimm<0xC2, "vprotd", X86vrotli, v4i32,
160 SchedWriteVecShiftImm.XMM>;
161 defm VPROTQ : xop3opimm<0xC3, "vprotq", X86vrotli, v2i64,
162 SchedWriteVecShiftImm.XMM>;
163 defm VPROTW : xop3opimm<0xC1, "vprotw", X86vrotli, v8i16,
164 SchedWriteVecShiftImm.XMM>;
167 // Instruction where second source can be memory, but third must be register
168 multiclass xop4opm2<bits<8> opc, string OpcodeStr, Intrinsic Int,
169 X86FoldableSchedWrite sched> {
170 let isCommutable = 1 in
171 def rr : IXOPi8Reg<opc, MRMSrcReg, (outs VR128:$dst),
172 (ins VR128:$src1, VR128:$src2, VR128:$src3),
173 !strconcat(OpcodeStr,
174 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
176 (Int VR128:$src1, VR128:$src2, VR128:$src3))]>, XOP_4V,
178 def rm : IXOPi8Reg<opc, MRMSrcMem, (outs VR128:$dst),
179 (ins VR128:$src1, i128mem:$src2, VR128:$src3),
180 !strconcat(OpcodeStr,
181 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
183 (Int VR128:$src1, (load addr:$src2),
184 VR128:$src3))]>, XOP_4V, Sched<[sched.Folded, sched.ReadAfterFold]>;
187 let ExeDomain = SSEPackedInt in {
188 defm VPMADCSWD : xop4opm2<0xB6, "vpmadcswd",
189 int_x86_xop_vpmadcswd, SchedWriteVecIMul.XMM>;
190 defm VPMADCSSWD : xop4opm2<0xA6, "vpmadcsswd",
191 int_x86_xop_vpmadcsswd, SchedWriteVecIMul.XMM>;
192 defm VPMACSWW : xop4opm2<0x95, "vpmacsww",
193 int_x86_xop_vpmacsww, SchedWriteVecIMul.XMM>;
194 defm VPMACSWD : xop4opm2<0x96, "vpmacswd",
195 int_x86_xop_vpmacswd, SchedWriteVecIMul.XMM>;
196 defm VPMACSSWW : xop4opm2<0x85, "vpmacssww",
197 int_x86_xop_vpmacssww, SchedWriteVecIMul.XMM>;
198 defm VPMACSSWD : xop4opm2<0x86, "vpmacsswd",
199 int_x86_xop_vpmacsswd, SchedWriteVecIMul.XMM>;
200 defm VPMACSSDQL : xop4opm2<0x87, "vpmacssdql",
201 int_x86_xop_vpmacssdql, SchedWritePMULLD.XMM>;
202 defm VPMACSSDQH : xop4opm2<0x8F, "vpmacssdqh",
203 int_x86_xop_vpmacssdqh, SchedWritePMULLD.XMM>;
204 defm VPMACSSDD : xop4opm2<0x8E, "vpmacssdd",
205 int_x86_xop_vpmacssdd, SchedWritePMULLD.XMM>;
206 defm VPMACSDQL : xop4opm2<0x97, "vpmacsdql",
207 int_x86_xop_vpmacsdql, SchedWritePMULLD.XMM>;
208 defm VPMACSDQH : xop4opm2<0x9F, "vpmacsdqh",
209 int_x86_xop_vpmacsdqh, SchedWritePMULLD.XMM>;
210 defm VPMACSDD : xop4opm2<0x9E, "vpmacsdd",
211 int_x86_xop_vpmacsdd, SchedWritePMULLD.XMM>;
214 // IFMA patterns - for cases where we can safely ignore the overflow bits from
215 // the multiply or easily match with existing intrinsics.
216 let Predicates = [HasXOP] in {
217 def : Pat<(v8i16 (add (mul (v8i16 VR128:$src1), (v8i16 VR128:$src2)),
218 (v8i16 VR128:$src3))),
219 (VPMACSWWrr VR128:$src1, VR128:$src2, VR128:$src3)>;
220 def : Pat<(v4i32 (add (mul (v4i32 VR128:$src1), (v4i32 VR128:$src2)),
221 (v4i32 VR128:$src3))),
222 (VPMACSDDrr VR128:$src1, VR128:$src2, VR128:$src3)>;
223 def : Pat<(v2i64 (add (X86pmuldq (bc_v2i64 (X86PShufd (v4i32 VR128:$src1), (i8 -11))),
224 (bc_v2i64 (X86PShufd (v4i32 VR128:$src2), (i8 -11)))),
225 (v2i64 VR128:$src3))),
226 (VPMACSDQHrr VR128:$src1, VR128:$src2, VR128:$src3)>;
227 def : Pat<(v2i64 (add (X86pmuldq (v2i64 VR128:$src1), (v2i64 VR128:$src2)),
228 (v2i64 VR128:$src3))),
229 (VPMACSDQLrr VR128:$src1, VR128:$src2, VR128:$src3)>;
230 def : Pat<(v4i32 (add (X86vpmaddwd (v8i16 VR128:$src1), (v8i16 VR128:$src2)),
231 (v4i32 VR128:$src3))),
232 (VPMADCSWDrr VR128:$src1, VR128:$src2, VR128:$src3)>;
235 // Transforms to swizzle an immediate to help matching memory operand in first
237 def CommuteVPCOMCC : SDNodeXForm<imm, [{
238 uint8_t Imm = N->getZExtValue() & 0x7;
239 Imm = X86::getSwappedVPCOMImm(Imm);
240 return getI8Imm(Imm, SDLoc(N));
243 // Instruction where second source can be memory, third must be imm8
244 multiclass xopvpcom<bits<8> opc, string Suffix, SDNode OpNode, ValueType vt128,
245 X86FoldableSchedWrite sched> {
246 let ExeDomain = SSEPackedInt in { // SSE integer instructions
247 let isCommutable = 1 in
248 def ri : IXOPi8<opc, MRMSrcReg, (outs VR128:$dst),
249 (ins VR128:$src1, VR128:$src2, XOPCC:$cc),
250 !strconcat("vpcom${cc}", Suffix,
251 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
253 (vt128 (OpNode (vt128 VR128:$src1), (vt128 VR128:$src2),
255 XOP_4V, Sched<[sched]>;
256 def mi : IXOPi8<opc, MRMSrcMem, (outs VR128:$dst),
257 (ins VR128:$src1, i128mem:$src2, XOPCC:$cc),
258 !strconcat("vpcom${cc}", Suffix,
259 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
261 (vt128 (OpNode (vt128 VR128:$src1),
262 (vt128 (load addr:$src2)),
264 XOP_4V, Sched<[sched.Folded, sched.ReadAfterFold]>;
265 let isAsmParserOnly = 1, hasSideEffects = 0 in {
266 def ri_alt : IXOPi8<opc, MRMSrcReg, (outs VR128:$dst),
267 (ins VR128:$src1, VR128:$src2, u8imm:$src3),
268 !strconcat("vpcom", Suffix,
269 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
270 []>, XOP_4V, Sched<[sched]>, NotMemoryFoldable;
272 def mi_alt : IXOPi8<opc, MRMSrcMem, (outs VR128:$dst),
273 (ins VR128:$src1, i128mem:$src2, u8imm:$src3),
274 !strconcat("vpcom", Suffix,
275 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
276 []>, XOP_4V, Sched<[sched.Folded, sched.ReadAfterFold]>,
281 def : Pat<(OpNode (load addr:$src2),
282 (vt128 VR128:$src1), imm:$cc),
283 (!cast<Instruction>(NAME#"mi") VR128:$src1, addr:$src2,
284 (CommuteVPCOMCC imm:$cc))>;
287 defm VPCOMB : xopvpcom<0xCC, "b", X86vpcom, v16i8, SchedWriteVecALU.XMM>;
288 defm VPCOMW : xopvpcom<0xCD, "w", X86vpcom, v8i16, SchedWriteVecALU.XMM>;
289 defm VPCOMD : xopvpcom<0xCE, "d", X86vpcom, v4i32, SchedWriteVecALU.XMM>;
290 defm VPCOMQ : xopvpcom<0xCF, "q", X86vpcom, v2i64, SchedWriteVecALU.XMM>;
291 defm VPCOMUB : xopvpcom<0xEC, "ub", X86vpcomu, v16i8, SchedWriteVecALU.XMM>;
292 defm VPCOMUW : xopvpcom<0xED, "uw", X86vpcomu, v8i16, SchedWriteVecALU.XMM>;
293 defm VPCOMUD : xopvpcom<0xEE, "ud", X86vpcomu, v4i32, SchedWriteVecALU.XMM>;
294 defm VPCOMUQ : xopvpcom<0xEF, "uq", X86vpcomu, v2i64, SchedWriteVecALU.XMM>;
296 multiclass xop4op<bits<8> opc, string OpcodeStr, SDNode OpNode,
297 ValueType vt128, X86FoldableSchedWrite sched> {
298 def rrr : IXOPi8Reg<opc, MRMSrcReg, (outs VR128:$dst),
299 (ins VR128:$src1, VR128:$src2, VR128:$src3),
300 !strconcat(OpcodeStr,
301 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
303 (vt128 (OpNode (vt128 VR128:$src1), (vt128 VR128:$src2),
304 (vt128 VR128:$src3))))]>,
305 XOP_4V, Sched<[sched]>;
306 def rrm : IXOPi8Reg<opc, MRMSrcMemOp4, (outs VR128:$dst),
307 (ins VR128:$src1, VR128:$src2, i128mem:$src3),
308 !strconcat(OpcodeStr,
309 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
311 (vt128 (OpNode (vt128 VR128:$src1), (vt128 VR128:$src2),
312 (vt128 (load addr:$src3)))))]>,
313 XOP_4V, VEX_W, Sched<[sched.Folded, sched.ReadAfterFold, sched.ReadAfterFold]>;
314 def rmr : IXOPi8Reg<opc, MRMSrcMem, (outs VR128:$dst),
315 (ins VR128:$src1, i128mem:$src2, VR128:$src3),
316 !strconcat(OpcodeStr,
317 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
319 (v16i8 (OpNode (vt128 VR128:$src1), (vt128 (load addr:$src2)),
320 (vt128 VR128:$src3))))]>,
321 XOP_4V, Sched<[sched.Folded, sched.ReadAfterFold,
323 ReadDefault, ReadDefault, ReadDefault, ReadDefault,
326 sched.ReadAfterFold]>;
328 let isCodeGenOnly = 1, ForceDisassemble = 1, hasSideEffects = 0 in
329 def rrr_REV : IXOPi8Reg<opc, MRMSrcRegOp4, (outs VR128:$dst),
330 (ins VR128:$src1, VR128:$src2, VR128:$src3),
331 !strconcat(OpcodeStr,
332 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
333 []>, XOP_4V, VEX_W, Sched<[sched]>, FoldGenData<NAME#rrr>;
336 let ExeDomain = SSEPackedInt in {
337 defm VPPERM : xop4op<0xA3, "vpperm", X86vpperm, v16i8,
338 SchedWriteVarShuffle.XMM>;
341 // Instruction where either second or third source can be memory
342 multiclass xop4op_int<bits<8> opc, string OpcodeStr, RegisterClass RC,
343 X86MemOperand x86memop, ValueType VT,
344 X86FoldableSchedWrite sched> {
345 def rrr : IXOPi8Reg<opc, MRMSrcReg, (outs RC:$dst),
346 (ins RC:$src1, RC:$src2, RC:$src3),
347 !strconcat(OpcodeStr,
348 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
349 [(set RC:$dst, (VT (or (and RC:$src3, RC:$src1),
350 (X86andnp RC:$src3, RC:$src2))))]>, XOP_4V,
352 // FIXME: This pattern can't match.
353 def rrm : IXOPi8Reg<opc, MRMSrcMemOp4, (outs RC:$dst),
354 (ins RC:$src1, RC:$src2, x86memop:$src3),
355 !strconcat(OpcodeStr,
356 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
357 [(set RC:$dst, (VT (or (and (load addr:$src3), RC:$src1),
358 (X86andnp (load addr:$src3), RC:$src2))))]>,
359 XOP_4V, VEX_W, Sched<[sched.Folded, sched.ReadAfterFold, sched.ReadAfterFold]>;
360 def rmr : IXOPi8Reg<opc, MRMSrcMem, (outs RC:$dst),
361 (ins RC:$src1, x86memop:$src2, RC:$src3),
362 !strconcat(OpcodeStr,
363 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
364 [(set RC:$dst, (VT (or (and RC:$src3, RC:$src1),
365 (X86andnp RC:$src3, (load addr:$src2)))))]>,
366 XOP_4V, Sched<[sched.Folded, sched.ReadAfterFold,
368 ReadDefault, ReadDefault, ReadDefault, ReadDefault,
371 sched.ReadAfterFold]>;
373 let isCodeGenOnly = 1, ForceDisassemble = 1, hasSideEffects = 0 in
374 def rrr_REV : IXOPi8Reg<opc, MRMSrcRegOp4, (outs RC:$dst),
375 (ins RC:$src1, RC:$src2, RC:$src3),
376 !strconcat(OpcodeStr,
377 "\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}"),
378 []>, XOP_4V, VEX_W, Sched<[sched]>, FoldGenData<NAME#rrr>;
381 let ExeDomain = SSEPackedInt in {
382 defm VPCMOV : xop4op_int<0xA2, "vpcmov", VR128, i128mem, v2i64,
383 SchedWriteShuffle.XMM>;
384 defm VPCMOVY : xop4op_int<0xA2, "vpcmov", VR256, i256mem, v4i64,
385 SchedWriteShuffle.YMM>, VEX_L;
388 let Predicates = [HasXOP] in {
389 def : Pat<(v16i8 (or (and VR128:$src3, VR128:$src1),
390 (X86andnp VR128:$src3, VR128:$src2))),
391 (VPCMOVrrr VR128:$src1, VR128:$src2, VR128:$src3)>;
392 def : Pat<(v8i16 (or (and VR128:$src3, VR128:$src1),
393 (X86andnp VR128:$src3, VR128:$src2))),
394 (VPCMOVrrr VR128:$src1, VR128:$src2, VR128:$src3)>;
395 def : Pat<(v4i32 (or (and VR128:$src3, VR128:$src1),
396 (X86andnp VR128:$src3, VR128:$src2))),
397 (VPCMOVrrr VR128:$src1, VR128:$src2, VR128:$src3)>;
399 def : Pat<(or (and VR128:$src3, VR128:$src1),
400 (X86andnp VR128:$src3, (bc_v16i8 (loadv2i64 addr:$src2)))),
401 (VPCMOVrmr VR128:$src1, addr:$src2, VR128:$src3)>;
402 def : Pat<(or (and VR128:$src3, VR128:$src1),
403 (X86andnp VR128:$src3, (bc_v8i16 (loadv2i64 addr:$src2)))),
404 (VPCMOVrmr VR128:$src1, addr:$src2, VR128:$src3)>;
405 def : Pat<(or (and VR128:$src3, VR128:$src1),
406 (X86andnp VR128:$src3, (bc_v4i32 (loadv2i64 addr:$src2)))),
407 (VPCMOVrmr VR128:$src1, addr:$src2, VR128:$src3)>;
409 def : Pat<(v32i8 (or (and VR256:$src3, VR256:$src1),
410 (X86andnp VR256:$src3, VR256:$src2))),
411 (VPCMOVYrrr VR256:$src1, VR256:$src2, VR256:$src3)>;
412 def : Pat<(v16i16 (or (and VR256:$src3, VR256:$src1),
413 (X86andnp VR256:$src3, VR256:$src2))),
414 (VPCMOVYrrr VR256:$src1, VR256:$src2, VR256:$src3)>;
415 def : Pat<(v8i32 (or (and VR256:$src3, VR256:$src1),
416 (X86andnp VR256:$src3, VR256:$src2))),
417 (VPCMOVYrrr VR256:$src1, VR256:$src2, VR256:$src3)>;
419 def : Pat<(or (and VR256:$src3, VR256:$src1),
420 (X86andnp VR256:$src3, (bc_v32i8 (loadv4i64 addr:$src2)))),
421 (VPCMOVYrmr VR256:$src1, addr:$src2, VR256:$src3)>;
422 def : Pat<(or (and VR256:$src3, VR256:$src1),
423 (X86andnp VR256:$src3, (bc_v16i16 (loadv4i64 addr:$src2)))),
424 (VPCMOVYrmr VR256:$src1, addr:$src2, VR256:$src3)>;
425 def : Pat<(or (and VR256:$src3, VR256:$src1),
426 (X86andnp VR256:$src3, (bc_v8i32 (loadv4i64 addr:$src2)))),
427 (VPCMOVYrmr VR256:$src1, addr:$src2, VR256:$src3)>;
430 multiclass xop_vpermil2<bits<8> Opc, string OpcodeStr, RegisterClass RC,
431 X86MemOperand intmemop, X86MemOperand fpmemop,
432 ValueType VT, PatFrag FPLdFrag, PatFrag IntLdFrag,
433 X86FoldableSchedWrite sched> {
434 def rr : IXOP5<Opc, MRMSrcReg, (outs RC:$dst),
435 (ins RC:$src1, RC:$src2, RC:$src3, u8imm:$src4),
436 !strconcat(OpcodeStr,
437 "\t{$src4, $src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3, $src4}"),
439 (VT (X86vpermil2 RC:$src1, RC:$src2, RC:$src3, (i8 imm:$src4))))]>,
441 def rm : IXOP5<Opc, MRMSrcMemOp4, (outs RC:$dst),
442 (ins RC:$src1, RC:$src2, intmemop:$src3, u8imm:$src4),
443 !strconcat(OpcodeStr,
444 "\t{$src4, $src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3, $src4}"),
446 (VT (X86vpermil2 RC:$src1, RC:$src2, (IntLdFrag addr:$src3),
447 (i8 imm:$src4))))]>, VEX_W,
448 Sched<[sched.Folded, sched.ReadAfterFold, sched.ReadAfterFold]>;
449 def mr : IXOP5<Opc, MRMSrcMem, (outs RC:$dst),
450 (ins RC:$src1, fpmemop:$src2, RC:$src3, u8imm:$src4),
451 !strconcat(OpcodeStr,
452 "\t{$src4, $src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3, $src4}"),
454 (VT (X86vpermil2 RC:$src1, (FPLdFrag addr:$src2),
455 RC:$src3, (i8 imm:$src4))))]>,
456 Sched<[sched.Folded, sched.ReadAfterFold,
458 ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault,
460 sched.ReadAfterFold]>;
462 let isCodeGenOnly = 1, ForceDisassemble = 1, hasSideEffects = 0 in
463 def rr_REV : IXOP5<Opc, MRMSrcRegOp4, (outs RC:$dst),
464 (ins RC:$src1, RC:$src2, RC:$src3, u8imm:$src4),
465 !strconcat(OpcodeStr,
466 "\t{$src4, $src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3, $src4}"),
467 []>, VEX_W, Sched<[sched]>, FoldGenData<NAME#rr>;
470 let ExeDomain = SSEPackedDouble in {
471 defm VPERMIL2PD : xop_vpermil2<0x49, "vpermil2pd", VR128, i128mem, f128mem,
472 v2f64, loadv2f64, loadv2i64,
473 SchedWriteFVarShuffle.XMM>;
474 defm VPERMIL2PDY : xop_vpermil2<0x49, "vpermil2pd", VR256, i256mem, f256mem,
475 v4f64, loadv4f64, loadv4i64,
476 SchedWriteFVarShuffle.YMM>, VEX_L;
479 let ExeDomain = SSEPackedSingle in {
480 defm VPERMIL2PS : xop_vpermil2<0x48, "vpermil2ps", VR128, i128mem, f128mem,
481 v4f32, loadv4f32, loadv4i32,
482 SchedWriteFVarShuffle.XMM>;
483 defm VPERMIL2PSY : xop_vpermil2<0x48, "vpermil2ps", VR256, i256mem, f256mem,
484 v8f32, loadv8f32, loadv8i32,
485 SchedWriteFVarShuffle.YMM>, VEX_L;