1//===- X86InstrVecCompiler.td - Vector Compiler Patterns ---*- tablegen -*-===// 2// 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 6// 7//===----------------------------------------------------------------------===// 8// 9// This file describes the various vector pseudo instructions used by the 10// compiler, as well as Pat patterns used during instruction selection. 11// 12//===----------------------------------------------------------------------===// 13 14//===----------------------------------------------------------------------===// 15// Non-instruction patterns 16//===----------------------------------------------------------------------===// 17 18let Predicates = [NoAVX512] in { 19 // A vector extract of the first f32/f64 position is a subregister copy 20 def : Pat<(f16 (extractelt (v8f16 VR128:$src), (iPTR 0))), 21 (COPY_TO_REGCLASS (v8f16 VR128:$src), FR16)>; 22 def : Pat<(f32 (extractelt (v4f32 VR128:$src), (iPTR 0))), 23 (COPY_TO_REGCLASS (v4f32 VR128:$src), FR32)>; 24 def : Pat<(f64 (extractelt (v2f64 VR128:$src), (iPTR 0))), 25 (COPY_TO_REGCLASS (v2f64 VR128:$src), FR64)>; 26} 27 28let Predicates = [HasAVX512] in { 29 // A vector extract of the first f32/f64 position is a subregister copy 30 def : Pat<(f16 (extractelt (v8f16 VR128X:$src), (iPTR 0))), 31 (COPY_TO_REGCLASS (v8f16 VR128X:$src), FR16X)>; 32 def : Pat<(f32 (extractelt (v4f32 VR128X:$src), (iPTR 0))), 33 (COPY_TO_REGCLASS (v4f32 VR128X:$src), FR32X)>; 34 def : Pat<(f64 (extractelt (v2f64 VR128X:$src), (iPTR 0))), 35 (COPY_TO_REGCLASS (v2f64 VR128X:$src), FR64X)>; 36} 37 38let Predicates = [NoVLX] in { 39 def : Pat<(v8f16 (scalar_to_vector FR16:$src)), 40 (COPY_TO_REGCLASS FR16:$src, VR128)>; 41 // Implicitly promote a 32-bit scalar to a vector. 42 def : Pat<(v4f32 (scalar_to_vector FR32:$src)), 43 (COPY_TO_REGCLASS FR32:$src, VR128)>; 44 // Implicitly promote a 64-bit scalar to a vector. 45 def : Pat<(v2f64 (scalar_to_vector FR64:$src)), 46 (COPY_TO_REGCLASS FR64:$src, VR128)>; 47} 48 49let Predicates = [HasVLX] in { 50 def : Pat<(v8f16 (scalar_to_vector FR16X:$src)), 51 (COPY_TO_REGCLASS FR16X:$src, VR128X)>; 52 // Implicitly promote a 32-bit scalar to a vector. 53 def : Pat<(v4f32 (scalar_to_vector FR32X:$src)), 54 (COPY_TO_REGCLASS FR32X:$src, VR128X)>; 55 // Implicitly promote a 64-bit scalar to a vector. 56 def : Pat<(v2f64 (scalar_to_vector FR64X:$src)), 57 (COPY_TO_REGCLASS FR64X:$src, VR128X)>; 58} 59 60//===----------------------------------------------------------------------===// 61// Subvector tricks 62//===----------------------------------------------------------------------===// 63 64// Patterns for insert_subvector/extract_subvector to/from index=0 65multiclass subvector_subreg_lowering<RegisterClass subRC, ValueType subVT, 66 RegisterClass RC, ValueType VT, 67 SubRegIndex subIdx> { 68 def : Pat<(subVT (extract_subvector (VT RC:$src), (iPTR 0))), 69 (subVT (EXTRACT_SUBREG RC:$src, subIdx))>; 70 71 def : Pat<(VT (insert_subvector undef_or_freeze_undef, subRC:$src, (iPTR 0))), 72 (VT (INSERT_SUBREG (IMPLICIT_DEF), subRC:$src, subIdx))>; 73} 74 75// A 128-bit subvector extract from the first 256-bit vector position is a 76// subregister copy that needs no instruction. Likewise, a 128-bit subvector 77// insert to the first 256-bit vector position is a subregister copy that needs 78// no instruction. 79defm : subvector_subreg_lowering<VR128, v4i32, VR256, v8i32, sub_xmm>; 80defm : subvector_subreg_lowering<VR128, v4f32, VR256, v8f32, sub_xmm>; 81defm : subvector_subreg_lowering<VR128, v2i64, VR256, v4i64, sub_xmm>; 82defm : subvector_subreg_lowering<VR128, v2f64, VR256, v4f64, sub_xmm>; 83defm : subvector_subreg_lowering<VR128, v8i16, VR256, v16i16, sub_xmm>; 84defm : subvector_subreg_lowering<VR128, v16i8, VR256, v32i8, sub_xmm>; 85defm : subvector_subreg_lowering<VR128, v8f16, VR256, v16f16, sub_xmm>; 86 87// A 128-bit subvector extract from the first 512-bit vector position is a 88// subregister copy that needs no instruction. Likewise, a 128-bit subvector 89// insert to the first 512-bit vector position is a subregister copy that needs 90// no instruction. 91defm : subvector_subreg_lowering<VR128, v4i32, VR512, v16i32, sub_xmm>; 92defm : subvector_subreg_lowering<VR128, v4f32, VR512, v16f32, sub_xmm>; 93defm : subvector_subreg_lowering<VR128, v2i64, VR512, v8i64, sub_xmm>; 94defm : subvector_subreg_lowering<VR128, v2f64, VR512, v8f64, sub_xmm>; 95defm : subvector_subreg_lowering<VR128, v8i16, VR512, v32i16, sub_xmm>; 96defm : subvector_subreg_lowering<VR128, v16i8, VR512, v64i8, sub_xmm>; 97defm : subvector_subreg_lowering<VR128, v8f16, VR512, v32f16, sub_xmm>; 98 99// A 128-bit subvector extract from the first 512-bit vector position is a 100// subregister copy that needs no instruction. Likewise, a 128-bit subvector 101// insert to the first 512-bit vector position is a subregister copy that needs 102// no instruction. 103defm : subvector_subreg_lowering<VR256, v8i32, VR512, v16i32, sub_ymm>; 104defm : subvector_subreg_lowering<VR256, v8f32, VR512, v16f32, sub_ymm>; 105defm : subvector_subreg_lowering<VR256, v4i64, VR512, v8i64, sub_ymm>; 106defm : subvector_subreg_lowering<VR256, v4f64, VR512, v8f64, sub_ymm>; 107defm : subvector_subreg_lowering<VR256, v16i16, VR512, v32i16, sub_ymm>; 108defm : subvector_subreg_lowering<VR256, v32i8, VR512, v64i8, sub_ymm>; 109defm : subvector_subreg_lowering<VR256, v16f16, VR512, v32f16, sub_ymm>; 110 111 112// If we're inserting into an all zeros vector, just use a plain move which 113// will zero the upper bits. A post-isel hook will take care of removing 114// any moves that we can prove are unnecessary. 115multiclass subvec_zero_lowering<string MoveStr, 116 RegisterClass RC, ValueType DstTy, 117 ValueType SrcTy, SubRegIndex SubIdx> { 118 def : Pat<(DstTy (insert_subvector immAllZerosV, 119 (SrcTy RC:$src), (iPTR 0))), 120 (SUBREG_TO_REG (i64 0), 121 (SrcTy (!cast<Instruction>("VMOV"#MoveStr#"rr") RC:$src)), SubIdx)>; 122} 123 124let Predicates = [HasAVX, NoVLX] in { 125 defm : subvec_zero_lowering<"APD", VR128, v4f64, v2f64, sub_xmm>; 126 defm : subvec_zero_lowering<"APS", VR128, v8f32, v4f32, sub_xmm>; 127 defm : subvec_zero_lowering<"DQA", VR128, v4i64, v2i64, sub_xmm>; 128 defm : subvec_zero_lowering<"DQA", VR128, v8i32, v4i32, sub_xmm>; 129 defm : subvec_zero_lowering<"DQA", VR128, v16i16, v8i16, sub_xmm>; 130 defm : subvec_zero_lowering<"DQA", VR128, v32i8, v16i8, sub_xmm>; 131} 132 133let Predicates = [HasAVXNECONVERT, NoVLX] in 134 defm : subvec_zero_lowering<"DQA", VR128, v16bf16, v8bf16, sub_xmm>; 135 136let Predicates = [HasVLX] in { 137 defm : subvec_zero_lowering<"APDZ128", VR128X, v4f64, v2f64, sub_xmm>; 138 defm : subvec_zero_lowering<"APSZ128", VR128X, v8f32, v4f32, sub_xmm>; 139 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v4i64, v2i64, sub_xmm>; 140 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v8i32, v4i32, sub_xmm>; 141 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v16i16, v8i16, sub_xmm>; 142 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v32i8, v16i8, sub_xmm>; 143 144 defm : subvec_zero_lowering<"APDZ128", VR128X, v8f64, v2f64, sub_xmm>; 145 defm : subvec_zero_lowering<"APSZ128", VR128X, v16f32, v4f32, sub_xmm>; 146 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v8i64, v2i64, sub_xmm>; 147 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v16i32, v4i32, sub_xmm>; 148 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v32i16, v8i16, sub_xmm>; 149 defm : subvec_zero_lowering<"DQA64Z128", VR128X, v64i8, v16i8, sub_xmm>; 150 151 defm : subvec_zero_lowering<"APDZ256", VR256X, v8f64, v4f64, sub_ymm>; 152 defm : subvec_zero_lowering<"APSZ256", VR256X, v16f32, v8f32, sub_ymm>; 153 defm : subvec_zero_lowering<"DQA64Z256", VR256X, v8i64, v4i64, sub_ymm>; 154 defm : subvec_zero_lowering<"DQA64Z256", VR256X, v16i32, v8i32, sub_ymm>; 155 defm : subvec_zero_lowering<"DQA64Z256", VR256X, v32i16, v16i16, sub_ymm>; 156 defm : subvec_zero_lowering<"DQA64Z256", VR256X, v64i8, v32i8, sub_ymm>; 157} 158 159let Predicates = [HasAVX512, NoVLX] in { 160 defm : subvec_zero_lowering<"APD", VR128, v8f64, v2f64, sub_xmm>; 161 defm : subvec_zero_lowering<"APS", VR128, v16f32, v4f32, sub_xmm>; 162 defm : subvec_zero_lowering<"DQA", VR128, v8i64, v2i64, sub_xmm>; 163 defm : subvec_zero_lowering<"DQA", VR128, v16i32, v4i32, sub_xmm>; 164 defm : subvec_zero_lowering<"DQA", VR128, v32i16, v8i16, sub_xmm>; 165 defm : subvec_zero_lowering<"DQA", VR128, v64i8, v16i8, sub_xmm>; 166 167 defm : subvec_zero_lowering<"APDY", VR256, v8f64, v4f64, sub_ymm>; 168 defm : subvec_zero_lowering<"APSY", VR256, v16f32, v8f32, sub_ymm>; 169 defm : subvec_zero_lowering<"DQAY", VR256, v8i64, v4i64, sub_ymm>; 170 defm : subvec_zero_lowering<"DQAY", VR256, v16i32, v8i32, sub_ymm>; 171 defm : subvec_zero_lowering<"DQAY", VR256, v32i16, v16i16, sub_ymm>; 172 defm : subvec_zero_lowering<"DQAY", VR256, v64i8, v32i8, sub_ymm>; 173} 174 175let Predicates = [HasFP16, HasVLX] in { 176 defm : subvec_zero_lowering<"APSZ128", VR128X, v16f16, v8f16, sub_xmm>; 177 defm : subvec_zero_lowering<"APSZ128", VR128X, v32f16, v8f16, sub_xmm>; 178 defm : subvec_zero_lowering<"APSZ256", VR256X, v32f16, v16f16, sub_ymm>; 179} 180 181let Predicates = [HasBF16, HasVLX] in { 182 defm : subvec_zero_lowering<"APSZ128", VR128X, v16bf16, v8bf16, sub_xmm>; 183 defm : subvec_zero_lowering<"APSZ128", VR128X, v32bf16, v8bf16, sub_xmm>; 184 defm : subvec_zero_lowering<"APSZ256", VR256X, v32bf16, v16bf16, sub_ymm>; 185} 186 187class maskzeroupper<ValueType vt, RegisterClass RC> : 188 PatLeaf<(vt RC:$src), [{ 189 return isMaskZeroExtended(N); 190 }]>; 191 192def maskzeroupperv1i1 : maskzeroupper<v1i1, VK1>; 193def maskzeroupperv2i1 : maskzeroupper<v2i1, VK2>; 194def maskzeroupperv4i1 : maskzeroupper<v4i1, VK4>; 195def maskzeroupperv8i1 : maskzeroupper<v8i1, VK8>; 196def maskzeroupperv16i1 : maskzeroupper<v16i1, VK16>; 197def maskzeroupperv32i1 : maskzeroupper<v32i1, VK32>; 198 199// The patterns determine if we can depend on the upper bits of a mask register 200// being zeroed by the previous operation so that we can skip explicit 201// zeroing. 202let Predicates = [HasBWI] in { 203 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV), 204 maskzeroupperv1i1:$src, (iPTR 0))), 205 (COPY_TO_REGCLASS VK1:$src, VK32)>; 206 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV), 207 maskzeroupperv8i1:$src, (iPTR 0))), 208 (COPY_TO_REGCLASS VK8:$src, VK32)>; 209 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV), 210 maskzeroupperv16i1:$src, (iPTR 0))), 211 (COPY_TO_REGCLASS VK16:$src, VK32)>; 212 213 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 214 maskzeroupperv1i1:$src, (iPTR 0))), 215 (COPY_TO_REGCLASS VK1:$src, VK64)>; 216 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 217 maskzeroupperv8i1:$src, (iPTR 0))), 218 (COPY_TO_REGCLASS VK8:$src, VK64)>; 219 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 220 maskzeroupperv16i1:$src, (iPTR 0))), 221 (COPY_TO_REGCLASS VK16:$src, VK64)>; 222 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 223 maskzeroupperv32i1:$src, (iPTR 0))), 224 (COPY_TO_REGCLASS VK32:$src, VK64)>; 225} 226 227let Predicates = [HasAVX512] in { 228 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV), 229 maskzeroupperv1i1:$src, (iPTR 0))), 230 (COPY_TO_REGCLASS VK1:$src, VK16)>; 231 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV), 232 maskzeroupperv8i1:$src, (iPTR 0))), 233 (COPY_TO_REGCLASS VK8:$src, VK16)>; 234} 235 236let Predicates = [HasDQI] in { 237 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV), 238 maskzeroupperv1i1:$src, (iPTR 0))), 239 (COPY_TO_REGCLASS VK1:$src, VK8)>; 240} 241 242let Predicates = [HasVLX, HasDQI] in { 243 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV), 244 maskzeroupperv2i1:$src, (iPTR 0))), 245 (COPY_TO_REGCLASS VK2:$src, VK8)>; 246 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV), 247 maskzeroupperv4i1:$src, (iPTR 0))), 248 (COPY_TO_REGCLASS VK4:$src, VK8)>; 249} 250 251let Predicates = [HasVLX] in { 252 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV), 253 maskzeroupperv2i1:$src, (iPTR 0))), 254 (COPY_TO_REGCLASS VK2:$src, VK16)>; 255 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV), 256 maskzeroupperv4i1:$src, (iPTR 0))), 257 (COPY_TO_REGCLASS VK4:$src, VK16)>; 258} 259 260let Predicates = [HasBWI, HasVLX] in { 261 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV), 262 maskzeroupperv2i1:$src, (iPTR 0))), 263 (COPY_TO_REGCLASS VK2:$src, VK32)>; 264 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV), 265 maskzeroupperv4i1:$src, (iPTR 0))), 266 (COPY_TO_REGCLASS VK4:$src, VK32)>; 267 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 268 maskzeroupperv2i1:$src, (iPTR 0))), 269 (COPY_TO_REGCLASS VK2:$src, VK64)>; 270 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 271 maskzeroupperv4i1:$src, (iPTR 0))), 272 (COPY_TO_REGCLASS VK4:$src, VK64)>; 273} 274 275// If the bits are not zero we have to fall back to explicitly zeroing by 276// using shifts. 277let Predicates = [HasAVX512] in { 278 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV), 279 (v1i1 VK1:$mask), (iPTR 0))), 280 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK1:$mask, VK16), 281 (i8 15)), (i8 15))>; 282 283 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV), 284 (v2i1 VK2:$mask), (iPTR 0))), 285 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK2:$mask, VK16), 286 (i8 14)), (i8 14))>; 287 288 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV), 289 (v4i1 VK4:$mask), (iPTR 0))), 290 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK4:$mask, VK16), 291 (i8 12)), (i8 12))>; 292} 293 294let Predicates = [HasAVX512, NoDQI] in { 295 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV), 296 (v8i1 VK8:$mask), (iPTR 0))), 297 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK8:$mask, VK16), 298 (i8 8)), (i8 8))>; 299} 300 301let Predicates = [HasDQI] in { 302 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV), 303 (v8i1 VK8:$mask), (iPTR 0))), 304 (COPY_TO_REGCLASS (KMOVBkk VK8:$mask), VK16)>; 305 306 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV), 307 (v1i1 VK1:$mask), (iPTR 0))), 308 (KSHIFTRBri (KSHIFTLBri (COPY_TO_REGCLASS VK1:$mask, VK8), 309 (i8 7)), (i8 7))>; 310 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV), 311 (v2i1 VK2:$mask), (iPTR 0))), 312 (KSHIFTRBri (KSHIFTLBri (COPY_TO_REGCLASS VK2:$mask, VK8), 313 (i8 6)), (i8 6))>; 314 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV), 315 (v4i1 VK4:$mask), (iPTR 0))), 316 (KSHIFTRBri (KSHIFTLBri (COPY_TO_REGCLASS VK4:$mask, VK8), 317 (i8 4)), (i8 4))>; 318} 319 320let Predicates = [HasBWI] in { 321 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV), 322 (v16i1 VK16:$mask), (iPTR 0))), 323 (COPY_TO_REGCLASS (KMOVWkk VK16:$mask), VK32)>; 324 325 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 326 (v16i1 VK16:$mask), (iPTR 0))), 327 (COPY_TO_REGCLASS (KMOVWkk VK16:$mask), VK64)>; 328 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 329 (v32i1 VK32:$mask), (iPTR 0))), 330 (COPY_TO_REGCLASS (KMOVDkk VK32:$mask), VK64)>; 331} 332 333let Predicates = [HasBWI, NoDQI] in { 334 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV), 335 (v8i1 VK8:$mask), (iPTR 0))), 336 (KSHIFTRDri (KSHIFTLDri (COPY_TO_REGCLASS VK8:$mask, VK32), 337 (i8 24)), (i8 24))>; 338 339 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 340 (v8i1 VK8:$mask), (iPTR 0))), 341 (KSHIFTRQri (KSHIFTLQri (COPY_TO_REGCLASS VK8:$mask, VK64), 342 (i8 56)), (i8 56))>; 343} 344 345let Predicates = [HasBWI, HasDQI] in { 346 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV), 347 (v8i1 VK8:$mask), (iPTR 0))), 348 (COPY_TO_REGCLASS (KMOVBkk VK8:$mask), VK32)>; 349 350 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 351 (v8i1 VK8:$mask), (iPTR 0))), 352 (COPY_TO_REGCLASS (KMOVBkk VK8:$mask), VK64)>; 353} 354 355let Predicates = [HasBWI] in { 356 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV), 357 (v1i1 VK1:$mask), (iPTR 0))), 358 (KSHIFTRDri (KSHIFTLDri (COPY_TO_REGCLASS VK1:$mask, VK32), 359 (i8 31)), (i8 31))>; 360 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV), 361 (v2i1 VK2:$mask), (iPTR 0))), 362 (KSHIFTRDri (KSHIFTLDri (COPY_TO_REGCLASS VK2:$mask, VK32), 363 (i8 30)), (i8 30))>; 364 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV), 365 (v4i1 VK4:$mask), (iPTR 0))), 366 (KSHIFTRDri (KSHIFTLDri (COPY_TO_REGCLASS VK4:$mask, VK32), 367 (i8 28)), (i8 28))>; 368 369 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 370 (v1i1 VK1:$mask), (iPTR 0))), 371 (KSHIFTRQri (KSHIFTLQri (COPY_TO_REGCLASS VK1:$mask, VK64), 372 (i8 63)), (i8 63))>; 373 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 374 (v2i1 VK2:$mask), (iPTR 0))), 375 (KSHIFTRQri (KSHIFTLQri (COPY_TO_REGCLASS VK2:$mask, VK64), 376 (i8 62)), (i8 62))>; 377 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV), 378 (v4i1 VK4:$mask), (iPTR 0))), 379 (KSHIFTRQri (KSHIFTLQri (COPY_TO_REGCLASS VK4:$mask, VK64), 380 (i8 60)), (i8 60))>; 381} 382 383//===----------------------------------------------------------------------===// 384// Extra selection patterns for f128, f128mem 385 386// movaps is shorter than movdqa. movaps is in SSE and movdqa is in SSE2. 387let Predicates = [NoAVX] in { 388def : Pat<(alignedstore (f128 VR128:$src), addr:$dst), 389 (MOVAPSmr addr:$dst, VR128:$src)>; 390def : Pat<(store (f128 VR128:$src), addr:$dst), 391 (MOVUPSmr addr:$dst, VR128:$src)>; 392 393def : Pat<(alignedloadf128 addr:$src), 394 (MOVAPSrm addr:$src)>; 395def : Pat<(loadf128 addr:$src), 396 (MOVUPSrm addr:$src)>; 397} 398 399let Predicates = [HasAVX, NoVLX] in { 400def : Pat<(alignedstore (f128 VR128:$src), addr:$dst), 401 (VMOVAPSmr addr:$dst, VR128:$src)>; 402def : Pat<(store (f128 VR128:$src), addr:$dst), 403 (VMOVUPSmr addr:$dst, VR128:$src)>; 404 405def : Pat<(alignedloadf128 addr:$src), 406 (VMOVAPSrm addr:$src)>; 407def : Pat<(loadf128 addr:$src), 408 (VMOVUPSrm addr:$src)>; 409} 410 411let Predicates = [HasVLX] in { 412def : Pat<(alignedstore (f128 VR128X:$src), addr:$dst), 413 (VMOVAPSZ128mr addr:$dst, VR128X:$src)>; 414def : Pat<(store (f128 VR128X:$src), addr:$dst), 415 (VMOVUPSZ128mr addr:$dst, VR128X:$src)>; 416 417def : Pat<(alignedloadf128 addr:$src), 418 (VMOVAPSZ128rm addr:$src)>; 419def : Pat<(loadf128 addr:$src), 420 (VMOVUPSZ128rm addr:$src)>; 421} 422 423let Predicates = [UseSSE1] in { 424// andps is shorter than andpd or pand. andps is SSE and andpd/pand are in SSE2 425def : Pat<(f128 (X86fand VR128:$src1, (memopf128 addr:$src2))), 426 (ANDPSrm VR128:$src1, f128mem:$src2)>; 427 428def : Pat<(f128 (X86fand VR128:$src1, VR128:$src2)), 429 (ANDPSrr VR128:$src1, VR128:$src2)>; 430 431def : Pat<(f128 (X86for VR128:$src1, (memopf128 addr:$src2))), 432 (ORPSrm VR128:$src1, f128mem:$src2)>; 433 434def : Pat<(f128 (X86for VR128:$src1, VR128:$src2)), 435 (ORPSrr VR128:$src1, VR128:$src2)>; 436 437def : Pat<(f128 (X86fxor VR128:$src1, (memopf128 addr:$src2))), 438 (XORPSrm VR128:$src1, f128mem:$src2)>; 439 440def : Pat<(f128 (X86fxor VR128:$src1, VR128:$src2)), 441 (XORPSrr VR128:$src1, VR128:$src2)>; 442} 443 444let Predicates = [HasAVX, NoVLX] in { 445// andps is shorter than andpd or pand. andps is SSE and andpd/pand are in SSE2 446def : Pat<(f128 (X86fand VR128:$src1, (loadf128 addr:$src2))), 447 (VANDPSrm VR128:$src1, f128mem:$src2)>; 448 449def : Pat<(f128 (X86fand VR128:$src1, VR128:$src2)), 450 (VANDPSrr VR128:$src1, VR128:$src2)>; 451 452def : Pat<(f128 (X86for VR128:$src1, (loadf128 addr:$src2))), 453 (VORPSrm VR128:$src1, f128mem:$src2)>; 454 455def : Pat<(f128 (X86for VR128:$src1, VR128:$src2)), 456 (VORPSrr VR128:$src1, VR128:$src2)>; 457 458def : Pat<(f128 (X86fxor VR128:$src1, (loadf128 addr:$src2))), 459 (VXORPSrm VR128:$src1, f128mem:$src2)>; 460 461def : Pat<(f128 (X86fxor VR128:$src1, VR128:$src2)), 462 (VXORPSrr VR128:$src1, VR128:$src2)>; 463} 464 465let Predicates = [HasVLX] in { 466// andps is shorter than andpd or pand. andps is SSE and andpd/pand are in SSE2 467def : Pat<(f128 (X86fand VR128X:$src1, (loadf128 addr:$src2))), 468 (VANDPSZ128rm VR128X:$src1, f128mem:$src2)>; 469 470def : Pat<(f128 (X86fand VR128X:$src1, VR128X:$src2)), 471 (VANDPSZ128rr VR128X:$src1, VR128X:$src2)>; 472 473def : Pat<(f128 (X86for VR128X:$src1, (loadf128 addr:$src2))), 474 (VORPSZ128rm VR128X:$src1, f128mem:$src2)>; 475 476def : Pat<(f128 (X86for VR128X:$src1, VR128X:$src2)), 477 (VORPSZ128rr VR128X:$src1, VR128X:$src2)>; 478 479def : Pat<(f128 (X86fxor VR128X:$src1, (loadf128 addr:$src2))), 480 (VXORPSZ128rm VR128X:$src1, f128mem:$src2)>; 481 482def : Pat<(f128 (X86fxor VR128X:$src1, VR128X:$src2)), 483 (VXORPSZ128rr VR128X:$src1, VR128X:$src2)>; 484} 485