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<(f16 (extractelt (v8f16 VR128X:$src), (iPTR 0))),
29 (COPY_TO_REGCLASS (v8f16 VR128X:$src), FR16X)>;
30 def : Pat<(f32 (extractelt (v4f32 VR128X:$src), (iPTR 0))),
31 (COPY_TO_REGCLASS (v4f32 VR128X:$src), FR32X)>;
32 def : Pat<(f64 (extractelt (v2f64 VR128X:$src), (iPTR 0))),
33 (COPY_TO_REGCLASS (v2f64 VR128X:$src), FR64X)>;
36 let Predicates = [NoVLX] in {
37 def : Pat<(v8f16 (scalar_to_vector FR16X:$src)),
38 (COPY_TO_REGCLASS FR16X:$src, VR128)>;
39 // Implicitly promote a 32-bit scalar to a vector.
40 def : Pat<(v4f32 (scalar_to_vector FR32:$src)),
41 (COPY_TO_REGCLASS FR32:$src, VR128)>;
42 // Implicitly promote a 64-bit scalar to a vector.
43 def : Pat<(v2f64 (scalar_to_vector FR64:$src)),
44 (COPY_TO_REGCLASS FR64:$src, VR128)>;
47 let Predicates = [HasVLX] in {
48 def : Pat<(v8f16 (scalar_to_vector FR16X:$src)),
49 (COPY_TO_REGCLASS FR16X:$src, VR128X)>;
50 // Implicitly promote a 32-bit scalar to a vector.
51 def : Pat<(v4f32 (scalar_to_vector FR32X:$src)),
52 (COPY_TO_REGCLASS FR32X:$src, VR128X)>;
53 // Implicitly promote a 64-bit scalar to a vector.
54 def : Pat<(v2f64 (scalar_to_vector FR64X:$src)),
55 (COPY_TO_REGCLASS FR64X:$src, VR128X)>;
58 //===----------------------------------------------------------------------===//
60 //===----------------------------------------------------------------------===//
62 // Patterns for insert_subvector/extract_subvector to/from index=0
63 multiclass subvector_subreg_lowering<RegisterClass subRC, ValueType subVT,
64 RegisterClass RC, ValueType VT,
66 def : Pat<(subVT (extract_subvector (VT RC:$src), (iPTR 0))),
67 (subVT (EXTRACT_SUBREG RC:$src, subIdx))>;
69 def : Pat<(VT (insert_subvector undef, subRC:$src, (iPTR 0))),
70 (VT (INSERT_SUBREG (IMPLICIT_DEF), subRC:$src, subIdx))>;
73 // A 128-bit subvector extract from the first 256-bit vector position is a
74 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
75 // insert to the first 256-bit vector position is a subregister copy that needs
77 defm : subvector_subreg_lowering<VR128, v4i32, VR256, v8i32, sub_xmm>;
78 defm : subvector_subreg_lowering<VR128, v4f32, VR256, v8f32, sub_xmm>;
79 defm : subvector_subreg_lowering<VR128, v2i64, VR256, v4i64, sub_xmm>;
80 defm : subvector_subreg_lowering<VR128, v2f64, VR256, v4f64, sub_xmm>;
81 defm : subvector_subreg_lowering<VR128, v8i16, VR256, v16i16, sub_xmm>;
82 defm : subvector_subreg_lowering<VR128, v16i8, VR256, v32i8, sub_xmm>;
83 defm : subvector_subreg_lowering<VR128, v8f16, VR256, v16f16, sub_xmm>;
85 // A 128-bit subvector extract from the first 512-bit vector position is a
86 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
87 // insert to the first 512-bit vector position is a subregister copy that needs
89 defm : subvector_subreg_lowering<VR128, v4i32, VR512, v16i32, sub_xmm>;
90 defm : subvector_subreg_lowering<VR128, v4f32, VR512, v16f32, sub_xmm>;
91 defm : subvector_subreg_lowering<VR128, v2i64, VR512, v8i64, sub_xmm>;
92 defm : subvector_subreg_lowering<VR128, v2f64, VR512, v8f64, sub_xmm>;
93 defm : subvector_subreg_lowering<VR128, v8i16, VR512, v32i16, sub_xmm>;
94 defm : subvector_subreg_lowering<VR128, v16i8, VR512, v64i8, sub_xmm>;
95 defm : subvector_subreg_lowering<VR128, v8f16, VR512, v32f16, sub_xmm>;
97 // A 128-bit subvector extract from the first 512-bit vector position is a
98 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
99 // insert to the first 512-bit vector position is a subregister copy that needs
101 defm : subvector_subreg_lowering<VR256, v8i32, VR512, v16i32, sub_ymm>;
102 defm : subvector_subreg_lowering<VR256, v8f32, VR512, v16f32, sub_ymm>;
103 defm : subvector_subreg_lowering<VR256, v4i64, VR512, v8i64, sub_ymm>;
104 defm : subvector_subreg_lowering<VR256, v4f64, VR512, v8f64, sub_ymm>;
105 defm : subvector_subreg_lowering<VR256, v16i16, VR512, v32i16, sub_ymm>;
106 defm : subvector_subreg_lowering<VR256, v32i8, VR512, v64i8, sub_ymm>;
107 defm : subvector_subreg_lowering<VR256, v16f16, VR512, v32f16, sub_ymm>;
110 // If we're inserting into an all zeros vector, just use a plain move which
111 // will zero the upper bits. A post-isel hook will take care of removing
112 // any moves that we can prove are unnecessary.
113 multiclass subvec_zero_lowering<string MoveStr,
114 RegisterClass RC, ValueType DstTy,
115 ValueType SrcTy, ValueType ZeroTy,
116 SubRegIndex SubIdx> {
117 def : Pat<(DstTy (insert_subvector immAllZerosV,
118 (SrcTy RC:$src), (iPTR 0))),
119 (SUBREG_TO_REG (i64 0),
120 (SrcTy (!cast<Instruction>("VMOV"#MoveStr#"rr") RC:$src)), SubIdx)>;
123 let Predicates = [HasAVX, NoVLX] in {
124 defm : subvec_zero_lowering<"APD", VR128, v4f64, v2f64, v8i32, sub_xmm>;
125 defm : subvec_zero_lowering<"APS", VR128, v8f32, v4f32, v8i32, sub_xmm>;
126 defm : subvec_zero_lowering<"DQA", VR128, v4i64, v2i64, v8i32, sub_xmm>;
127 defm : subvec_zero_lowering<"DQA", VR128, v8i32, v4i32, v8i32, sub_xmm>;
128 defm : subvec_zero_lowering<"DQA", VR128, v16i16, v8i16, v8i32, sub_xmm>;
129 defm : subvec_zero_lowering<"DQA", VR128, v32i8, v16i8, v8i32, sub_xmm>;
132 let Predicates = [HasVLX] in {
133 defm : subvec_zero_lowering<"APDZ128", VR128X, v4f64, v2f64, v8i32, sub_xmm>;
134 defm : subvec_zero_lowering<"APSZ128", VR128X, v8f32, v4f32, v8i32, sub_xmm>;
135 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v4i64, v2i64, v8i32, sub_xmm>;
136 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v8i32, v4i32, v8i32, sub_xmm>;
137 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v16i16, v8i16, v8i32, sub_xmm>;
138 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v32i8, v16i8, v8i32, sub_xmm>;
140 defm : subvec_zero_lowering<"APDZ128", VR128X, v8f64, v2f64, v16i32, sub_xmm>;
141 defm : subvec_zero_lowering<"APSZ128", VR128X, v16f32, v4f32, v16i32, sub_xmm>;
142 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v8i64, v2i64, v16i32, sub_xmm>;
143 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v16i32, v4i32, v16i32, sub_xmm>;
144 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v32i16, v8i16, v16i32, sub_xmm>;
145 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v64i8, v16i8, v16i32, sub_xmm>;
147 defm : subvec_zero_lowering<"APDZ256", VR256X, v8f64, v4f64, v16i32, sub_ymm>;
148 defm : subvec_zero_lowering<"APSZ256", VR256X, v16f32, v8f32, v16i32, sub_ymm>;
149 defm : subvec_zero_lowering<"DQA64Z256", VR256X, v8i64, v4i64, v16i32, sub_ymm>;
150 defm : subvec_zero_lowering<"DQA64Z256", VR256X, v16i32, v8i32, v16i32, sub_ymm>;
151 defm : subvec_zero_lowering<"DQA64Z256", VR256X, v32i16, v16i16, v16i32, sub_ymm>;
152 defm : subvec_zero_lowering<"DQA64Z256", VR256X, v64i8, v32i8, v16i32, sub_ymm>;
155 let Predicates = [HasAVX512, NoVLX] in {
156 defm : subvec_zero_lowering<"APD", VR128, v8f64, v2f64, v16i32, sub_xmm>;
157 defm : subvec_zero_lowering<"APS", VR128, v16f32, v4f32, v16i32, sub_xmm>;
158 defm : subvec_zero_lowering<"DQA", VR128, v8i64, v2i64, v16i32, sub_xmm>;
159 defm : subvec_zero_lowering<"DQA", VR128, v16i32, v4i32, v16i32, sub_xmm>;
160 defm : subvec_zero_lowering<"DQA", VR128, v32i16, v8i16, v16i32, sub_xmm>;
161 defm : subvec_zero_lowering<"DQA", VR128, v64i8, v16i8, v16i32, sub_xmm>;
163 defm : subvec_zero_lowering<"APDY", VR256, v8f64, v4f64, v16i32, sub_ymm>;
164 defm : subvec_zero_lowering<"APSY", VR256, v16f32, v8f32, v16i32, sub_ymm>;
165 defm : subvec_zero_lowering<"DQAY", VR256, v8i64, v4i64, v16i32, sub_ymm>;
166 defm : subvec_zero_lowering<"DQAY", VR256, v16i32, v8i32, v16i32, sub_ymm>;
167 defm : subvec_zero_lowering<"DQAY", VR256, v32i16, v16i16, v16i32, sub_ymm>;
168 defm : subvec_zero_lowering<"DQAY", VR256, v64i8, v32i8, v16i32, sub_ymm>;
171 let Predicates = [HasFP16, HasVLX] in {
172 defm : subvec_zero_lowering<"APSZ128", VR128X, v16f16, v8f16, v8i32, sub_xmm>;
173 defm : subvec_zero_lowering<"APSZ128", VR128X, v32f16, v8f16, v16i32, sub_xmm>;
174 defm : subvec_zero_lowering<"APSZ256", VR256X, v32f16, v16f16, v16i32, sub_ymm>;
177 class maskzeroupper<ValueType vt, RegisterClass RC> :
178 PatLeaf<(vt RC:$src), [{
179 return isMaskZeroExtended(N);
182 def maskzeroupperv1i1 : maskzeroupper<v1i1, VK1>;
183 def maskzeroupperv2i1 : maskzeroupper<v2i1, VK2>;
184 def maskzeroupperv4i1 : maskzeroupper<v4i1, VK4>;
185 def maskzeroupperv8i1 : maskzeroupper<v8i1, VK8>;
186 def maskzeroupperv16i1 : maskzeroupper<v16i1, VK16>;
187 def maskzeroupperv32i1 : maskzeroupper<v32i1, VK32>;
189 // The patterns determine if we can depend on the upper bits of a mask register
190 // being zeroed by the previous operation so that we can skip explicit
192 let Predicates = [HasBWI] in {
193 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
194 maskzeroupperv1i1:$src, (iPTR 0))),
195 (COPY_TO_REGCLASS VK1:$src, VK32)>;
196 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
197 maskzeroupperv8i1:$src, (iPTR 0))),
198 (COPY_TO_REGCLASS VK8:$src, VK32)>;
199 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
200 maskzeroupperv16i1:$src, (iPTR 0))),
201 (COPY_TO_REGCLASS VK16:$src, VK32)>;
203 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
204 maskzeroupperv1i1:$src, (iPTR 0))),
205 (COPY_TO_REGCLASS VK1:$src, VK64)>;
206 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
207 maskzeroupperv8i1:$src, (iPTR 0))),
208 (COPY_TO_REGCLASS VK8:$src, VK64)>;
209 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
210 maskzeroupperv16i1:$src, (iPTR 0))),
211 (COPY_TO_REGCLASS VK16:$src, VK64)>;
212 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
213 maskzeroupperv32i1:$src, (iPTR 0))),
214 (COPY_TO_REGCLASS VK32:$src, VK64)>;
217 let Predicates = [HasAVX512] in {
218 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
219 maskzeroupperv1i1:$src, (iPTR 0))),
220 (COPY_TO_REGCLASS VK1:$src, VK16)>;
221 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
222 maskzeroupperv8i1:$src, (iPTR 0))),
223 (COPY_TO_REGCLASS VK8:$src, VK16)>;
226 let Predicates = [HasDQI] in {
227 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
228 maskzeroupperv1i1:$src, (iPTR 0))),
229 (COPY_TO_REGCLASS VK1:$src, VK8)>;
232 let Predicates = [HasVLX, HasDQI] in {
233 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
234 maskzeroupperv2i1:$src, (iPTR 0))),
235 (COPY_TO_REGCLASS VK2:$src, VK8)>;
236 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
237 maskzeroupperv4i1:$src, (iPTR 0))),
238 (COPY_TO_REGCLASS VK4:$src, VK8)>;
241 let Predicates = [HasVLX] in {
242 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
243 maskzeroupperv2i1:$src, (iPTR 0))),
244 (COPY_TO_REGCLASS VK2:$src, VK16)>;
245 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
246 maskzeroupperv4i1:$src, (iPTR 0))),
247 (COPY_TO_REGCLASS VK4:$src, VK16)>;
250 let Predicates = [HasBWI, HasVLX] in {
251 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
252 maskzeroupperv2i1:$src, (iPTR 0))),
253 (COPY_TO_REGCLASS VK2:$src, VK32)>;
254 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
255 maskzeroupperv4i1:$src, (iPTR 0))),
256 (COPY_TO_REGCLASS VK4:$src, VK32)>;
257 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
258 maskzeroupperv2i1:$src, (iPTR 0))),
259 (COPY_TO_REGCLASS VK2:$src, VK64)>;
260 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
261 maskzeroupperv4i1:$src, (iPTR 0))),
262 (COPY_TO_REGCLASS VK4:$src, VK64)>;
265 // If the bits are not zero we have to fall back to explicitly zeroing by
267 let Predicates = [HasAVX512] in {
268 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
269 (v1i1 VK1:$mask), (iPTR 0))),
270 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK1:$mask, VK16),
273 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
274 (v2i1 VK2:$mask), (iPTR 0))),
275 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK2:$mask, VK16),
278 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
279 (v4i1 VK4:$mask), (iPTR 0))),
280 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK4:$mask, VK16),
284 let Predicates = [HasAVX512, NoDQI] in {
285 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
286 (v8i1 VK8:$mask), (iPTR 0))),
287 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK8:$mask, VK16),
291 let Predicates = [HasDQI] in {
292 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
293 (v8i1 VK8:$mask), (iPTR 0))),
294 (COPY_TO_REGCLASS (KMOVBkk VK8:$mask), VK16)>;
296 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
297 (v1i1 VK1:$mask), (iPTR 0))),
298 (KSHIFTRBri (KSHIFTLBri (COPY_TO_REGCLASS VK1:$mask, VK8),
300 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
301 (v2i1 VK2:$mask), (iPTR 0))),
302 (KSHIFTRBri (KSHIFTLBri (COPY_TO_REGCLASS VK2:$mask, VK8),
304 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
305 (v4i1 VK4:$mask), (iPTR 0))),
306 (KSHIFTRBri (KSHIFTLBri (COPY_TO_REGCLASS VK4:$mask, VK8),
310 let Predicates = [HasBWI] in {
311 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
312 (v16i1 VK16:$mask), (iPTR 0))),
313 (COPY_TO_REGCLASS (KMOVWkk VK16:$mask), VK32)>;
315 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
316 (v16i1 VK16:$mask), (iPTR 0))),
317 (COPY_TO_REGCLASS (KMOVWkk VK16:$mask), VK64)>;
318 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
319 (v32i1 VK32:$mask), (iPTR 0))),
320 (COPY_TO_REGCLASS (KMOVDkk VK32:$mask), VK64)>;
323 let Predicates = [HasBWI, NoDQI] in {
324 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
325 (v8i1 VK8:$mask), (iPTR 0))),
326 (KSHIFTRDri (KSHIFTLDri (COPY_TO_REGCLASS VK8:$mask, VK32),
329 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
330 (v8i1 VK8:$mask), (iPTR 0))),
331 (KSHIFTRQri (KSHIFTLQri (COPY_TO_REGCLASS VK8:$mask, VK64),
335 let Predicates = [HasBWI, HasDQI] in {
336 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
337 (v8i1 VK8:$mask), (iPTR 0))),
338 (COPY_TO_REGCLASS (KMOVBkk VK8:$mask), VK32)>;
340 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
341 (v8i1 VK8:$mask), (iPTR 0))),
342 (COPY_TO_REGCLASS (KMOVBkk VK8:$mask), VK64)>;
345 let Predicates = [HasBWI] in {
346 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
347 (v1i1 VK1:$mask), (iPTR 0))),
348 (KSHIFTRDri (KSHIFTLDri (COPY_TO_REGCLASS VK1:$mask, VK32),
350 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
351 (v2i1 VK2:$mask), (iPTR 0))),
352 (KSHIFTRDri (KSHIFTLDri (COPY_TO_REGCLASS VK2:$mask, VK32),
354 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
355 (v4i1 VK4:$mask), (iPTR 0))),
356 (KSHIFTRDri (KSHIFTLDri (COPY_TO_REGCLASS VK4:$mask, VK32),
359 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
360 (v1i1 VK1:$mask), (iPTR 0))),
361 (KSHIFTRQri (KSHIFTLQri (COPY_TO_REGCLASS VK1:$mask, VK64),
363 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
364 (v2i1 VK2:$mask), (iPTR 0))),
365 (KSHIFTRQri (KSHIFTLQri (COPY_TO_REGCLASS VK2:$mask, VK64),
367 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
368 (v4i1 VK4:$mask), (iPTR 0))),
369 (KSHIFTRQri (KSHIFTLQri (COPY_TO_REGCLASS VK4:$mask, VK64),
373 //===----------------------------------------------------------------------===//
374 // Extra selection patterns for f128, f128mem
376 // movaps is shorter than movdqa. movaps is in SSE and movdqa is in SSE2.
377 let Predicates = [NoAVX] in {
378 def : Pat<(alignedstore (f128 VR128:$src), addr:$dst),
379 (MOVAPSmr addr:$dst, VR128:$src)>;
380 def : Pat<(store (f128 VR128:$src), addr:$dst),
381 (MOVUPSmr addr:$dst, VR128:$src)>;
383 def : Pat<(alignedloadf128 addr:$src),
384 (MOVAPSrm addr:$src)>;
385 def : Pat<(loadf128 addr:$src),
386 (MOVUPSrm addr:$src)>;
389 let Predicates = [HasAVX, NoVLX] in {
390 def : Pat<(alignedstore (f128 VR128:$src), addr:$dst),
391 (VMOVAPSmr addr:$dst, VR128:$src)>;
392 def : Pat<(store (f128 VR128:$src), addr:$dst),
393 (VMOVUPSmr addr:$dst, VR128:$src)>;
395 def : Pat<(alignedloadf128 addr:$src),
396 (VMOVAPSrm addr:$src)>;
397 def : Pat<(loadf128 addr:$src),
398 (VMOVUPSrm addr:$src)>;
401 let Predicates = [HasVLX] in {
402 def : Pat<(alignedstore (f128 VR128X:$src), addr:$dst),
403 (VMOVAPSZ128mr addr:$dst, VR128X:$src)>;
404 def : Pat<(store (f128 VR128X:$src), addr:$dst),
405 (VMOVUPSZ128mr addr:$dst, VR128X:$src)>;
407 def : Pat<(alignedloadf128 addr:$src),
408 (VMOVAPSZ128rm addr:$src)>;
409 def : Pat<(loadf128 addr:$src),
410 (VMOVUPSZ128rm addr:$src)>;
413 let Predicates = [UseSSE1] in {
414 // andps is shorter than andpd or pand. andps is SSE and andpd/pand are in SSE2
415 def : Pat<(f128 (X86fand VR128:$src1, (memopf128 addr:$src2))),
416 (ANDPSrm VR128:$src1, f128mem:$src2)>;
418 def : Pat<(f128 (X86fand VR128:$src1, VR128:$src2)),
419 (ANDPSrr VR128:$src1, VR128:$src2)>;
421 def : Pat<(f128 (X86for VR128:$src1, (memopf128 addr:$src2))),
422 (ORPSrm VR128:$src1, f128mem:$src2)>;
424 def : Pat<(f128 (X86for VR128:$src1, VR128:$src2)),
425 (ORPSrr VR128:$src1, VR128:$src2)>;
427 def : Pat<(f128 (X86fxor VR128:$src1, (memopf128 addr:$src2))),
428 (XORPSrm VR128:$src1, f128mem:$src2)>;
430 def : Pat<(f128 (X86fxor VR128:$src1, VR128:$src2)),
431 (XORPSrr VR128:$src1, VR128:$src2)>;
434 let Predicates = [HasAVX, NoVLX] in {
435 // andps is shorter than andpd or pand. andps is SSE and andpd/pand are in SSE2
436 def : Pat<(f128 (X86fand VR128:$src1, (loadf128 addr:$src2))),
437 (VANDPSrm VR128:$src1, f128mem:$src2)>;
439 def : Pat<(f128 (X86fand VR128:$src1, VR128:$src2)),
440 (VANDPSrr VR128:$src1, VR128:$src2)>;
442 def : Pat<(f128 (X86for VR128:$src1, (loadf128 addr:$src2))),
443 (VORPSrm VR128:$src1, f128mem:$src2)>;
445 def : Pat<(f128 (X86for VR128:$src1, VR128:$src2)),
446 (VORPSrr VR128:$src1, VR128:$src2)>;
448 def : Pat<(f128 (X86fxor VR128:$src1, (loadf128 addr:$src2))),
449 (VXORPSrm VR128:$src1, f128mem:$src2)>;
451 def : Pat<(f128 (X86fxor VR128:$src1, VR128:$src2)),
452 (VXORPSrr VR128:$src1, VR128:$src2)>;
455 let Predicates = [HasVLX] in {
456 // andps is shorter than andpd or pand. andps is SSE and andpd/pand are in SSE2
457 def : Pat<(f128 (X86fand VR128X:$src1, (loadf128 addr:$src2))),
458 (VANDPSZ128rm VR128X:$src1, f128mem:$src2)>;
460 def : Pat<(f128 (X86fand VR128X:$src1, VR128X:$src2)),
461 (VANDPSZ128rr VR128X:$src1, VR128X:$src2)>;
463 def : Pat<(f128 (X86for VR128X:$src1, (loadf128 addr:$src2))),
464 (VORPSZ128rm VR128X:$src1, f128mem:$src2)>;
466 def : Pat<(f128 (X86for VR128X:$src1, VR128X:$src2)),
467 (VORPSZ128rr VR128X:$src1, VR128X:$src2)>;
469 def : Pat<(f128 (X86fxor VR128X:$src1, (loadf128 addr:$src2))),
470 (VXORPSZ128rm VR128X:$src1, f128mem:$src2)>;
472 def : Pat<(f128 (X86fxor VR128X:$src1, VR128X:$src2)),
473 (VXORPSZ128rr VR128X:$src1, VR128X:$src2)>;