1 //===- X86InstrVecCompiler.td - Vector Compiler Patterns ---*- 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 the various vector pseudo instructions used by the
10 // compiler, as well as Pat patterns used during instruction selection.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // Non-instruction patterns
16 //===----------------------------------------------------------------------===//
18 let Predicates = [NoAVX512] in {
19 // A vector extract of the first f32/f64 position is a subregister copy
20 def : Pat<(f32 (extractelt (v4f32 VR128:$src), (iPTR 0))),
21 (COPY_TO_REGCLASS (v4f32 VR128:$src), FR32)>;
22 def : Pat<(f64 (extractelt (v2f64 VR128:$src), (iPTR 0))),
23 (COPY_TO_REGCLASS (v2f64 VR128:$src), FR64)>;
26 let Predicates = [HasAVX512] in {
27 // A vector extract of the first f32/f64 position is a subregister copy
28 def : Pat<(f32 (extractelt (v4f32 VR128X:$src), (iPTR 0))),
29 (COPY_TO_REGCLASS (v4f32 VR128X:$src), FR32X)>;
30 def : Pat<(f64 (extractelt (v2f64 VR128X:$src), (iPTR 0))),
31 (COPY_TO_REGCLASS (v2f64 VR128X:$src), FR64X)>;
34 let Predicates = [NoVLX] in {
35 // Implicitly promote a 32-bit scalar to a vector.
36 def : Pat<(v4f32 (scalar_to_vector FR32:$src)),
37 (COPY_TO_REGCLASS FR32:$src, VR128)>;
38 // Implicitly promote a 64-bit scalar to a vector.
39 def : Pat<(v2f64 (scalar_to_vector FR64:$src)),
40 (COPY_TO_REGCLASS FR64:$src, VR128)>;
43 let Predicates = [HasVLX] in {
44 // Implicitly promote a 32-bit scalar to a vector.
45 def : Pat<(v4f32 (scalar_to_vector FR32X:$src)),
46 (COPY_TO_REGCLASS FR32X:$src, VR128X)>;
47 // Implicitly promote a 64-bit scalar to a vector.
48 def : Pat<(v2f64 (scalar_to_vector FR64X:$src)),
49 (COPY_TO_REGCLASS FR64X:$src, VR128X)>;
52 //===----------------------------------------------------------------------===//
54 //===----------------------------------------------------------------------===//
56 // Patterns for insert_subvector/extract_subvector to/from index=0
57 multiclass subvector_subreg_lowering<RegisterClass subRC, ValueType subVT,
58 RegisterClass RC, ValueType VT,
60 def : Pat<(subVT (extract_subvector (VT RC:$src), (iPTR 0))),
61 (subVT (EXTRACT_SUBREG RC:$src, subIdx))>;
63 def : Pat<(VT (insert_subvector undef, subRC:$src, (iPTR 0))),
64 (VT (INSERT_SUBREG (IMPLICIT_DEF), subRC:$src, subIdx))>;
67 // A 128-bit subvector extract from the first 256-bit vector position is a
68 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
69 // insert to the first 256-bit vector position is a subregister copy that needs
71 defm : subvector_subreg_lowering<VR128, v4i32, VR256, v8i32, sub_xmm>;
72 defm : subvector_subreg_lowering<VR128, v4f32, VR256, v8f32, sub_xmm>;
73 defm : subvector_subreg_lowering<VR128, v2i64, VR256, v4i64, sub_xmm>;
74 defm : subvector_subreg_lowering<VR128, v2f64, VR256, v4f64, sub_xmm>;
75 defm : subvector_subreg_lowering<VR128, v8i16, VR256, v16i16, sub_xmm>;
76 defm : subvector_subreg_lowering<VR128, v16i8, VR256, v32i8, sub_xmm>;
78 // A 128-bit subvector extract from the first 512-bit vector position is a
79 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
80 // insert to the first 512-bit vector position is a subregister copy that needs
82 defm : subvector_subreg_lowering<VR128, v4i32, VR512, v16i32, sub_xmm>;
83 defm : subvector_subreg_lowering<VR128, v4f32, VR512, v16f32, sub_xmm>;
84 defm : subvector_subreg_lowering<VR128, v2i64, VR512, v8i64, sub_xmm>;
85 defm : subvector_subreg_lowering<VR128, v2f64, VR512, v8f64, sub_xmm>;
86 defm : subvector_subreg_lowering<VR128, v8i16, VR512, v32i16, sub_xmm>;
87 defm : subvector_subreg_lowering<VR128, v16i8, VR512, v64i8, sub_xmm>;
89 // A 128-bit subvector extract from the first 512-bit vector position is a
90 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
91 // insert to the first 512-bit vector position is a subregister copy that needs
93 defm : subvector_subreg_lowering<VR256, v8i32, VR512, v16i32, sub_ymm>;
94 defm : subvector_subreg_lowering<VR256, v8f32, VR512, v16f32, sub_ymm>;
95 defm : subvector_subreg_lowering<VR256, v4i64, VR512, v8i64, sub_ymm>;
96 defm : subvector_subreg_lowering<VR256, v4f64, VR512, v8f64, sub_ymm>;
97 defm : subvector_subreg_lowering<VR256, v16i16, VR512, v32i16, sub_ymm>;
98 defm : subvector_subreg_lowering<VR256, v32i8, VR512, v64i8, sub_ymm>;
101 multiclass subvector_store_lowering<string AlignedStr, string UnalignedStr,
102 RegisterClass RC, ValueType DstTy,
103 ValueType SrcTy, SubRegIndex SubIdx> {
104 def : Pat<(alignedstore (DstTy (extract_subvector
105 (SrcTy RC:$src), (iPTR 0))), addr:$dst),
106 (!cast<Instruction>("VMOV"#AlignedStr#"mr") addr:$dst,
107 (DstTy (EXTRACT_SUBREG RC:$src, SubIdx)))>;
109 def : Pat<(store (DstTy (extract_subvector
110 (SrcTy RC:$src), (iPTR 0))), addr:$dst),
111 (!cast<Instruction>("VMOV"#UnalignedStr#"mr") addr:$dst,
112 (DstTy (EXTRACT_SUBREG RC:$src, SubIdx)))>;
115 let Predicates = [HasAVX, NoVLX] in {
116 defm : subvector_store_lowering<"APD", "UPD", VR256X, v2f64, v4f64, sub_xmm>;
117 defm : subvector_store_lowering<"APS", "UPS", VR256X, v4f32, v8f32, sub_xmm>;
118 defm : subvector_store_lowering<"DQA", "DQU", VR256X, v2i64, v4i64, sub_xmm>;
119 defm : subvector_store_lowering<"DQA", "DQU", VR256X, v4i32, v8i32, sub_xmm>;
120 defm : subvector_store_lowering<"DQA", "DQU", VR256X, v8i16, v16i16, sub_xmm>;
121 defm : subvector_store_lowering<"DQA", "DQU", VR256X, v16i8, v32i8, sub_xmm>;
124 let Predicates = [HasVLX] in {
125 // Special patterns for storing subvector extracts of lower 128-bits
126 // Its cheaper to just use VMOVAPS/VMOVUPS instead of VEXTRACTF128mr
127 defm : subvector_store_lowering<"APDZ128", "UPDZ128", VR256X, v2f64, v4f64,
129 defm : subvector_store_lowering<"APSZ128", "UPSZ128", VR256X, v4f32, v8f32,
131 defm : subvector_store_lowering<"DQA64Z128", "DQU64Z128", VR256X, v2i64,
133 defm : subvector_store_lowering<"DQA64Z128", "DQU64Z128", VR256X, v4i32,
135 defm : subvector_store_lowering<"DQA64Z128", "DQU64Z128", VR256X, v8i16,
137 defm : subvector_store_lowering<"DQA64Z128", "DQU64Z128", VR256X, v16i8,
140 // Special patterns for storing subvector extracts of lower 128-bits of 512.
141 // Its cheaper to just use VMOVAPS/VMOVUPS instead of VEXTRACTF128mr
142 defm : subvector_store_lowering<"APDZ128", "UPDZ128", VR512, v2f64, v8f64,
144 defm : subvector_store_lowering<"APSZ128", "UPSZ128", VR512, v4f32, v16f32,
146 defm : subvector_store_lowering<"DQA64Z128", "DQU64Z128", VR512, v2i64,
148 defm : subvector_store_lowering<"DQA64Z128", "DQU64Z128", VR512, v4i32,
150 defm : subvector_store_lowering<"DQA64Z128", "DQU64Z128", VR512, v8i16,
152 defm : subvector_store_lowering<"DQA64Z128", "DQU64Z128", VR512, v16i8,
155 // Special patterns for storing subvector extracts of lower 256-bits of 512.
156 // Its cheaper to just use VMOVAPS/VMOVUPS instead of VEXTRACTF128mr
157 defm : subvector_store_lowering<"APDZ256", "UPDZ256", VR512, v4f64, v8f64,
159 defm : subvector_store_lowering<"APSZ256", "UPSZ256", VR512, v8f32, v16f32,
161 defm : subvector_store_lowering<"DQA64Z256", "DQU64Z256", VR512, v4i64,
163 defm : subvector_store_lowering<"DQA64Z256", "DQU64Z256", VR512, v8i32,
165 defm : subvector_store_lowering<"DQA64Z256", "DQU64Z256", VR512, v16i16,
167 defm : subvector_store_lowering<"DQA64Z256", "DQU64Z256", VR512, v32i8,
171 // If we're inserting into an all zeros vector, just use a plain move which
172 // will zero the upper bits. A post-isel hook will take care of removing
173 // any moves that we can prove are unnecessary.
174 multiclass subvec_zero_lowering<string MoveStr,
175 RegisterClass RC, ValueType DstTy,
176 ValueType SrcTy, ValueType ZeroTy,
177 SubRegIndex SubIdx> {
178 def : Pat<(DstTy (insert_subvector (bitconvert (ZeroTy immAllZerosV)),
179 (SrcTy RC:$src), (iPTR 0))),
180 (SUBREG_TO_REG (i64 0),
181 (SrcTy (!cast<Instruction>("VMOV"#MoveStr#"rr") RC:$src)), SubIdx)>;
184 let Predicates = [HasAVX, NoVLX] in {
185 defm : subvec_zero_lowering<"APD", VR128, v4f64, v2f64, v8i32, sub_xmm>;
186 defm : subvec_zero_lowering<"APS", VR128, v8f32, v4f32, v8i32, sub_xmm>;
187 defm : subvec_zero_lowering<"DQA", VR128, v4i64, v2i64, v8i32, sub_xmm>;
188 defm : subvec_zero_lowering<"DQA", VR128, v8i32, v4i32, v8i32, sub_xmm>;
189 defm : subvec_zero_lowering<"DQA", VR128, v16i16, v8i16, v8i32, sub_xmm>;
190 defm : subvec_zero_lowering<"DQA", VR128, v32i8, v16i8, v8i32, sub_xmm>;
193 let Predicates = [HasVLX] in {
194 defm : subvec_zero_lowering<"APDZ128", VR128X, v4f64, v2f64, v8i32, sub_xmm>;
195 defm : subvec_zero_lowering<"APSZ128", VR128X, v8f32, v4f32, v8i32, sub_xmm>;
196 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v4i64, v2i64, v8i32, sub_xmm>;
197 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v8i32, v4i32, v8i32, sub_xmm>;
198 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v16i16, v8i16, v8i32, sub_xmm>;
199 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v32i8, v16i8, v8i32, sub_xmm>;
201 defm : subvec_zero_lowering<"APDZ128", VR128X, v8f64, v2f64, v16i32, sub_xmm>;
202 defm : subvec_zero_lowering<"APSZ128", VR128X, v16f32, v4f32, v16i32, sub_xmm>;
203 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v8i64, v2i64, v16i32, sub_xmm>;
204 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v16i32, v4i32, v16i32, sub_xmm>;
205 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v32i16, v8i16, v16i32, sub_xmm>;
206 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v64i8, v16i8, v16i32, sub_xmm>;
208 defm : subvec_zero_lowering<"APDZ256", VR256X, v8f64, v4f64, v16i32, sub_ymm>;
209 defm : subvec_zero_lowering<"APSZ256", VR256X, v16f32, v8f32, v16i32, sub_ymm>;
210 defm : subvec_zero_lowering<"DQA64Z256", VR256X, v8i64, v4i64, v16i32, sub_ymm>;
211 defm : subvec_zero_lowering<"DQA64Z256", VR256X, v16i32, v8i32, v16i32, sub_ymm>;
212 defm : subvec_zero_lowering<"DQA64Z256", VR256X, v32i16, v16i16, v16i32, sub_ymm>;
213 defm : subvec_zero_lowering<"DQA64Z256", VR256X, v64i8, v32i8, v16i32, sub_ymm>;
216 let Predicates = [HasAVX512, NoVLX] in {
217 defm : subvec_zero_lowering<"APD", VR128, v8f64, v2f64, v16i32, sub_xmm>;
218 defm : subvec_zero_lowering<"APS", VR128, v16f32, v4f32, v16i32, sub_xmm>;
219 defm : subvec_zero_lowering<"DQA", VR128, v8i64, v2i64, v16i32, sub_xmm>;
220 defm : subvec_zero_lowering<"DQA", VR128, v16i32, v4i32, v16i32, sub_xmm>;
221 defm : subvec_zero_lowering<"DQA", VR128, v32i16, v8i16, v16i32, sub_xmm>;
222 defm : subvec_zero_lowering<"DQA", VR128, v64i8, v16i8, v16i32, sub_xmm>;
224 defm : subvec_zero_lowering<"APDY", VR256, v8f64, v4f64, v16i32, sub_ymm>;
225 defm : subvec_zero_lowering<"APSY", VR256, v16f32, v8f32, v16i32, sub_ymm>;
226 defm : subvec_zero_lowering<"DQAY", VR256, v8i64, v4i64, v16i32, sub_ymm>;
227 defm : subvec_zero_lowering<"DQAY", VR256, v16i32, v8i32, v16i32, sub_ymm>;
228 defm : subvec_zero_lowering<"DQAY", VR256, v32i16, v16i16, v16i32, sub_ymm>;
229 defm : subvec_zero_lowering<"DQAY", VR256, v64i8, v32i8, v16i32, sub_ymm>;
232 class maskzeroupper<ValueType vt, RegisterClass RC> :
233 PatLeaf<(vt RC:$src), [{
234 return isMaskZeroExtended(N);
237 def maskzeroupperv1i1 : maskzeroupper<v1i1, VK1>;
238 def maskzeroupperv2i1 : maskzeroupper<v2i1, VK2>;
239 def maskzeroupperv4i1 : maskzeroupper<v4i1, VK4>;
240 def maskzeroupperv8i1 : maskzeroupper<v8i1, VK8>;
241 def maskzeroupperv16i1 : maskzeroupper<v16i1, VK16>;
242 def maskzeroupperv32i1 : maskzeroupper<v32i1, VK32>;
244 // The patterns determine if we can depend on the upper bits of a mask register
245 // being zeroed by the previous operation so that we can skip explicit
247 let Predicates = [HasBWI] in {
248 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
249 maskzeroupperv1i1:$src, (iPTR 0))),
250 (COPY_TO_REGCLASS VK1:$src, VK32)>;
251 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
252 maskzeroupperv8i1:$src, (iPTR 0))),
253 (COPY_TO_REGCLASS VK8:$src, VK32)>;
254 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
255 maskzeroupperv16i1:$src, (iPTR 0))),
256 (COPY_TO_REGCLASS VK16:$src, VK32)>;
258 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
259 maskzeroupperv1i1:$src, (iPTR 0))),
260 (COPY_TO_REGCLASS VK1:$src, VK64)>;
261 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
262 maskzeroupperv8i1:$src, (iPTR 0))),
263 (COPY_TO_REGCLASS VK8:$src, VK64)>;
264 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
265 maskzeroupperv16i1:$src, (iPTR 0))),
266 (COPY_TO_REGCLASS VK16:$src, VK64)>;
267 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
268 maskzeroupperv32i1:$src, (iPTR 0))),
269 (COPY_TO_REGCLASS VK32:$src, VK64)>;
272 let Predicates = [HasAVX512] in {
273 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
274 maskzeroupperv1i1:$src, (iPTR 0))),
275 (COPY_TO_REGCLASS VK1:$src, VK16)>;
276 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
277 maskzeroupperv8i1:$src, (iPTR 0))),
278 (COPY_TO_REGCLASS VK8:$src, VK16)>;
281 let Predicates = [HasDQI] in {
282 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
283 maskzeroupperv1i1:$src, (iPTR 0))),
284 (COPY_TO_REGCLASS VK1:$src, VK8)>;
287 let Predicates = [HasVLX, HasDQI] in {
288 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
289 maskzeroupperv2i1:$src, (iPTR 0))),
290 (COPY_TO_REGCLASS VK2:$src, VK8)>;
291 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
292 maskzeroupperv4i1:$src, (iPTR 0))),
293 (COPY_TO_REGCLASS VK4:$src, VK8)>;
296 let Predicates = [HasVLX] in {
297 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
298 maskzeroupperv2i1:$src, (iPTR 0))),
299 (COPY_TO_REGCLASS VK2:$src, VK16)>;
300 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
301 maskzeroupperv4i1:$src, (iPTR 0))),
302 (COPY_TO_REGCLASS VK4:$src, VK16)>;
305 let Predicates = [HasBWI, HasVLX] in {
306 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
307 maskzeroupperv2i1:$src, (iPTR 0))),
308 (COPY_TO_REGCLASS VK2:$src, VK32)>;
309 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
310 maskzeroupperv4i1:$src, (iPTR 0))),
311 (COPY_TO_REGCLASS VK4:$src, VK32)>;
312 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
313 maskzeroupperv2i1:$src, (iPTR 0))),
314 (COPY_TO_REGCLASS VK2:$src, VK64)>;
315 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
316 maskzeroupperv4i1:$src, (iPTR 0))),
317 (COPY_TO_REGCLASS VK4:$src, VK64)>;
320 // If the bits are not zero we have to fall back to explicitly zeroing by
322 let Predicates = [HasAVX512] in {
323 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
324 (v1i1 VK1:$mask), (iPTR 0))),
325 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK1:$mask, VK16),
328 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
329 (v2i1 VK2:$mask), (iPTR 0))),
330 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK2:$mask, VK16),
333 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
334 (v4i1 VK4:$mask), (iPTR 0))),
335 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK4:$mask, VK16),
339 let Predicates = [HasAVX512, NoDQI] in {
340 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
341 (v8i1 VK8:$mask), (iPTR 0))),
342 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK8:$mask, VK16),
346 let Predicates = [HasDQI] in {
347 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
348 (v8i1 VK8:$mask), (iPTR 0))),
349 (COPY_TO_REGCLASS (KMOVBkk VK8:$mask), VK16)>;
351 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
352 (v1i1 VK1:$mask), (iPTR 0))),
353 (KSHIFTRBri (KSHIFTLBri (COPY_TO_REGCLASS VK1:$mask, VK8),
355 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
356 (v2i1 VK2:$mask), (iPTR 0))),
357 (KSHIFTRBri (KSHIFTLBri (COPY_TO_REGCLASS VK2:$mask, VK8),
359 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
360 (v4i1 VK4:$mask), (iPTR 0))),
361 (KSHIFTRBri (KSHIFTLBri (COPY_TO_REGCLASS VK4:$mask, VK8),
365 let Predicates = [HasBWI] in {
366 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
367 (v16i1 VK16:$mask), (iPTR 0))),
368 (COPY_TO_REGCLASS (KMOVWkk VK16:$mask), VK32)>;
370 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
371 (v16i1 VK16:$mask), (iPTR 0))),
372 (COPY_TO_REGCLASS (KMOVWkk VK16:$mask), VK64)>;
373 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
374 (v32i1 VK32:$mask), (iPTR 0))),
375 (COPY_TO_REGCLASS (KMOVDkk VK32:$mask), VK64)>;
378 let Predicates = [HasBWI, NoDQI] in {
379 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
380 (v8i1 VK8:$mask), (iPTR 0))),
381 (KSHIFTRDri (KSHIFTLDri (COPY_TO_REGCLASS VK8:$mask, VK32),
384 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
385 (v8i1 VK8:$mask), (iPTR 0))),
386 (KSHIFTRQri (KSHIFTLQri (COPY_TO_REGCLASS VK8:$mask, VK64),
390 let Predicates = [HasBWI, HasDQI] in {
391 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
392 (v8i1 VK8:$mask), (iPTR 0))),
393 (COPY_TO_REGCLASS (KMOVBkk VK8:$mask), VK32)>;
395 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
396 (v8i1 VK8:$mask), (iPTR 0))),
397 (COPY_TO_REGCLASS (KMOVBkk VK8:$mask), VK64)>;
400 let Predicates = [HasBWI] in {
401 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
402 (v1i1 VK1:$mask), (iPTR 0))),
403 (KSHIFTRDri (KSHIFTLDri (COPY_TO_REGCLASS VK1:$mask, VK32),
405 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
406 (v2i1 VK2:$mask), (iPTR 0))),
407 (KSHIFTRDri (KSHIFTLDri (COPY_TO_REGCLASS VK2:$mask, VK32),
409 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
410 (v4i1 VK4:$mask), (iPTR 0))),
411 (KSHIFTRDri (KSHIFTLDri (COPY_TO_REGCLASS VK4:$mask, VK32),
414 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
415 (v1i1 VK1:$mask), (iPTR 0))),
416 (KSHIFTRQri (KSHIFTLQri (COPY_TO_REGCLASS VK1:$mask, VK64),
418 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
419 (v2i1 VK2:$mask), (iPTR 0))),
420 (KSHIFTRQri (KSHIFTLQri (COPY_TO_REGCLASS VK2:$mask, VK64),
422 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
423 (v4i1 VK4:$mask), (iPTR 0))),
424 (KSHIFTRQri (KSHIFTLQri (COPY_TO_REGCLASS VK4:$mask, VK64),
428 //===----------------------------------------------------------------------===//
429 // Extra selection patterns for f128, f128mem
431 // movaps is shorter than movdqa. movaps is in SSE and movdqa is in SSE2.
432 let Predicates = [NoAVX] in {
433 def : Pat<(alignedstore (f128 VR128:$src), addr:$dst),
434 (MOVAPSmr addr:$dst, VR128:$src)>;
435 def : Pat<(store (f128 VR128:$src), addr:$dst),
436 (MOVUPSmr addr:$dst, VR128:$src)>;
438 def : Pat<(alignedloadf128 addr:$src),
439 (MOVAPSrm addr:$src)>;
440 def : Pat<(loadf128 addr:$src),
441 (MOVUPSrm addr:$src)>;
444 let Predicates = [HasAVX, NoVLX] in {
445 def : Pat<(alignedstore (f128 VR128:$src), addr:$dst),
446 (VMOVAPSmr addr:$dst, VR128:$src)>;
447 def : Pat<(store (f128 VR128:$src), addr:$dst),
448 (VMOVUPSmr addr:$dst, VR128:$src)>;
450 def : Pat<(alignedloadf128 addr:$src),
451 (VMOVAPSrm addr:$src)>;
452 def : Pat<(loadf128 addr:$src),
453 (VMOVUPSrm addr:$src)>;
456 let Predicates = [HasVLX] in {
457 def : Pat<(alignedstore (f128 VR128X:$src), addr:$dst),
458 (VMOVAPSZ128mr addr:$dst, VR128X:$src)>;
459 def : Pat<(store (f128 VR128X:$src), addr:$dst),
460 (VMOVUPSZ128mr addr:$dst, VR128X:$src)>;
462 def : Pat<(alignedloadf128 addr:$src),
463 (VMOVAPSZ128rm addr:$src)>;
464 def : Pat<(loadf128 addr:$src),
465 (VMOVUPSZ128rm addr:$src)>;
468 let Predicates = [UseSSE1] in {
469 // andps is shorter than andpd or pand. andps is SSE and andpd/pand are in SSE2
470 def : Pat<(f128 (X86fand VR128:$src1, (memopf128 addr:$src2))),
471 (ANDPSrm VR128:$src1, f128mem:$src2)>;
473 def : Pat<(f128 (X86fand VR128:$src1, VR128:$src2)),
474 (ANDPSrr VR128:$src1, VR128:$src2)>;
476 def : Pat<(f128 (X86for VR128:$src1, (memopf128 addr:$src2))),
477 (ORPSrm VR128:$src1, f128mem:$src2)>;
479 def : Pat<(f128 (X86for VR128:$src1, VR128:$src2)),
480 (ORPSrr VR128:$src1, VR128:$src2)>;
482 def : Pat<(f128 (X86fxor VR128:$src1, (memopf128 addr:$src2))),
483 (XORPSrm VR128:$src1, f128mem:$src2)>;
485 def : Pat<(f128 (X86fxor VR128:$src1, VR128:$src2)),
486 (XORPSrr VR128:$src1, VR128:$src2)>;
489 let Predicates = [HasAVX] in {
490 // andps is shorter than andpd or pand. andps is SSE and andpd/pand are in SSE2
491 def : Pat<(f128 (X86fand VR128:$src1, (loadf128 addr:$src2))),
492 (VANDPSrm VR128:$src1, f128mem:$src2)>;
494 def : Pat<(f128 (X86fand VR128:$src1, VR128:$src2)),
495 (VANDPSrr VR128:$src1, VR128:$src2)>;
497 def : Pat<(f128 (X86for VR128:$src1, (loadf128 addr:$src2))),
498 (VORPSrm VR128:$src1, f128mem:$src2)>;
500 def : Pat<(f128 (X86for VR128:$src1, VR128:$src2)),
501 (VORPSrr VR128:$src1, VR128:$src2)>;
503 def : Pat<(f128 (X86fxor VR128:$src1, (loadf128 addr:$src2))),
504 (VXORPSrm VR128:$src1, f128mem:$src2)>;
506 def : Pat<(f128 (X86fxor VR128:$src1, VR128:$src2)),
507 (VXORPSrr VR128:$src1, VR128:$src2)>;