X86InstrVecCompiler.td 22 KB

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