1e8d8bef9SDimitry Andric//===- HexagonPatternsHVX.td - Selection Patterns for HVX --*- tablegen -*-===// 2e8d8bef9SDimitry Andric// 3e8d8bef9SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4e8d8bef9SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 5e8d8bef9SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6e8d8bef9SDimitry Andric// 7e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 8e8d8bef9SDimitry Andric 904eeddc0SDimitry Andricdef HQ8: PatLeaf<(VecQ8 HvxQR:$R)>; 1004eeddc0SDimitry Andricdef HQ16: PatLeaf<(VecQ16 HvxQR:$R)>; 1104eeddc0SDimitry Andricdef HQ32: PatLeaf<(VecQ32 HvxQR:$R)>; 1204eeddc0SDimitry Andric 1304eeddc0SDimitry Andricdef HVI8: PatLeaf<(VecI8 HvxVR:$R)>; 1404eeddc0SDimitry Andricdef HVI16: PatLeaf<(VecI16 HvxVR:$R)>; 1504eeddc0SDimitry Andricdef HVI32: PatLeaf<(VecI32 HvxVR:$R)>; 1604eeddc0SDimitry Andricdef HVF16: PatLeaf<(VecF16 HvxVR:$R)>; 1704eeddc0SDimitry Andricdef HVF32: PatLeaf<(VecF32 HvxVR:$R)>; 1804eeddc0SDimitry Andric 1904eeddc0SDimitry Andricdef HWI8: PatLeaf<(VecPI8 HvxWR:$R)>; 2004eeddc0SDimitry Andricdef HWI16: PatLeaf<(VecPI16 HvxWR:$R)>; 2104eeddc0SDimitry Andricdef HWI32: PatLeaf<(VecPI32 HvxWR:$R)>; 2204eeddc0SDimitry Andricdef HWF16: PatLeaf<(VecPF16 HvxWR:$R)>; 2304eeddc0SDimitry Andricdef HWF32: PatLeaf<(VecPF32 HvxWR:$R)>; 24e8d8bef9SDimitry Andric 25e8d8bef9SDimitry Andricdef SDTVecUnaryOp: 26e8d8bef9SDimitry Andric SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVec<1>]>; 27e8d8bef9SDimitry Andric 280b57cec5SDimitry Andricdef SDTVecBinOp: 290b57cec5SDimitry Andric SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>, SDTCisSameAs<1,2>]>; 300b57cec5SDimitry Andric 310b57cec5SDimitry Andricdef SDTHexagonVEXTRACTW: SDTypeProfile<1, 2, 320b57cec5SDimitry Andric [SDTCisVT<0, i32>, SDTCisVec<1>, SDTCisVT<2, i32>]>; 330b57cec5SDimitry Andricdef HexagonVEXTRACTW : SDNode<"HexagonISD::VEXTRACTW", SDTHexagonVEXTRACTW>; 340b57cec5SDimitry Andric 350b57cec5SDimitry Andricdef SDTHexagonVINSERTW0: SDTypeProfile<1, 2, 360b57cec5SDimitry Andric [SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisVT<2, i32>]>; 370b57cec5SDimitry Andricdef HexagonVINSERTW0: SDNode<"HexagonISD::VINSERTW0", SDTHexagonVINSERTW0>; 380b57cec5SDimitry Andric 390b57cec5SDimitry Andricdef HwLen2: SDNodeXForm<imm, [{ 40*81ad6265SDimitry Andric const auto &ST = CurDAG->getSubtarget<HexagonSubtarget>(); 410b57cec5SDimitry Andric return CurDAG->getTargetConstant(ST.getVectorLength()/2, SDLoc(N), MVT::i32); 420b57cec5SDimitry Andric}]>; 430b57cec5SDimitry Andric 440b57cec5SDimitry Andricdef Q2V: OutPatFrag<(ops node:$Qs), (V6_vandqrt $Qs, (A2_tfrsi -1))>; 450b57cec5SDimitry Andric 460b57cec5SDimitry Andricdef Combinev: OutPatFrag<(ops node:$Vs, node:$Vt), 470b57cec5SDimitry Andric (REG_SEQUENCE HvxWR, $Vs, vsub_hi, $Vt, vsub_lo)>; 480b57cec5SDimitry Andric 490b57cec5SDimitry Andricdef Combineq: OutPatFrag<(ops node:$Qs, node:$Qt), 500b57cec5SDimitry Andric (V6_vandvrt 510b57cec5SDimitry Andric (V6_vor 520b57cec5SDimitry Andric (V6_vror (V6_vpackeb (V6_vd0), (Q2V $Qs)), 530b57cec5SDimitry Andric (A2_tfrsi (HwLen2 (i32 0)))), // Half the vector length 540b57cec5SDimitry Andric (V6_vpackeb (V6_vd0), (Q2V $Qt))), 550b57cec5SDimitry Andric (A2_tfrsi -1))>; 560b57cec5SDimitry Andric 570b57cec5SDimitry Andricdef LoVec: OutPatFrag<(ops node:$Vs), (EXTRACT_SUBREG $Vs, vsub_lo)>; 580b57cec5SDimitry Andricdef HiVec: OutPatFrag<(ops node:$Vs), (EXTRACT_SUBREG $Vs, vsub_hi)>; 590b57cec5SDimitry Andric 600b57cec5SDimitry Andricdef HexagonQCAT: SDNode<"HexagonISD::QCAT", SDTVecBinOp>; 610b57cec5SDimitry Andricdef HexagonQTRUE: SDNode<"HexagonISD::QTRUE", SDTVecLeaf>; 620b57cec5SDimitry Andricdef HexagonQFALSE: SDNode<"HexagonISD::QFALSE", SDTVecLeaf>; 63e8d8bef9SDimitry Andricdef HexagonVPACKL: SDNode<"HexagonISD::VPACKL", SDTVecUnaryOp>; 64e8d8bef9SDimitry Andricdef HexagonVUNPACK: SDNode<"HexagonISD::VUNPACK", SDTVecUnaryOp>; 65e8d8bef9SDimitry Andricdef HexagonVUNPACKU: SDNode<"HexagonISD::VUNPACKU", SDTVecUnaryOp>; 660b57cec5SDimitry Andric 6704eeddc0SDimitry Andricdef vzero: PatFrags<(ops), [(splat_vector (i32 0)), (splat_vector (f32zero))]>; 680b57cec5SDimitry Andricdef qtrue: PatFrag<(ops), (HexagonQTRUE)>; 690b57cec5SDimitry Andricdef qfalse: PatFrag<(ops), (HexagonQFALSE)>; 700b57cec5SDimitry Andricdef qcat: PatFrag<(ops node:$Qs, node:$Qt), 710b57cec5SDimitry Andric (HexagonQCAT node:$Qs, node:$Qt)>; 720b57cec5SDimitry Andric 730b57cec5SDimitry Andricdef qnot: PatFrag<(ops node:$Qs), (xor node:$Qs, qtrue)>; 74e8d8bef9SDimitry Andricdef vpackl: PatFrag<(ops node:$Vs), (HexagonVPACKL node:$Vs)>; 75e8d8bef9SDimitry Andricdef vunpack: PatFrag<(ops node:$Vs), (HexagonVUNPACK node:$Vs)>; 76e8d8bef9SDimitry Andricdef vunpacku: PatFrag<(ops node:$Vs), (HexagonVUNPACKU node:$Vs)>; 770b57cec5SDimitry Andric 780b57cec5SDimitry Andricdef VSxtb: OutPatFrag<(ops node:$Vs), (V6_vunpackb $Vs)>; 790b57cec5SDimitry Andricdef VSxth: OutPatFrag<(ops node:$Vs), (V6_vunpackh $Vs)>; 800b57cec5SDimitry Andricdef VZxtb: OutPatFrag<(ops node:$Vs), (V6_vunpackub $Vs)>; 810b57cec5SDimitry Andricdef VZxth: OutPatFrag<(ops node:$Vs), (V6_vunpackuh $Vs)>; 820b57cec5SDimitry Andric 830b57cec5SDimitry Andricdef IsVecOff : PatLeaf<(i32 imm), [{ 840b57cec5SDimitry Andric int32_t V = N->getSExtValue(); 850b57cec5SDimitry Andric int32_t VecSize = HRI->getSpillSize(Hexagon::HvxVRRegClass); 860b57cec5SDimitry Andric assert(isPowerOf2_32(VecSize)); 870b57cec5SDimitry Andric if ((uint32_t(V) & (uint32_t(VecSize)-1)) != 0) 880b57cec5SDimitry Andric return false; 890b57cec5SDimitry Andric int32_t L = Log2_32(VecSize); 900b57cec5SDimitry Andric return isInt<4>(V >> L); 910b57cec5SDimitry Andric}]>; 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric 940b57cec5SDimitry Andricdef alignedload: PatFrag<(ops node:$a), (load $a), [{ 95*81ad6265SDimitry Andric return isAlignedMemNode(cast<MemSDNode>(N)); 960b57cec5SDimitry Andric}]>; 970b57cec5SDimitry Andric 980b57cec5SDimitry Andricdef unalignedload: PatFrag<(ops node:$a), (load $a), [{ 99*81ad6265SDimitry Andric return !isAlignedMemNode(cast<MemSDNode>(N)); 1000b57cec5SDimitry Andric}]>; 1010b57cec5SDimitry Andric 1020b57cec5SDimitry Andricdef alignedstore: PatFrag<(ops node:$v, node:$a), (store $v, $a), [{ 103*81ad6265SDimitry Andric return isAlignedMemNode(cast<MemSDNode>(N)); 1040b57cec5SDimitry Andric}]>; 1050b57cec5SDimitry Andric 1060b57cec5SDimitry Andricdef unalignedstore: PatFrag<(ops node:$v, node:$a), (store $v, $a), [{ 107*81ad6265SDimitry Andric return !isAlignedMemNode(cast<MemSDNode>(N)); 1080b57cec5SDimitry Andric}]>; 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andric// HVX loads 1120b57cec5SDimitry Andric 113fe6060f1SDimitry Andricmulticlass HvxLdfi_pat<InstHexagon MI, PatFrag Load, ValueType ResType, 1140b57cec5SDimitry Andric PatFrag ImmPred> { 115fe6060f1SDimitry Andric def: Pat<(ResType (Load (add (i32 AddrFI:$fi), ImmPred:$Off))), 116fe6060f1SDimitry Andric (MI AddrFI:$fi, imm:$Off)>; 117fe6060f1SDimitry Andric def: Pat<(ResType (Load (IsOrAdd (i32 AddrFI:$fi), ImmPred:$Off))), 118fe6060f1SDimitry Andric (MI AddrFI:$fi, imm:$Off)>; 119fe6060f1SDimitry Andric def: Pat<(ResType (Load AddrFI:$fi)), (ResType (MI AddrFI:$fi, 0))>; 120fe6060f1SDimitry Andric} 121fe6060f1SDimitry Andric 122fe6060f1SDimitry Andricmulticlass HvxLdgi_pat<InstHexagon MI, PatFrag Load, ValueType ResType, 123fe6060f1SDimitry Andric PatFrag ImmPred> { 124fe6060f1SDimitry Andric def: Pat<(ResType (Load (add I32:$Rt, ImmPred:$Off))), 125fe6060f1SDimitry Andric (MI I32:$Rt, imm:$Off)>; 1260b57cec5SDimitry Andric def: Pat<(ResType (Load I32:$Rt)), 1270b57cec5SDimitry Andric (MI I32:$Rt, 0)>; 128fe6060f1SDimitry Andric} 129fe6060f1SDimitry Andric 130fe6060f1SDimitry Andricmulticlass HvxLdc_pat<InstHexagon MI, PatFrag Load, ValueType ResType> { 1310b57cec5SDimitry Andric // The HVX selection code for shuffles can generate vector constants. 1320b57cec5SDimitry Andric // Calling "Select" on the resulting loads from CP fails without these 1330b57cec5SDimitry Andric // patterns. 134fe6060f1SDimitry Andric def: Pat<(ResType (Load (HexagonCP tconstpool:$Addr))), 135fe6060f1SDimitry Andric (MI (A2_tfrsi imm:$Addr), 0)>; 136fe6060f1SDimitry Andric def: Pat<(ResType (Load (HexagonAtPcrel tconstpool:$Addr))), 137fe6060f1SDimitry Andric (MI (C4_addipc imm:$Addr), 0)>; 1380b57cec5SDimitry Andric} 1390b57cec5SDimitry Andric 140fe6060f1SDimitry Andricmulticlass HvxLd_pat<InstHexagon MI, PatFrag Load, ValueType ResType, 141fe6060f1SDimitry Andric PatFrag ImmPred> { 142fe6060f1SDimitry Andric defm: HvxLdfi_pat<MI, Load, ResType, ImmPred>; 143fe6060f1SDimitry Andric defm: HvxLdgi_pat<MI, Load, ResType, ImmPred>; 144fe6060f1SDimitry Andric defm: HvxLdc_pat <MI, Load, ResType>; 145fe6060f1SDimitry Andric} 146fe6060f1SDimitry Andric 147fe6060f1SDimitry Andric// Aligned loads: everything, plus loads with valignaddr node. 1480b57cec5SDimitry Andricmulticlass HvxLda_pat<InstHexagon MI, PatFrag Load, ValueType ResType, 1490b57cec5SDimitry Andric PatFrag ImmPred> { 1500b57cec5SDimitry Andric let AddedComplexity = 50 in { 1510b57cec5SDimitry Andric def: Pat<(ResType (Load (valignaddr I32:$Rt))), 1520b57cec5SDimitry Andric (MI I32:$Rt, 0)>; 1530b57cec5SDimitry Andric def: Pat<(ResType (Load (add (valignaddr I32:$Rt), ImmPred:$Off))), 1540b57cec5SDimitry Andric (MI I32:$Rt, imm:$Off)>; 1550b57cec5SDimitry Andric } 1560b57cec5SDimitry Andric defm: HvxLd_pat<MI, Load, ResType, ImmPred>; 1570b57cec5SDimitry Andric} 1580b57cec5SDimitry Andric 1590b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 160fe6060f1SDimitry Andric // alignedload will match a non-temporal load as well, so try non-temporal 161fe6060f1SDimitry Andric // first. 1620b57cec5SDimitry Andric defm: HvxLda_pat<V6_vL32b_nt_ai, alignednontemporalload, VecI8, IsVecOff>; 1630b57cec5SDimitry Andric defm: HvxLda_pat<V6_vL32b_nt_ai, alignednontemporalload, VecI16, IsVecOff>; 1640b57cec5SDimitry Andric defm: HvxLda_pat<V6_vL32b_nt_ai, alignednontemporalload, VecI32, IsVecOff>; 1650b57cec5SDimitry Andric defm: HvxLda_pat<V6_vL32b_ai, alignedload, VecI8, IsVecOff>; 1660b57cec5SDimitry Andric defm: HvxLda_pat<V6_vL32b_ai, alignedload, VecI16, IsVecOff>; 1670b57cec5SDimitry Andric defm: HvxLda_pat<V6_vL32b_ai, alignedload, VecI32, IsVecOff>; 1680b57cec5SDimitry Andric defm: HvxLd_pat<V6_vL32Ub_ai, unalignedload, VecI8, IsVecOff>; 1690b57cec5SDimitry Andric defm: HvxLd_pat<V6_vL32Ub_ai, unalignedload, VecI16, IsVecOff>; 1700b57cec5SDimitry Andric defm: HvxLd_pat<V6_vL32Ub_ai, unalignedload, VecI32, IsVecOff>; 1710b57cec5SDimitry Andric} 1720b57cec5SDimitry Andric 17304eeddc0SDimitry Andriclet Predicates = [UseHVXV68] in { 17404eeddc0SDimitry Andric defm: HvxLda_pat<V6_vL32b_nt_ai, alignednontemporalload, VecF16, IsVecOff>; 17504eeddc0SDimitry Andric defm: HvxLda_pat<V6_vL32b_nt_ai, alignednontemporalload, VecF32, IsVecOff>; 17604eeddc0SDimitry Andric defm: HvxLda_pat<V6_vL32b_ai, alignedload, VecF16, IsVecOff>; 17704eeddc0SDimitry Andric defm: HvxLda_pat<V6_vL32b_ai, alignedload, VecF32, IsVecOff>; 17804eeddc0SDimitry Andric defm: HvxLd_pat<V6_vL32Ub_ai, unalignedload, VecF16, IsVecOff>; 17904eeddc0SDimitry Andric defm: HvxLd_pat<V6_vL32Ub_ai, unalignedload, VecF32, IsVecOff>; 18004eeddc0SDimitry Andric} 181fe6060f1SDimitry Andric 1820b57cec5SDimitry Andric// HVX stores 1830b57cec5SDimitry Andric 184fe6060f1SDimitry Andricmulticlass HvxStfi_pat<InstHexagon MI, PatFrag Store, PatFrag Value, 185fe6060f1SDimitry Andric PatFrag ImmPred> { 186fe6060f1SDimitry Andric def: Pat<(Store Value:$Vs, (add (i32 AddrFI:$fi), ImmPred:$Off)), 187fe6060f1SDimitry Andric (MI AddrFI:$fi, imm:$Off, Value:$Vs)>; 188fe6060f1SDimitry Andric def: Pat<(Store Value:$Vs, (IsOrAdd (i32 AddrFI:$fi), ImmPred:$Off)), 189fe6060f1SDimitry Andric (MI AddrFI:$fi, imm:$Off, Value:$Vs)>; 190fe6060f1SDimitry Andric def: Pat<(Store Value:$Vs, AddrFI:$fi), 191fe6060f1SDimitry Andric (MI AddrFI:$fi, 0, Value:$Vs)>; 192fe6060f1SDimitry Andric} 193fe6060f1SDimitry Andric 194fe6060f1SDimitry Andricmulticlass HvxStgi_pat<InstHexagon MI, PatFrag Store, PatFrag Value, 195fe6060f1SDimitry Andric PatFrag ImmPred> { 196fe6060f1SDimitry Andric def: Pat<(Store Value:$Vs, (add I32:$Rt, ImmPred:$Off)), 197fe6060f1SDimitry Andric (MI I32:$Rt, imm:$Off, Value:$Vs)>; 198fe6060f1SDimitry Andric def: Pat<(Store Value:$Vs, (IsOrAdd I32:$Rt, ImmPred:$Off)), 199fe6060f1SDimitry Andric (MI I32:$Rt, imm:$Off, Value:$Vs)>; 2000b57cec5SDimitry Andric def: Pat<(Store Value:$Vs, I32:$Rt), 2010b57cec5SDimitry Andric (MI I32:$Rt, 0, Value:$Vs)>; 202fe6060f1SDimitry Andric} 203fe6060f1SDimitry Andric 204fe6060f1SDimitry Andricmulticlass HvxSt_pat<InstHexagon MI, PatFrag Store, PatFrag Value, 205fe6060f1SDimitry Andric PatFrag ImmPred> { 206fe6060f1SDimitry Andric defm: HvxStfi_pat<MI, Store, Value, ImmPred>; 207fe6060f1SDimitry Andric defm: HvxStgi_pat<MI, Store, Value, ImmPred>; 2080b57cec5SDimitry Andric} 2090b57cec5SDimitry Andric 2100b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 211fe6060f1SDimitry Andric // alignedstore will match a non-temporal store as well, so try non-temporal 212fe6060f1SDimitry Andric // first. 213fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32b_nt_ai, alignednontemporalstore, HVI8, IsVecOff>; 214fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32b_nt_ai, alignednontemporalstore, HVI16, IsVecOff>; 215fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32b_nt_ai, alignednontemporalstore, HVI32, IsVecOff>; 216fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32b_ai, alignedstore, HVI8, IsVecOff>; 217fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32b_ai, alignedstore, HVI16, IsVecOff>; 218fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32b_ai, alignedstore, HVI32, IsVecOff>; 219fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32Ub_ai, unalignedstore, HVI8, IsVecOff>; 220fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32Ub_ai, unalignedstore, HVI16, IsVecOff>; 221fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32Ub_ai, unalignedstore, HVI32, IsVecOff>; 2220b57cec5SDimitry Andric} 2230b57cec5SDimitry Andric 22404eeddc0SDimitry Andriclet Predicates = [UseHVXV68] in { 22504eeddc0SDimitry Andric defm: HvxSt_pat<V6_vS32b_nt_ai, alignednontemporalstore, HVF16, IsVecOff>; 22604eeddc0SDimitry Andric defm: HvxSt_pat<V6_vS32b_nt_ai, alignednontemporalstore, HVF32, IsVecOff>; 22704eeddc0SDimitry Andric defm: HvxSt_pat<V6_vS32b_ai, alignedstore, HVF16, IsVecOff>; 22804eeddc0SDimitry Andric defm: HvxSt_pat<V6_vS32b_ai, alignedstore, HVF32, IsVecOff>; 22904eeddc0SDimitry Andric defm: HvxSt_pat<V6_vS32Ub_ai, unalignedstore, HVF16, IsVecOff>; 23004eeddc0SDimitry Andric defm: HvxSt_pat<V6_vS32Ub_ai, unalignedstore, HVF32, IsVecOff>; 23104eeddc0SDimitry Andric} 23204eeddc0SDimitry Andric 2330b57cec5SDimitry Andric// Bitcasts between same-size vector types are no-ops, except for the 2340b57cec5SDimitry Andric// actual type change. 2350b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 2368bcb0991SDimitry Andric defm: NopCast_pat<VecI8, VecI16, HvxVR>; 2378bcb0991SDimitry Andric defm: NopCast_pat<VecI8, VecI32, HvxVR>; 2388bcb0991SDimitry Andric defm: NopCast_pat<VecI16, VecI32, HvxVR>; 2390b57cec5SDimitry Andric 2408bcb0991SDimitry Andric defm: NopCast_pat<VecPI8, VecPI16, HvxWR>; 2418bcb0991SDimitry Andric defm: NopCast_pat<VecPI8, VecPI32, HvxWR>; 2428bcb0991SDimitry Andric defm: NopCast_pat<VecPI16, VecPI32, HvxWR>; 2430b57cec5SDimitry Andric} 2440b57cec5SDimitry Andric 24504eeddc0SDimitry Andriclet Predicates = [UseHVX, UseHVXFloatingPoint] in { 24604eeddc0SDimitry Andric defm: NopCast_pat<VecI8, VecF16, HvxVR>; 24704eeddc0SDimitry Andric defm: NopCast_pat<VecI8, VecF32, HvxVR>; 24804eeddc0SDimitry Andric defm: NopCast_pat<VecI16, VecF16, HvxVR>; 24904eeddc0SDimitry Andric defm: NopCast_pat<VecI16, VecF32, HvxVR>; 25004eeddc0SDimitry Andric defm: NopCast_pat<VecI32, VecF16, HvxVR>; 25104eeddc0SDimitry Andric defm: NopCast_pat<VecI32, VecF32, HvxVR>; 25204eeddc0SDimitry Andric defm: NopCast_pat<VecF16, VecF32, HvxVR>; 25304eeddc0SDimitry Andric 25404eeddc0SDimitry Andric defm: NopCast_pat<VecPI8, VecPF16, HvxWR>; 25504eeddc0SDimitry Andric defm: NopCast_pat<VecPI8, VecPF32, HvxWR>; 25604eeddc0SDimitry Andric defm: NopCast_pat<VecPI16, VecPF16, HvxWR>; 25704eeddc0SDimitry Andric defm: NopCast_pat<VecPI16, VecPF32, HvxWR>; 25804eeddc0SDimitry Andric defm: NopCast_pat<VecPI32, VecPF16, HvxWR>; 25904eeddc0SDimitry Andric defm: NopCast_pat<VecPI32, VecPF32, HvxWR>; 26004eeddc0SDimitry Andric defm: NopCast_pat<VecPF16, VecPF32, HvxWR>; 26104eeddc0SDimitry Andric} 26204eeddc0SDimitry Andric 2630b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 264e8d8bef9SDimitry Andric let AddedComplexity = 100 in { 265e8d8bef9SDimitry Andric // These should be preferred over a vsplat of 0. 2660b57cec5SDimitry Andric def: Pat<(VecI8 vzero), (V6_vd0)>; 2670b57cec5SDimitry Andric def: Pat<(VecI16 vzero), (V6_vd0)>; 2680b57cec5SDimitry Andric def: Pat<(VecI32 vzero), (V6_vd0)>; 2690b57cec5SDimitry Andric def: Pat<(VecPI8 vzero), (PS_vdd0)>; 2700b57cec5SDimitry Andric def: Pat<(VecPI16 vzero), (PS_vdd0)>; 2710b57cec5SDimitry Andric def: Pat<(VecPI32 vzero), (PS_vdd0)>; 27204eeddc0SDimitry Andric def: Pat<(VecPF32 vzero), (PS_vdd0)>; 2730b57cec5SDimitry Andric 2740b57cec5SDimitry Andric def: Pat<(concat_vectors (VecI8 vzero), (VecI8 vzero)), (PS_vdd0)>; 2750b57cec5SDimitry Andric def: Pat<(concat_vectors (VecI16 vzero), (VecI16 vzero)), (PS_vdd0)>; 2760b57cec5SDimitry Andric def: Pat<(concat_vectors (VecI32 vzero), (VecI32 vzero)), (PS_vdd0)>; 277e8d8bef9SDimitry Andric } 2780b57cec5SDimitry Andric 2790b57cec5SDimitry Andric def: Pat<(VecPI8 (concat_vectors HVI8:$Vs, HVI8:$Vt)), 2800b57cec5SDimitry Andric (Combinev HvxVR:$Vt, HvxVR:$Vs)>; 2810b57cec5SDimitry Andric def: Pat<(VecPI16 (concat_vectors HVI16:$Vs, HVI16:$Vt)), 2820b57cec5SDimitry Andric (Combinev HvxVR:$Vt, HvxVR:$Vs)>; 2830b57cec5SDimitry Andric def: Pat<(VecPI32 (concat_vectors HVI32:$Vs, HVI32:$Vt)), 2840b57cec5SDimitry Andric (Combinev HvxVR:$Vt, HvxVR:$Vs)>; 2850b57cec5SDimitry Andric 2860b57cec5SDimitry Andric def: Pat<(VecQ8 (qcat HQ16:$Qs, HQ16:$Qt)), (Combineq $Qt, $Qs)>; 2870b57cec5SDimitry Andric def: Pat<(VecQ16 (qcat HQ32:$Qs, HQ32:$Qt)), (Combineq $Qt, $Qs)>; 2880b57cec5SDimitry Andric 2890b57cec5SDimitry Andric def: Pat<(HexagonVEXTRACTW HVI8:$Vu, I32:$Rs), 2900b57cec5SDimitry Andric (V6_extractw HvxVR:$Vu, I32:$Rs)>; 2910b57cec5SDimitry Andric def: Pat<(HexagonVEXTRACTW HVI16:$Vu, I32:$Rs), 2920b57cec5SDimitry Andric (V6_extractw HvxVR:$Vu, I32:$Rs)>; 2930b57cec5SDimitry Andric def: Pat<(HexagonVEXTRACTW HVI32:$Vu, I32:$Rs), 2940b57cec5SDimitry Andric (V6_extractw HvxVR:$Vu, I32:$Rs)>; 2950b57cec5SDimitry Andric 2960b57cec5SDimitry Andric def: Pat<(HexagonVINSERTW0 HVI8:$Vu, I32:$Rt), 2970b57cec5SDimitry Andric (V6_vinsertwr HvxVR:$Vu, I32:$Rt)>; 2980b57cec5SDimitry Andric def: Pat<(HexagonVINSERTW0 HVI16:$Vu, I32:$Rt), 2990b57cec5SDimitry Andric (V6_vinsertwr HvxVR:$Vu, I32:$Rt)>; 3000b57cec5SDimitry Andric def: Pat<(HexagonVINSERTW0 HVI32:$Vu, I32:$Rt), 3010b57cec5SDimitry Andric (V6_vinsertwr HvxVR:$Vu, I32:$Rt)>; 3020b57cec5SDimitry Andric} 3030b57cec5SDimitry Andric 30404eeddc0SDimitry Andriclet Predicates = [UseHVX, UseHVXFloatingPoint] in { 30504eeddc0SDimitry Andric let AddedComplexity = 100 in { 30604eeddc0SDimitry Andric def: Pat<(VecF16 vzero), (V6_vd0)>; 30704eeddc0SDimitry Andric def: Pat<(VecF32 vzero), (V6_vd0)>; 30804eeddc0SDimitry Andric def: Pat<(VecPF16 vzero), (PS_vdd0)>; 30904eeddc0SDimitry Andric def: Pat<(VecPF32 vzero), (PS_vdd0)>; 31004eeddc0SDimitry Andric 31104eeddc0SDimitry Andric def: Pat<(concat_vectors (VecF16 vzero), (VecF16 vzero)), (PS_vdd0)>; 31204eeddc0SDimitry Andric def: Pat<(concat_vectors (VecF32 vzero), (VecF32 vzero)), (PS_vdd0)>; 31304eeddc0SDimitry Andric } 31404eeddc0SDimitry Andric 31504eeddc0SDimitry Andric def: Pat<(VecPF16 (concat_vectors HVF16:$Vs, HVF16:$Vt)), 31604eeddc0SDimitry Andric (Combinev HvxVR:$Vt, HvxVR:$Vs)>; 31704eeddc0SDimitry Andric def: Pat<(VecPF32 (concat_vectors HVF32:$Vs, HVF32:$Vt)), 31804eeddc0SDimitry Andric (Combinev HvxVR:$Vt, HvxVR:$Vs)>; 31904eeddc0SDimitry Andric 32004eeddc0SDimitry Andric def: Pat<(HexagonVINSERTW0 HVF16:$Vu, I32:$Rt), 32104eeddc0SDimitry Andric (V6_vinsertwr HvxVR:$Vu, I32:$Rt)>; 32204eeddc0SDimitry Andric def: Pat<(HexagonVINSERTW0 HVF32:$Vu, I32:$Rt), 32304eeddc0SDimitry Andric (V6_vinsertwr HvxVR:$Vu, I32:$Rt)>; 32404eeddc0SDimitry Andric} 32504eeddc0SDimitry Andric 326e8d8bef9SDimitry Andric// Splats for HvxV60 327e8d8bef9SDimitry Andricdef V60splatib: OutPatFrag<(ops node:$V), (V6_lvsplatw (ToI32 (SplatB $V)))>; 328e8d8bef9SDimitry Andricdef V60splatih: OutPatFrag<(ops node:$V), (V6_lvsplatw (ToI32 (SplatH $V)))>; 329e8d8bef9SDimitry Andricdef V60splatiw: OutPatFrag<(ops node:$V), (V6_lvsplatw (ToI32 $V))>; 330e8d8bef9SDimitry Andricdef V60splatrb: OutPatFrag<(ops node:$Rs), (V6_lvsplatw (S2_vsplatrb $Rs))>; 331e8d8bef9SDimitry Andricdef V60splatrh: OutPatFrag<(ops node:$Rs), 3320b57cec5SDimitry Andric (V6_lvsplatw (A2_combine_ll $Rs, $Rs))>; 333e8d8bef9SDimitry Andricdef V60splatrw: OutPatFrag<(ops node:$Rs), (V6_lvsplatw $Rs)>; 334e8d8bef9SDimitry Andric 335e8d8bef9SDimitry Andric// Splats for HvxV62+ 336e8d8bef9SDimitry Andricdef V62splatib: OutPatFrag<(ops node:$V), (V6_lvsplatb (ToI32 $V))>; 337e8d8bef9SDimitry Andricdef V62splatih: OutPatFrag<(ops node:$V), (V6_lvsplath (ToI32 $V))>; 338e8d8bef9SDimitry Andricdef V62splatiw: OutPatFrag<(ops node:$V), (V6_lvsplatw (ToI32 $V))>; 339e8d8bef9SDimitry Andricdef V62splatrb: OutPatFrag<(ops node:$Rs), (V6_lvsplatb $Rs)>; 340e8d8bef9SDimitry Andricdef V62splatrh: OutPatFrag<(ops node:$Rs), (V6_lvsplath $Rs)>; 341e8d8bef9SDimitry Andricdef V62splatrw: OutPatFrag<(ops node:$Rs), (V6_lvsplatw $Rs)>; 3420b57cec5SDimitry Andric 3430b57cec5SDimitry Andricdef Rep: OutPatFrag<(ops node:$N), (Combinev $N, $N)>; 3440b57cec5SDimitry Andric 345e8d8bef9SDimitry Andriclet Predicates = [UseHVX,UseHVXV60] in { 3460b57cec5SDimitry Andric let AddedComplexity = 10 in { 347e8d8bef9SDimitry Andric def: Pat<(VecI8 (splat_vector u8_0ImmPred:$V)), (V60splatib $V)>; 348e8d8bef9SDimitry Andric def: Pat<(VecI16 (splat_vector u16_0ImmPred:$V)), (V60splatih $V)>; 349e8d8bef9SDimitry Andric def: Pat<(VecI32 (splat_vector anyimm:$V)), (V60splatiw $V)>; 350e8d8bef9SDimitry Andric def: Pat<(VecPI8 (splat_vector u8_0ImmPred:$V)), (Rep (V60splatib $V))>; 351e8d8bef9SDimitry Andric def: Pat<(VecPI16 (splat_vector u16_0ImmPred:$V)), (Rep (V60splatih $V))>; 352e8d8bef9SDimitry Andric def: Pat<(VecPI32 (splat_vector anyimm:$V)), (Rep (V60splatiw $V))>; 3530b57cec5SDimitry Andric } 354e8d8bef9SDimitry Andric def: Pat<(VecI8 (splat_vector I32:$Rs)), (V60splatrb $Rs)>; 355e8d8bef9SDimitry Andric def: Pat<(VecI16 (splat_vector I32:$Rs)), (V60splatrh $Rs)>; 356e8d8bef9SDimitry Andric def: Pat<(VecI32 (splat_vector I32:$Rs)), (V60splatrw $Rs)>; 357e8d8bef9SDimitry Andric def: Pat<(VecPI8 (splat_vector I32:$Rs)), (Rep (V60splatrb $Rs))>; 358e8d8bef9SDimitry Andric def: Pat<(VecPI16 (splat_vector I32:$Rs)), (Rep (V60splatrh $Rs))>; 359e8d8bef9SDimitry Andric def: Pat<(VecPI32 (splat_vector I32:$Rs)), (Rep (V60splatrw $Rs))>; 360e8d8bef9SDimitry Andric} 361e8d8bef9SDimitry Andriclet Predicates = [UseHVX,UseHVXV62] in { 362e8d8bef9SDimitry Andric let AddedComplexity = 30 in { 363e8d8bef9SDimitry Andric def: Pat<(VecI8 (splat_vector u8_0ImmPred:$V)), (V62splatib imm:$V)>; 364e8d8bef9SDimitry Andric def: Pat<(VecI16 (splat_vector u16_0ImmPred:$V)), (V62splatih imm:$V)>; 365e8d8bef9SDimitry Andric def: Pat<(VecI32 (splat_vector anyimm:$V)), (V62splatiw imm:$V)>; 366e8d8bef9SDimitry Andric def: Pat<(VecPI8 (splat_vector u8_0ImmPred:$V)), 367e8d8bef9SDimitry Andric (Rep (V62splatib imm:$V))>; 368e8d8bef9SDimitry Andric def: Pat<(VecPI16 (splat_vector u16_0ImmPred:$V)), 369e8d8bef9SDimitry Andric (Rep (V62splatih imm:$V))>; 370e8d8bef9SDimitry Andric def: Pat<(VecPI32 (splat_vector anyimm:$V)), 371e8d8bef9SDimitry Andric (Rep (V62splatiw imm:$V))>; 372e8d8bef9SDimitry Andric } 373e8d8bef9SDimitry Andric let AddedComplexity = 20 in { 374e8d8bef9SDimitry Andric def: Pat<(VecI8 (splat_vector I32:$Rs)), (V62splatrb $Rs)>; 375e8d8bef9SDimitry Andric def: Pat<(VecI16 (splat_vector I32:$Rs)), (V62splatrh $Rs)>; 376e8d8bef9SDimitry Andric def: Pat<(VecI32 (splat_vector I32:$Rs)), (V62splatrw $Rs)>; 377e8d8bef9SDimitry Andric def: Pat<(VecPI8 (splat_vector I32:$Rs)), (Rep (V62splatrb $Rs))>; 378e8d8bef9SDimitry Andric def: Pat<(VecPI16 (splat_vector I32:$Rs)), (Rep (V62splatrh $Rs))>; 379e8d8bef9SDimitry Andric def: Pat<(VecPI32 (splat_vector I32:$Rs)), (Rep (V62splatrw $Rs))>; 380e8d8bef9SDimitry Andric } 3810b57cec5SDimitry Andric} 38204eeddc0SDimitry Andriclet Predicates = [UseHVXV68, UseHVXFloatingPoint] in { 38304eeddc0SDimitry Andric let AddedComplexity = 30 in { 38404eeddc0SDimitry Andric def: Pat<(VecF16 (splat_vector u16_0ImmPred:$V)), (V62splatih imm:$V)>; 38504eeddc0SDimitry Andric def: Pat<(VecF32 (splat_vector anyint:$V)), (V62splatiw imm:$V)>; 38604eeddc0SDimitry Andric def: Pat<(VecF32 (splat_vector f32ImmPred:$V)), (V62splatiw (ftoi $V))>; 38704eeddc0SDimitry Andric } 38804eeddc0SDimitry Andric let AddedComplexity = 20 in { 38904eeddc0SDimitry Andric def: Pat<(VecF16 (splat_vector I32:$Rs)), (V62splatrh $Rs)>; 39004eeddc0SDimitry Andric def: Pat<(VecF32 (splat_vector I32:$Rs)), (V62splatrw $Rs)>; 39104eeddc0SDimitry Andric def: Pat<(VecF32 (splat_vector F32:$Rs)), (V62splatrw $Rs)>; 39204eeddc0SDimitry Andric } 39304eeddc0SDimitry Andric} 3940b57cec5SDimitry Andric 3950b57cec5SDimitry Andricclass Vneg1<ValueType VecTy> 396e8d8bef9SDimitry Andric : PatFrag<(ops), (VecTy (splat_vector (i32 -1)))>; 3970b57cec5SDimitry Andric 3980b57cec5SDimitry Andricclass Vnot<ValueType VecTy> 3990b57cec5SDimitry Andric : PatFrag<(ops node:$Vs), (xor $Vs, Vneg1<VecTy>)>; 4000b57cec5SDimitry Andric 4010b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 4020b57cec5SDimitry Andric let AddedComplexity = 200 in { 4030b57cec5SDimitry Andric def: Pat<(Vnot<VecI8> HVI8:$Vs), (V6_vnot HvxVR:$Vs)>; 4040b57cec5SDimitry Andric def: Pat<(Vnot<VecI16> HVI16:$Vs), (V6_vnot HvxVR:$Vs)>; 4050b57cec5SDimitry Andric def: Pat<(Vnot<VecI32> HVI32:$Vs), (V6_vnot HvxVR:$Vs)>; 4060b57cec5SDimitry Andric } 4070b57cec5SDimitry Andric 4080b57cec5SDimitry Andric def: OpR_RR_pat<V6_vaddb, Add, VecI8, HVI8>; 4090b57cec5SDimitry Andric def: OpR_RR_pat<V6_vaddh, Add, VecI16, HVI16>; 4100b57cec5SDimitry Andric def: OpR_RR_pat<V6_vaddw, Add, VecI32, HVI32>; 4110b57cec5SDimitry Andric def: OpR_RR_pat<V6_vaddb_dv, Add, VecPI8, HWI8>; 4120b57cec5SDimitry Andric def: OpR_RR_pat<V6_vaddh_dv, Add, VecPI16, HWI16>; 4130b57cec5SDimitry Andric def: OpR_RR_pat<V6_vaddw_dv, Add, VecPI32, HWI32>; 4140b57cec5SDimitry Andric def: OpR_RR_pat<V6_vsubb, Sub, VecI8, HVI8>; 4150b57cec5SDimitry Andric def: OpR_RR_pat<V6_vsubh, Sub, VecI16, HVI16>; 4160b57cec5SDimitry Andric def: OpR_RR_pat<V6_vsubw, Sub, VecI32, HVI32>; 4170b57cec5SDimitry Andric def: OpR_RR_pat<V6_vsubb_dv, Sub, VecPI8, HWI8>; 4180b57cec5SDimitry Andric def: OpR_RR_pat<V6_vsubh_dv, Sub, VecPI16, HWI16>; 4190b57cec5SDimitry Andric def: OpR_RR_pat<V6_vsubw_dv, Sub, VecPI32, HWI32>; 4200b57cec5SDimitry Andric def: OpR_RR_pat<V6_vand, And, VecI8, HVI8>; 4210b57cec5SDimitry Andric def: OpR_RR_pat<V6_vand, And, VecI16, HVI16>; 4220b57cec5SDimitry Andric def: OpR_RR_pat<V6_vand, And, VecI32, HVI32>; 4230b57cec5SDimitry Andric def: OpR_RR_pat<V6_vor, Or, VecI8, HVI8>; 4240b57cec5SDimitry Andric def: OpR_RR_pat<V6_vor, Or, VecI16, HVI16>; 4250b57cec5SDimitry Andric def: OpR_RR_pat<V6_vor, Or, VecI32, HVI32>; 4260b57cec5SDimitry Andric def: OpR_RR_pat<V6_vxor, Xor, VecI8, HVI8>; 4270b57cec5SDimitry Andric def: OpR_RR_pat<V6_vxor, Xor, VecI16, HVI16>; 4280b57cec5SDimitry Andric def: OpR_RR_pat<V6_vxor, Xor, VecI32, HVI32>; 4290b57cec5SDimitry Andric 430e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vminb, Smin, VecI8, HVI8>; 431e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vmaxb, Smax, VecI8, HVI8>; 432e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vminub, Umin, VecI8, HVI8>; 433e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vmaxub, Umax, VecI8, HVI8>; 434e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vminh, Smin, VecI16, HVI16>; 435e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vmaxh, Smax, VecI16, HVI16>; 436e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vminuh, Umin, VecI16, HVI16>; 437e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vmaxuh, Umax, VecI16, HVI16>; 438e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vminw, Smin, VecI32, HVI32>; 439e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vmaxw, Smax, VecI32, HVI32>; 440e8d8bef9SDimitry Andric 4410b57cec5SDimitry Andric def: Pat<(vselect HQ8:$Qu, HVI8:$Vs, HVI8:$Vt), 4420b57cec5SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vs, HvxVR:$Vt)>; 4430b57cec5SDimitry Andric def: Pat<(vselect HQ16:$Qu, HVI16:$Vs, HVI16:$Vt), 4440b57cec5SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vs, HvxVR:$Vt)>; 4450b57cec5SDimitry Andric def: Pat<(vselect HQ32:$Qu, HVI32:$Vs, HVI32:$Vt), 4460b57cec5SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vs, HvxVR:$Vt)>; 4470b57cec5SDimitry Andric 4480b57cec5SDimitry Andric def: Pat<(vselect (qnot HQ8:$Qu), HVI8:$Vs, HVI8:$Vt), 4490b57cec5SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vt, HvxVR:$Vs)>; 4500b57cec5SDimitry Andric def: Pat<(vselect (qnot HQ16:$Qu), HVI16:$Vs, HVI16:$Vt), 4510b57cec5SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vt, HvxVR:$Vs)>; 4520b57cec5SDimitry Andric def: Pat<(vselect (qnot HQ32:$Qu), HVI32:$Vs, HVI32:$Vt), 4530b57cec5SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vt, HvxVR:$Vs)>; 4540b57cec5SDimitry Andric} 4550b57cec5SDimitry Andric 45604eeddc0SDimitry Andric// For now, we always deal with vector floating point in SF mode. 45704eeddc0SDimitry Andricclass OpR_RR_pat_conv<InstHexagon MI, PatFrag Op, ValueType ResType, 45804eeddc0SDimitry Andric PatFrag RsPred, PatFrag RtPred = RsPred> 45904eeddc0SDimitry Andric : Pat<(ResType (Op RsPred:$Rs, RtPred:$Rt)), 46004eeddc0SDimitry Andric (V6_vconv_sf_qf32 (VecF32 (MI RsPred:$Rs, RtPred:$Rt)))>; 46104eeddc0SDimitry Andric 46204eeddc0SDimitry Andricclass OpR_RR_pat_conv_hf<InstHexagon MI, PatFrag Op, ValueType ResType, 46304eeddc0SDimitry Andric PatFrag RsPred, PatFrag RtPred = RsPred> 46404eeddc0SDimitry Andric : Pat<(ResType (Op RsPred:$Rs, RtPred:$Rt)), 46504eeddc0SDimitry Andric (V6_vconv_hf_qf16 (VecF16 (MI RsPred:$Rs, RtPred:$Rt)))>; 46604eeddc0SDimitry Andric 46704eeddc0SDimitry Andriclet Predicates = [UseHVXV68, UseHVXQFloat] in { 46804eeddc0SDimitry Andric def: OpR_RR_pat_conv_hf<V6_vsub_hf, pf2<fsub>, VecF16, HVF16>; 46904eeddc0SDimitry Andric def: OpR_RR_pat_conv_hf<V6_vadd_hf, pf2<fadd>, VecF16, HVF16>; 47004eeddc0SDimitry Andric def: OpR_RR_pat_conv_hf<V6_vmpy_qf16_hf, pf2<fmul>, VecF16, HVF16>; 47104eeddc0SDimitry Andric def: OpR_RR_pat_conv<V6_vsub_sf, pf2<fsub>, VecF32, HVF32>; 47204eeddc0SDimitry Andric def: OpR_RR_pat_conv<V6_vadd_sf, pf2<fadd>, VecF32, HVF32>; 47304eeddc0SDimitry Andric def: OpR_RR_pat_conv<V6_vmpy_qf32_sf, pf2<fmul>, VecF32, HVF32>; 47404eeddc0SDimitry Andric 47504eeddc0SDimitry Andric // For now we assume that the fp32 register is always coming in as IEEE float 47604eeddc0SDimitry Andric // since the qfloat arithmetic instructions above always generate the 47704eeddc0SDimitry Andric // accompanying conversions as part of their pattern 47804eeddc0SDimitry Andric def: Pat<(VecF16 (pf1<fpround> HWF32:$Vuu)), 47904eeddc0SDimitry Andric (V6_vdealh (V6_vconv_hf_qf32 48004eeddc0SDimitry Andric (VecPF32 (Combinev (V6_vadd_sf (HiVec HvxWR:$Vuu), (V6_vd0)), 48104eeddc0SDimitry Andric (V6_vadd_sf (LoVec HvxWR:$Vuu), (V6_vd0)) 48204eeddc0SDimitry Andric ))))>; 48304eeddc0SDimitry Andric // fpextend for QFloat is handled manually in HexagonISelLoweringHVX.cpp. 48404eeddc0SDimitry Andric} 48504eeddc0SDimitry Andric 48604eeddc0SDimitry Andric// HVX IEEE arithmetic Instructions 48704eeddc0SDimitry Andriclet Predicates = [UseHVXV68, UseHVXIEEEFP] in { 48804eeddc0SDimitry Andric def: Pat<(fadd HVF16:$Rs, HVF16:$Rt), 48904eeddc0SDimitry Andric (V6_vadd_hf_hf HVF16:$Rs, HVF16:$Rt)>; 49004eeddc0SDimitry Andric def: Pat<(fadd HVF32:$Rs, HVF32:$Rt), 49104eeddc0SDimitry Andric (V6_vadd_sf_sf HVF32:$Rs, HVF32:$Rt)>; 49204eeddc0SDimitry Andric def: Pat<(fsub HVF16:$Rs, HVF16:$Rt), 49304eeddc0SDimitry Andric (V6_vsub_hf_hf HVF16:$Rs, HVF16:$Rt)>; 49404eeddc0SDimitry Andric def: Pat<(fsub HVF32:$Rs, HVF32:$Rt), 49504eeddc0SDimitry Andric (V6_vsub_sf_sf HVF32:$Rs, HVF32:$Rt)>; 49604eeddc0SDimitry Andric def: Pat<(fmul HVF16:$Rs, HVF16:$Rt), 49704eeddc0SDimitry Andric (V6_vmpy_hf_hf HVF16:$Rs, HVF16:$Rt)>; 49804eeddc0SDimitry Andric def: Pat<(fmul HVF32:$Rs, HVF32:$Rt), 49904eeddc0SDimitry Andric (V6_vmpy_sf_sf HVF32:$Rs, HVF32:$Rt)>; 50004eeddc0SDimitry Andric 50104eeddc0SDimitry Andric def: Pat<(VecF16 (pf1<fpround> HWF32:$Vuu)), 50204eeddc0SDimitry Andric (V6_vdealh (V6_vcvt_hf_sf (HiVec HvxWR:$Vuu), (LoVec HvxWR:$Vuu)))>; 50304eeddc0SDimitry Andric def: Pat<(VecPF32 (pf1<fpextend> HVF16:$Vu)), 50404eeddc0SDimitry Andric (V6_vcvt_sf_hf (V6_vshuffh HvxVR:$Vu))>; 50504eeddc0SDimitry Andric 50604eeddc0SDimitry Andric def: OpR_R_pat<V6_vcvt_h_hf, Fptosi, VecI16, HVF16>; 50704eeddc0SDimitry Andric def: OpR_R_pat<V6_vcvt_uh_hf, Fptoui, VecI16, HVF16>; 50804eeddc0SDimitry Andric def: OpR_R_pat<V6_vcvt_hf_h, Sitofp, VecF16, HVI16>; 50904eeddc0SDimitry Andric def: OpR_R_pat<V6_vcvt_hf_uh, Uitofp, VecF16, HVI16>; 51004eeddc0SDimitry Andric 51104eeddc0SDimitry Andric def: Pat<(VecI8 (Fptosi HWF16:$Vu)), 51204eeddc0SDimitry Andric (V6_vcvt_b_hf (HiVec $Vu), (LoVec $Vu))>; 51304eeddc0SDimitry Andric def: Pat<(VecI8 (Fptoui HWF16:$Vu)), 51404eeddc0SDimitry Andric (V6_vcvt_ub_hf (HiVec $Vu), (LoVec $Vu))>; 51504eeddc0SDimitry Andric def: Pat<(VecPF16 (Sitofp HVI8:$Vu)), (V6_vcvt_hf_b HvxVR:$Vu)>; 51604eeddc0SDimitry Andric def: Pat<(VecPF16 (Uitofp HVI8:$Vu)), (V6_vcvt_hf_ub HvxVR:$Vu)>; 51704eeddc0SDimitry Andric} 51804eeddc0SDimitry Andric 51904eeddc0SDimitry Andriclet Predicates = [UseHVXV68, UseHVXFloatingPoint] in { 52004eeddc0SDimitry Andric def: Pat<(vselect HQ16:$Qu, HVF16:$Vs, HVF16:$Vt), 52104eeddc0SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vs, HvxVR:$Vt)>; 52204eeddc0SDimitry Andric def: Pat<(vselect (qnot HQ16:$Qu), HVF16:$Vs, HVF16:$Vt), 52304eeddc0SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vt, HvxVR:$Vs)>; 52404eeddc0SDimitry Andric 52504eeddc0SDimitry Andric def: Pat<(vselect HQ32:$Qu, HVF32:$Vs, HVF32:$Vt), 52604eeddc0SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vs, HvxVR:$Vt)>; 52704eeddc0SDimitry Andric def: Pat<(vselect (qnot HQ32:$Qu), HVF32:$Vs, HVF32:$Vt), 52804eeddc0SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vt, HvxVR:$Vs)>; 52904eeddc0SDimitry Andric} 53004eeddc0SDimitry Andric 53104eeddc0SDimitry Andriclet Predicates = [UseHVXV68, UseHVX128B, UseHVXQFloat] in { 53204eeddc0SDimitry Andric let AddedComplexity = 220 in { 53304eeddc0SDimitry Andric defm: MinMax_pats<V6_vmin_hf, V6_vmax_hf, vselect, setgt, VecQ16, HVF16>; 53404eeddc0SDimitry Andric defm: MinMax_pats<V6_vmin_hf, V6_vmax_hf, vselect, setogt, VecQ16, HVF16>; 53504eeddc0SDimitry Andric defm: MinMax_pats<V6_vmin_sf, V6_vmax_sf, vselect, setgt, VecQ32, HVF32>; 53604eeddc0SDimitry Andric defm: MinMax_pats<V6_vmin_sf, V6_vmax_sf, vselect, setogt, VecQ32, HVF32>; 53704eeddc0SDimitry Andric } 53804eeddc0SDimitry Andric def: OpR_RR_pat<V6_vmin_hf, pf2<fminnum>, VecF16, HVF16>; 53904eeddc0SDimitry Andric def: OpR_RR_pat<V6_vmax_hf, pf2<fmaxnum>, VecF16, HVF16>; 54004eeddc0SDimitry Andric def: OpR_RR_pat<V6_vmin_sf, pf2<fminnum>, VecF32, HVF32>; 54104eeddc0SDimitry Andric def: OpR_RR_pat<V6_vmax_sf, pf2<fmaxnum>, VecF32, HVF32>; 54204eeddc0SDimitry Andric} 54304eeddc0SDimitry Andric 54404eeddc0SDimitry Andriclet Predicates = [UseHVXV68, UseHVX128B, UseHVXIEEEFP] in { 54504eeddc0SDimitry Andric let AddedComplexity = 220 in { 54604eeddc0SDimitry Andric defm: MinMax_pats<V6_vfmin_hf, V6_vfmax_hf, vselect, setgt, VecQ16, HVF16>; 54704eeddc0SDimitry Andric defm: MinMax_pats<V6_vfmin_hf, V6_vfmax_hf, vselect, setogt, VecQ16, HVF16>; 54804eeddc0SDimitry Andric defm: MinMax_pats<V6_vfmin_sf, V6_vfmax_sf, vselect, setgt, VecQ32, HVF32>; 54904eeddc0SDimitry Andric defm: MinMax_pats<V6_vfmin_sf, V6_vfmax_sf, vselect, setogt, VecQ32, HVF32>; 55004eeddc0SDimitry Andric } 55104eeddc0SDimitry Andric def: OpR_RR_pat<V6_vfmin_hf, pf2<fminnum>, VecF16, HVF16>; 55204eeddc0SDimitry Andric def: OpR_RR_pat<V6_vfmax_hf, pf2<fmaxnum>, VecF16, HVF16>; 55304eeddc0SDimitry Andric def: OpR_RR_pat<V6_vfmin_sf, pf2<fminnum>, VecF32, HVF32>; 55404eeddc0SDimitry Andric def: OpR_RR_pat<V6_vfmax_sf, pf2<fmaxnum>, VecF32, HVF32>; 55504eeddc0SDimitry Andric} 55604eeddc0SDimitry Andric 5570b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 558e8d8bef9SDimitry Andric // For i8 vectors Vs = (a0, a1, ...), Vt = (b0, b1, ...), 559e8d8bef9SDimitry Andric // V6_vmpybv Vs, Vt produces a pair of i16 vectors Hi:Lo, 560e8d8bef9SDimitry Andric // where Lo = (a0*b0, a2*b2, ...), Hi = (a1*b1, a3*b3, ...). 561e8d8bef9SDimitry Andric def: Pat<(mul HVI8:$Vs, HVI8:$Vt), 562e8d8bef9SDimitry Andric (V6_vshuffeb (HiVec (V6_vmpybv HvxVR:$Vs, HvxVR:$Vt)), 563e8d8bef9SDimitry Andric (LoVec (V6_vmpybv HvxVR:$Vs, HvxVR:$Vt)))>; 564e8d8bef9SDimitry Andric def: Pat<(mul HVI16:$Vs, HVI16:$Vt), 565e8d8bef9SDimitry Andric (V6_vmpyih HvxVR:$Vs, HvxVR:$Vt)>; 566e8d8bef9SDimitry Andric def: Pat<(mul HVI32:$Vs, HVI32:$Vt), 567e8d8bef9SDimitry Andric (V6_vmpyiewuh_acc (V6_vmpyieoh HvxVR:$Vs, HvxVR:$Vt), 568e8d8bef9SDimitry Andric HvxVR:$Vs, HvxVR:$Vt)>; 569e8d8bef9SDimitry Andric} 570e8d8bef9SDimitry Andric 571e8d8bef9SDimitry Andriclet Predicates = [UseHVX] in { 5720b57cec5SDimitry Andric def: Pat<(VecPI16 (sext HVI8:$Vs)), (VSxtb $Vs)>; 5730b57cec5SDimitry Andric def: Pat<(VecPI32 (sext HVI16:$Vs)), (VSxth $Vs)>; 5740b57cec5SDimitry Andric def: Pat<(VecPI16 (zext HVI8:$Vs)), (VZxtb $Vs)>; 5750b57cec5SDimitry Andric def: Pat<(VecPI32 (zext HVI16:$Vs)), (VZxth $Vs)>; 5760b57cec5SDimitry Andric 5770b57cec5SDimitry Andric def: Pat<(VecI16 (sext_invec HVI8:$Vs)), (LoVec (VSxtb $Vs))>; 5780b57cec5SDimitry Andric def: Pat<(VecI32 (sext_invec HVI16:$Vs)), (LoVec (VSxth $Vs))>; 5790b57cec5SDimitry Andric def: Pat<(VecI32 (sext_invec HVI8:$Vs)), 5800b57cec5SDimitry Andric (LoVec (VSxth (LoVec (VSxtb $Vs))))>; 5810b57cec5SDimitry Andric def: Pat<(VecPI16 (sext_invec HWI8:$Vss)), (VSxtb (LoVec $Vss))>; 5820b57cec5SDimitry Andric def: Pat<(VecPI32 (sext_invec HWI16:$Vss)), (VSxth (LoVec $Vss))>; 5830b57cec5SDimitry Andric def: Pat<(VecPI32 (sext_invec HWI8:$Vss)), 5840b57cec5SDimitry Andric (VSxth (LoVec (VSxtb (LoVec $Vss))))>; 5850b57cec5SDimitry Andric 5860b57cec5SDimitry Andric def: Pat<(VecI16 (zext_invec HVI8:$Vs)), (LoVec (VZxtb $Vs))>; 5870b57cec5SDimitry Andric def: Pat<(VecI32 (zext_invec HVI16:$Vs)), (LoVec (VZxth $Vs))>; 5880b57cec5SDimitry Andric def: Pat<(VecI32 (zext_invec HVI8:$Vs)), 5890b57cec5SDimitry Andric (LoVec (VZxth (LoVec (VZxtb $Vs))))>; 5900b57cec5SDimitry Andric def: Pat<(VecPI16 (zext_invec HWI8:$Vss)), (VZxtb (LoVec $Vss))>; 5910b57cec5SDimitry Andric def: Pat<(VecPI32 (zext_invec HWI16:$Vss)), (VZxth (LoVec $Vss))>; 5920b57cec5SDimitry Andric def: Pat<(VecPI32 (zext_invec HWI8:$Vss)), 5930b57cec5SDimitry Andric (VZxth (LoVec (VZxtb (LoVec $Vss))))>; 5940b57cec5SDimitry Andric 5950b57cec5SDimitry Andric def: Pat<(VecI8 (trunc HWI16:$Vss)), 5960b57cec5SDimitry Andric (V6_vpackeb (HiVec $Vss), (LoVec $Vss))>; 5970b57cec5SDimitry Andric def: Pat<(VecI16 (trunc HWI32:$Vss)), 5980b57cec5SDimitry Andric (V6_vpackeh (HiVec $Vss), (LoVec $Vss))>; 5990b57cec5SDimitry Andric 6000b57cec5SDimitry Andric def: Pat<(VecQ8 (trunc HVI8:$Vs)), 6010b57cec5SDimitry Andric (V6_vandvrt HvxVR:$Vs, (A2_tfrsi 0x01010101))>; 6020b57cec5SDimitry Andric def: Pat<(VecQ16 (trunc HVI16:$Vs)), 6030b57cec5SDimitry Andric (V6_vandvrt HvxVR:$Vs, (A2_tfrsi 0x01010101))>; 6040b57cec5SDimitry Andric def: Pat<(VecQ32 (trunc HVI32:$Vs)), 6050b57cec5SDimitry Andric (V6_vandvrt HvxVR:$Vs, (A2_tfrsi 0x01010101))>; 6060b57cec5SDimitry Andric} 6070b57cec5SDimitry Andric 6080b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 6090b57cec5SDimitry Andric // The "source" types are not legal, and there are no parameterized 6100b57cec5SDimitry Andric // definitions for them, but they are length-specific. 6110b57cec5SDimitry Andric let Predicates = [UseHVX,UseHVX64B] in { 6120b57cec5SDimitry Andric def: Pat<(VecI16 (sext_inreg HVI16:$Vs, v32i8)), 6130b57cec5SDimitry Andric (V6_vasrh (V6_vaslh HVI16:$Vs, (A2_tfrsi 8)), (A2_tfrsi 8))>; 6140b57cec5SDimitry Andric def: Pat<(VecI32 (sext_inreg HVI32:$Vs, v16i8)), 6150b57cec5SDimitry Andric (V6_vasrw (V6_vaslw HVI32:$Vs, (A2_tfrsi 24)), (A2_tfrsi 24))>; 6160b57cec5SDimitry Andric def: Pat<(VecI32 (sext_inreg HVI32:$Vs, v16i16)), 6170b57cec5SDimitry Andric (V6_vasrw (V6_vaslw HVI32:$Vs, (A2_tfrsi 16)), (A2_tfrsi 16))>; 6180b57cec5SDimitry Andric } 6190b57cec5SDimitry Andric let Predicates = [UseHVX,UseHVX128B] in { 6200b57cec5SDimitry Andric def: Pat<(VecI16 (sext_inreg HVI16:$Vs, v64i8)), 6210b57cec5SDimitry Andric (V6_vasrh (V6_vaslh HVI16:$Vs, (A2_tfrsi 8)), (A2_tfrsi 8))>; 6220b57cec5SDimitry Andric def: Pat<(VecI32 (sext_inreg HVI32:$Vs, v32i8)), 6230b57cec5SDimitry Andric (V6_vasrw (V6_vaslw HVI32:$Vs, (A2_tfrsi 24)), (A2_tfrsi 24))>; 6240b57cec5SDimitry Andric def: Pat<(VecI32 (sext_inreg HVI32:$Vs, v32i16)), 6250b57cec5SDimitry Andric (V6_vasrw (V6_vaslw HVI32:$Vs, (A2_tfrsi 16)), (A2_tfrsi 16))>; 6260b57cec5SDimitry Andric } 6270b57cec5SDimitry Andric 628e8d8bef9SDimitry Andric // Take a pair of vectors Vt:Vs and shift them towards LSB by (Rt & HwLen). 629e8d8bef9SDimitry Andric def: Pat<(VecI8 (valign HVI8:$Vt, HVI8:$Vs, I32:$Rt)), 630e8d8bef9SDimitry Andric (LoVec (V6_valignb HvxVR:$Vt, HvxVR:$Vs, I32:$Rt))>; 631e8d8bef9SDimitry Andric def: Pat<(VecI16 (valign HVI16:$Vt, HVI16:$Vs, I32:$Rt)), 632e8d8bef9SDimitry Andric (LoVec (V6_valignb HvxVR:$Vt, HvxVR:$Vs, I32:$Rt))>; 633e8d8bef9SDimitry Andric def: Pat<(VecI32 (valign HVI32:$Vt, HVI32:$Vs, I32:$Rt)), 634e8d8bef9SDimitry Andric (LoVec (V6_valignb HvxVR:$Vt, HvxVR:$Vs, I32:$Rt))>; 635e8d8bef9SDimitry Andric 6360b57cec5SDimitry Andric def: Pat<(HexagonVASL HVI8:$Vs, I32:$Rt), 6370b57cec5SDimitry Andric (V6_vpackeb (V6_vaslh (HiVec (VZxtb HvxVR:$Vs)), I32:$Rt), 6380b57cec5SDimitry Andric (V6_vaslh (LoVec (VZxtb HvxVR:$Vs)), I32:$Rt))>; 6390b57cec5SDimitry Andric def: Pat<(HexagonVASR HVI8:$Vs, I32:$Rt), 6400b57cec5SDimitry Andric (V6_vpackeb (V6_vasrh (HiVec (VSxtb HvxVR:$Vs)), I32:$Rt), 6410b57cec5SDimitry Andric (V6_vasrh (LoVec (VSxtb HvxVR:$Vs)), I32:$Rt))>; 6420b57cec5SDimitry Andric def: Pat<(HexagonVLSR HVI8:$Vs, I32:$Rt), 6430b57cec5SDimitry Andric (V6_vpackeb (V6_vlsrh (HiVec (VZxtb HvxVR:$Vs)), I32:$Rt), 6440b57cec5SDimitry Andric (V6_vlsrh (LoVec (VZxtb HvxVR:$Vs)), I32:$Rt))>; 6450b57cec5SDimitry Andric 6460b57cec5SDimitry Andric def: Pat<(HexagonVASL HVI16:$Vs, I32:$Rt), (V6_vaslh HvxVR:$Vs, I32:$Rt)>; 6470b57cec5SDimitry Andric def: Pat<(HexagonVASL HVI32:$Vs, I32:$Rt), (V6_vaslw HvxVR:$Vs, I32:$Rt)>; 6480b57cec5SDimitry Andric def: Pat<(HexagonVASR HVI16:$Vs, I32:$Rt), (V6_vasrh HvxVR:$Vs, I32:$Rt)>; 6490b57cec5SDimitry Andric def: Pat<(HexagonVASR HVI32:$Vs, I32:$Rt), (V6_vasrw HvxVR:$Vs, I32:$Rt)>; 6500b57cec5SDimitry Andric def: Pat<(HexagonVLSR HVI16:$Vs, I32:$Rt), (V6_vlsrh HvxVR:$Vs, I32:$Rt)>; 6510b57cec5SDimitry Andric def: Pat<(HexagonVLSR HVI32:$Vs, I32:$Rt), (V6_vlsrw HvxVR:$Vs, I32:$Rt)>; 6520b57cec5SDimitry Andric 6530b57cec5SDimitry Andric def: Pat<(add HVI32:$Vx, (HexagonVASL HVI32:$Vu, I32:$Rt)), 6540b57cec5SDimitry Andric (V6_vaslw_acc HvxVR:$Vx, HvxVR:$Vu, I32:$Rt)>; 6550b57cec5SDimitry Andric def: Pat<(add HVI32:$Vx, (HexagonVASR HVI32:$Vu, I32:$Rt)), 6560b57cec5SDimitry Andric (V6_vasrw_acc HvxVR:$Vx, HvxVR:$Vu, I32:$Rt)>; 6570b57cec5SDimitry Andric 6580b57cec5SDimitry Andric def: Pat<(shl HVI16:$Vs, HVI16:$Vt), (V6_vaslhv HvxVR:$Vs, HvxVR:$Vt)>; 6590b57cec5SDimitry Andric def: Pat<(shl HVI32:$Vs, HVI32:$Vt), (V6_vaslwv HvxVR:$Vs, HvxVR:$Vt)>; 6600b57cec5SDimitry Andric def: Pat<(sra HVI16:$Vs, HVI16:$Vt), (V6_vasrhv HvxVR:$Vs, HvxVR:$Vt)>; 6610b57cec5SDimitry Andric def: Pat<(sra HVI32:$Vs, HVI32:$Vt), (V6_vasrwv HvxVR:$Vs, HvxVR:$Vt)>; 6620b57cec5SDimitry Andric def: Pat<(srl HVI16:$Vs, HVI16:$Vt), (V6_vlsrhv HvxVR:$Vs, HvxVR:$Vt)>; 6630b57cec5SDimitry Andric def: Pat<(srl HVI32:$Vs, HVI32:$Vt), (V6_vlsrwv HvxVR:$Vs, HvxVR:$Vt)>; 6640b57cec5SDimitry Andric 665e8d8bef9SDimitry Andric // Vpackl is a pseudo-op that is used when legalizing widened truncates. 666e8d8bef9SDimitry Andric // It should never be produced with a register pair in the output, but 667e8d8bef9SDimitry Andric // it can happen to have a pair as an input. 668e8d8bef9SDimitry Andric def: Pat<(VecI8 (vpackl HVI16:$Vs)), (V6_vdealb HvxVR:$Vs)>; 669e8d8bef9SDimitry Andric def: Pat<(VecI8 (vpackl HVI32:$Vs)), (V6_vdealb4w (IMPLICIT_DEF), HvxVR:$Vs)>; 670e8d8bef9SDimitry Andric def: Pat<(VecI16 (vpackl HVI32:$Vs)), (V6_vdealh HvxVR:$Vs)>; 671e8d8bef9SDimitry Andric def: Pat<(VecI8 (vpackl HWI16:$Vs)), (V6_vpackeb (HiVec $Vs), (LoVec $Vs))>; 672e8d8bef9SDimitry Andric def: Pat<(VecI8 (vpackl HWI32:$Vs)), 673e8d8bef9SDimitry Andric (V6_vpackeb (IMPLICIT_DEF), (V6_vpackeh (HiVec $Vs), (LoVec $Vs)))>; 674e8d8bef9SDimitry Andric def: Pat<(VecI16 (vpackl HWI32:$Vs)), (V6_vpackeh (HiVec $Vs), (LoVec $Vs))>; 675e8d8bef9SDimitry Andric 676e8d8bef9SDimitry Andric def: Pat<(VecI16 (vunpack HVI8:$Vs)), (LoVec (VSxtb $Vs))>; 677e8d8bef9SDimitry Andric def: Pat<(VecI32 (vunpack HVI8:$Vs)), (LoVec (VSxth (LoVec (VSxtb $Vs))))>; 678e8d8bef9SDimitry Andric def: Pat<(VecI32 (vunpack HVI16:$Vs)), (LoVec (VSxth $Vs))>; 679e8d8bef9SDimitry Andric def: Pat<(VecPI16 (vunpack HVI8:$Vs)), (VSxtb $Vs)>; 680e8d8bef9SDimitry Andric def: Pat<(VecPI32 (vunpack HVI8:$Vs)), (VSxth (LoVec (VSxtb $Vs)))>; 681e8d8bef9SDimitry Andric def: Pat<(VecPI32 (vunpack HVI32:$Vs)), (VSxth $Vs)>; 682e8d8bef9SDimitry Andric 683e8d8bef9SDimitry Andric def: Pat<(VecI16 (vunpacku HVI8:$Vs)), (LoVec (VZxtb $Vs))>; 684e8d8bef9SDimitry Andric def: Pat<(VecI32 (vunpacku HVI8:$Vs)), (LoVec (VZxth (LoVec (VZxtb $Vs))))>; 685e8d8bef9SDimitry Andric def: Pat<(VecI32 (vunpacku HVI16:$Vs)), (LoVec (VZxth $Vs))>; 686e8d8bef9SDimitry Andric def: Pat<(VecPI16 (vunpacku HVI8:$Vs)), (VZxtb $Vs)>; 687e8d8bef9SDimitry Andric def: Pat<(VecPI32 (vunpacku HVI8:$Vs)), (VZxth (LoVec (VZxtb $Vs)))>; 688e8d8bef9SDimitry Andric def: Pat<(VecPI32 (vunpacku HVI32:$Vs)), (VZxth $Vs)>; 689e8d8bef9SDimitry Andric 690e8d8bef9SDimitry Andric let Predicates = [UseHVX,UseHVXV60] in { 6910b57cec5SDimitry Andric def: Pat<(VecI16 (bswap HVI16:$Vs)), 692e8d8bef9SDimitry Andric (V6_vdelta HvxVR:$Vs, (V60splatib (i32 0x01)))>; 6930b57cec5SDimitry Andric def: Pat<(VecI32 (bswap HVI32:$Vs)), 694e8d8bef9SDimitry Andric (V6_vdelta HvxVR:$Vs, (V60splatib (i32 0x03)))>; 695e8d8bef9SDimitry Andric } 696e8d8bef9SDimitry Andric let Predicates = [UseHVX,UseHVXV62], AddedComplexity = 10 in { 697e8d8bef9SDimitry Andric def: Pat<(VecI16 (bswap HVI16:$Vs)), 698e8d8bef9SDimitry Andric (V6_vdelta HvxVR:$Vs, (V62splatib (i32 0x01)))>; 699e8d8bef9SDimitry Andric def: Pat<(VecI32 (bswap HVI32:$Vs)), 700e8d8bef9SDimitry Andric (V6_vdelta HvxVR:$Vs, (V62splatib (i32 0x03)))>; 701e8d8bef9SDimitry Andric } 7020b57cec5SDimitry Andric 7030b57cec5SDimitry Andric def: Pat<(VecI8 (ctpop HVI8:$Vs)), 7040b57cec5SDimitry Andric (V6_vpackeb (V6_vpopcounth (HiVec (V6_vunpackub HvxVR:$Vs))), 7050b57cec5SDimitry Andric (V6_vpopcounth (LoVec (V6_vunpackub HvxVR:$Vs))))>; 7060b57cec5SDimitry Andric def: Pat<(VecI16 (ctpop HVI16:$Vs)), (V6_vpopcounth HvxVR:$Vs)>; 7070b57cec5SDimitry Andric def: Pat<(VecI32 (ctpop HVI32:$Vs)), 7080b57cec5SDimitry Andric (V6_vaddw (LoVec (V6_vzh (V6_vpopcounth HvxVR:$Vs))), 7090b57cec5SDimitry Andric (HiVec (V6_vzh (V6_vpopcounth HvxVR:$Vs))))>; 7100b57cec5SDimitry Andric 711e8d8bef9SDimitry Andric let Predicates = [UseHVX,UseHVXV60] in 7120b57cec5SDimitry Andric def: Pat<(VecI8 (ctlz HVI8:$Vs)), 7130b57cec5SDimitry Andric (V6_vsubb (V6_vpackeb (V6_vcl0h (HiVec (V6_vunpackub HvxVR:$Vs))), 7140b57cec5SDimitry Andric (V6_vcl0h (LoVec (V6_vunpackub HvxVR:$Vs)))), 715e8d8bef9SDimitry Andric (V60splatib (i32 0x08)))>; 716e8d8bef9SDimitry Andric let Predicates = [UseHVX,UseHVXV62], AddedComplexity = 10 in 717e8d8bef9SDimitry Andric def: Pat<(VecI8 (ctlz HVI8:$Vs)), 718e8d8bef9SDimitry Andric (V6_vsubb (V6_vpackeb (V6_vcl0h (HiVec (V6_vunpackub HvxVR:$Vs))), 719e8d8bef9SDimitry Andric (V6_vcl0h (LoVec (V6_vunpackub HvxVR:$Vs)))), 720e8d8bef9SDimitry Andric (V62splatib (i32 0x08)))>; 721e8d8bef9SDimitry Andric 7220b57cec5SDimitry Andric def: Pat<(VecI16 (ctlz HVI16:$Vs)), (V6_vcl0h HvxVR:$Vs)>; 7230b57cec5SDimitry Andric def: Pat<(VecI32 (ctlz HVI32:$Vs)), (V6_vcl0w HvxVR:$Vs)>; 7240b57cec5SDimitry Andric} 7250b57cec5SDimitry Andric 7260b57cec5SDimitry Andricclass HvxSel_pat<InstHexagon MI, PatFrag RegPred> 7270b57cec5SDimitry Andric : Pat<(select I1:$Pu, RegPred:$Vs, RegPred:$Vt), 7280b57cec5SDimitry Andric (MI I1:$Pu, RegPred:$Vs, RegPred:$Vt)>; 7290b57cec5SDimitry Andric 7300b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 7310b57cec5SDimitry Andric def: HvxSel_pat<PS_vselect, HVI8>; 7320b57cec5SDimitry Andric def: HvxSel_pat<PS_vselect, HVI16>; 7330b57cec5SDimitry Andric def: HvxSel_pat<PS_vselect, HVI32>; 7340b57cec5SDimitry Andric def: HvxSel_pat<PS_wselect, HWI8>; 7350b57cec5SDimitry Andric def: HvxSel_pat<PS_wselect, HWI16>; 7360b57cec5SDimitry Andric def: HvxSel_pat<PS_wselect, HWI32>; 7370b57cec5SDimitry Andric} 7380b57cec5SDimitry Andric 73904eeddc0SDimitry Andricdef V2Q: OutPatFrag<(ops node:$Vs), (V6_vandvrt $Vs, (A2_tfrsi -1))>; 74004eeddc0SDimitry Andric 741*81ad6265SDimitry Andriclet Predicates = [UseHVX] in { 742*81ad6265SDimitry Andric def: Pat<(select I1:$Pu, VecQ8:$Qs, VecQ8:$Qt), 74304eeddc0SDimitry Andric (V2Q (PS_vselect $Pu, (Q2V $Qs), (Q2V $Qt)))>; 744*81ad6265SDimitry Andric def: Pat<(select I1:$Pu, VecQ16:$Qs, VecQ16:$Qt), 745*81ad6265SDimitry Andric (V2Q (PS_vselect $Pu, (Q2V $Qs), (Q2V $Qt)))>; 746*81ad6265SDimitry Andric def: Pat<(select I1:$Pu, VecQ32:$Qs, VecQ32:$Qt), 747*81ad6265SDimitry Andric (V2Q (PS_vselect $Pu, (Q2V $Qs), (Q2V $Qt)))>; 748*81ad6265SDimitry Andric} 74904eeddc0SDimitry Andric 7500b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 7510b57cec5SDimitry Andric def: Pat<(VecQ8 (qtrue)), (PS_qtrue)>; 7520b57cec5SDimitry Andric def: Pat<(VecQ16 (qtrue)), (PS_qtrue)>; 7530b57cec5SDimitry Andric def: Pat<(VecQ32 (qtrue)), (PS_qtrue)>; 7540b57cec5SDimitry Andric def: Pat<(VecQ8 (qfalse)), (PS_qfalse)>; 7550b57cec5SDimitry Andric def: Pat<(VecQ16 (qfalse)), (PS_qfalse)>; 7560b57cec5SDimitry Andric def: Pat<(VecQ32 (qfalse)), (PS_qfalse)>; 7570b57cec5SDimitry Andric 7580b57cec5SDimitry Andric def: Pat<(vnot HQ8:$Qs), (V6_pred_not HvxQR:$Qs)>; 7590b57cec5SDimitry Andric def: Pat<(vnot HQ16:$Qs), (V6_pred_not HvxQR:$Qs)>; 7600b57cec5SDimitry Andric def: Pat<(vnot HQ32:$Qs), (V6_pred_not HvxQR:$Qs)>; 7610b57cec5SDimitry Andric def: Pat<(qnot HQ8:$Qs), (V6_pred_not HvxQR:$Qs)>; 7620b57cec5SDimitry Andric def: Pat<(qnot HQ16:$Qs), (V6_pred_not HvxQR:$Qs)>; 7630b57cec5SDimitry Andric def: Pat<(qnot HQ32:$Qs), (V6_pred_not HvxQR:$Qs)>; 7640b57cec5SDimitry Andric 7650b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_and, And, VecQ8, HQ8>; 7660b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_and, And, VecQ16, HQ16>; 7670b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_and, And, VecQ32, HQ32>; 7680b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_or, Or, VecQ8, HQ8>; 7690b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_or, Or, VecQ16, HQ16>; 7700b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_or, Or, VecQ32, HQ32>; 7710b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_xor, Xor, VecQ8, HQ8>; 7720b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_xor, Xor, VecQ16, HQ16>; 7730b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_xor, Xor, VecQ32, HQ32>; 7740b57cec5SDimitry Andric 775fe6060f1SDimitry Andric def: OpR_RR_pat<V6_pred_and_n, VNot2<And, qnot>, VecQ8, HQ8>; 776fe6060f1SDimitry Andric def: OpR_RR_pat<V6_pred_and_n, VNot2<And, qnot>, VecQ16, HQ16>; 777fe6060f1SDimitry Andric def: OpR_RR_pat<V6_pred_and_n, VNot2<And, qnot>, VecQ32, HQ32>; 778fe6060f1SDimitry Andric def: OpR_RR_pat<V6_pred_or_n, VNot2<Or, qnot>, VecQ8, HQ8>; 779fe6060f1SDimitry Andric def: OpR_RR_pat<V6_pred_or_n, VNot2<Or, qnot>, VecQ16, HQ16>; 780fe6060f1SDimitry Andric def: OpR_RR_pat<V6_pred_or_n, VNot2<Or, qnot>, VecQ32, HQ32>; 7810b57cec5SDimitry Andric 7820b57cec5SDimitry Andric def: OpR_RR_pat<V6_veqb, seteq, VecQ8, HVI8>; 7830b57cec5SDimitry Andric def: OpR_RR_pat<V6_veqh, seteq, VecQ16, HVI16>; 7840b57cec5SDimitry Andric def: OpR_RR_pat<V6_veqw, seteq, VecQ32, HVI32>; 7850b57cec5SDimitry Andric def: OpR_RR_pat<V6_vgtb, setgt, VecQ8, HVI8>; 7860b57cec5SDimitry Andric def: OpR_RR_pat<V6_vgth, setgt, VecQ16, HVI16>; 7870b57cec5SDimitry Andric def: OpR_RR_pat<V6_vgtw, setgt, VecQ32, HVI32>; 7880b57cec5SDimitry Andric def: OpR_RR_pat<V6_vgtub, setugt, VecQ8, HVI8>; 7890b57cec5SDimitry Andric def: OpR_RR_pat<V6_vgtuh, setugt, VecQ16, HVI16>; 7900b57cec5SDimitry Andric def: OpR_RR_pat<V6_vgtuw, setugt, VecQ32, HVI32>; 7910b57cec5SDimitry Andric 7920b57cec5SDimitry Andric def: AccRRR_pat<V6_veqb_and, And, seteq, HQ8, HVI8, HVI8>; 7930b57cec5SDimitry Andric def: AccRRR_pat<V6_veqb_or, Or, seteq, HQ8, HVI8, HVI8>; 7940b57cec5SDimitry Andric def: AccRRR_pat<V6_veqb_xor, Xor, seteq, HQ8, HVI8, HVI8>; 7950b57cec5SDimitry Andric def: AccRRR_pat<V6_veqh_and, And, seteq, HQ16, HVI16, HVI16>; 7960b57cec5SDimitry Andric def: AccRRR_pat<V6_veqh_or, Or, seteq, HQ16, HVI16, HVI16>; 7970b57cec5SDimitry Andric def: AccRRR_pat<V6_veqh_xor, Xor, seteq, HQ16, HVI16, HVI16>; 7980b57cec5SDimitry Andric def: AccRRR_pat<V6_veqw_and, And, seteq, HQ32, HVI32, HVI32>; 7990b57cec5SDimitry Andric def: AccRRR_pat<V6_veqw_or, Or, seteq, HQ32, HVI32, HVI32>; 8000b57cec5SDimitry Andric def: AccRRR_pat<V6_veqw_xor, Xor, seteq, HQ32, HVI32, HVI32>; 8010b57cec5SDimitry Andric 8020b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtb_and, And, setgt, HQ8, HVI8, HVI8>; 8030b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtb_or, Or, setgt, HQ8, HVI8, HVI8>; 8040b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtb_xor, Xor, setgt, HQ8, HVI8, HVI8>; 8050b57cec5SDimitry Andric def: AccRRR_pat<V6_vgth_and, And, setgt, HQ16, HVI16, HVI16>; 8060b57cec5SDimitry Andric def: AccRRR_pat<V6_vgth_or, Or, setgt, HQ16, HVI16, HVI16>; 8070b57cec5SDimitry Andric def: AccRRR_pat<V6_vgth_xor, Xor, setgt, HQ16, HVI16, HVI16>; 8080b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtw_and, And, setgt, HQ32, HVI32, HVI32>; 8090b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtw_or, Or, setgt, HQ32, HVI32, HVI32>; 8100b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtw_xor, Xor, setgt, HQ32, HVI32, HVI32>; 8110b57cec5SDimitry Andric 8120b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtub_and, And, setugt, HQ8, HVI8, HVI8>; 8130b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtub_or, Or, setugt, HQ8, HVI8, HVI8>; 8140b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtub_xor, Xor, setugt, HQ8, HVI8, HVI8>; 8150b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtuh_and, And, setugt, HQ16, HVI16, HVI16>; 8160b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtuh_or, Or, setugt, HQ16, HVI16, HVI16>; 8170b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtuh_xor, Xor, setugt, HQ16, HVI16, HVI16>; 8180b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtuw_and, And, setugt, HQ32, HVI32, HVI32>; 8190b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtuw_or, Or, setugt, HQ32, HVI32, HVI32>; 8200b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtuw_xor, Xor, setugt, HQ32, HVI32, HVI32>; 8210b57cec5SDimitry Andric} 82204eeddc0SDimitry Andric 82304eeddc0SDimitry Andriclet Predicates = [UseHVXV68, UseHVXFloatingPoint] in { 82404eeddc0SDimitry Andric def: OpR_RR_pat<V6_veqh, seteq, VecQ16, HVF16>; 82504eeddc0SDimitry Andric def: OpR_RR_pat<V6_veqh, setoeq, VecQ16, HVF16>; 82604eeddc0SDimitry Andric def: OpR_RR_pat<V6_veqh, setueq, VecQ16, HVF16>; 82704eeddc0SDimitry Andric def: OpR_RR_pat<V6_vgthf, setgt, VecQ16, HVF16>; 82804eeddc0SDimitry Andric def: OpR_RR_pat<V6_vgthf, setogt, VecQ16, HVF16>; 82904eeddc0SDimitry Andric def: OpR_RR_pat<V6_vgthf, setugt, VecQ16, HVF16>; 83004eeddc0SDimitry Andric 83104eeddc0SDimitry Andric def: OpR_RR_pat<V6_veqw, seteq, VecQ32, HVF32>; 83204eeddc0SDimitry Andric def: OpR_RR_pat<V6_veqw, setoeq, VecQ32, HVF32>; 83304eeddc0SDimitry Andric def: OpR_RR_pat<V6_veqw, setueq, VecQ32, HVF32>; 83404eeddc0SDimitry Andric def: OpR_RR_pat<V6_vgtsf, setgt, VecQ32, HVF32>; 83504eeddc0SDimitry Andric def: OpR_RR_pat<V6_vgtsf, setogt, VecQ32, HVF32>; 83604eeddc0SDimitry Andric def: OpR_RR_pat<V6_vgtsf, setugt, VecQ32, HVF32>; 83704eeddc0SDimitry Andric 83804eeddc0SDimitry Andric def: AccRRR_pat<V6_veqh_and, And, seteq, HQ16, HVF16, HVF16>; 83904eeddc0SDimitry Andric def: AccRRR_pat<V6_veqh_or, Or, seteq, HQ16, HVF16, HVF16>; 84004eeddc0SDimitry Andric def: AccRRR_pat<V6_veqh_xor, Xor, seteq, HQ16, HVF16, HVF16>; 84104eeddc0SDimitry Andric def: AccRRR_pat<V6_veqh_and, And, setoeq, HQ16, HVF16, HVF16>; 84204eeddc0SDimitry Andric def: AccRRR_pat<V6_veqh_or, Or, setoeq, HQ16, HVF16, HVF16>; 84304eeddc0SDimitry Andric def: AccRRR_pat<V6_veqh_xor, Xor, setoeq, HQ16, HVF16, HVF16>; 84404eeddc0SDimitry Andric def: AccRRR_pat<V6_veqh_and, And, setueq, HQ16, HVF16, HVF16>; 84504eeddc0SDimitry Andric def: AccRRR_pat<V6_veqh_or, Or, setueq, HQ16, HVF16, HVF16>; 84604eeddc0SDimitry Andric def: AccRRR_pat<V6_veqh_xor, Xor, setueq, HQ16, HVF16, HVF16>; 84704eeddc0SDimitry Andric def: AccRRR_pat<V6_vgthf_and, And, setgt, HQ16, HVF16, HVF16>; 84804eeddc0SDimitry Andric def: AccRRR_pat<V6_vgthf_or, Or, setgt, HQ16, HVF16, HVF16>; 84904eeddc0SDimitry Andric def: AccRRR_pat<V6_vgthf_xor, Xor, setgt, HQ16, HVF16, HVF16>; 85004eeddc0SDimitry Andric def: AccRRR_pat<V6_vgthf_and, And, setogt, HQ16, HVF16, HVF16>; 85104eeddc0SDimitry Andric def: AccRRR_pat<V6_vgthf_or, Or, setogt, HQ16, HVF16, HVF16>; 85204eeddc0SDimitry Andric def: AccRRR_pat<V6_vgthf_xor, Xor, setogt, HQ16, HVF16, HVF16>; 85304eeddc0SDimitry Andric def: AccRRR_pat<V6_vgthf_and, And, setugt, HQ16, HVF16, HVF16>; 85404eeddc0SDimitry Andric def: AccRRR_pat<V6_vgthf_or, Or, setugt, HQ16, HVF16, HVF16>; 85504eeddc0SDimitry Andric def: AccRRR_pat<V6_vgthf_xor, Xor, setugt, HQ16, HVF16, HVF16>; 85604eeddc0SDimitry Andric 85704eeddc0SDimitry Andric def: AccRRR_pat<V6_veqw_and, And, seteq, HQ32, HVF32, HVF32>; 85804eeddc0SDimitry Andric def: AccRRR_pat<V6_veqw_or, Or, seteq, HQ32, HVF32, HVF32>; 85904eeddc0SDimitry Andric def: AccRRR_pat<V6_veqw_xor, Xor, seteq, HQ32, HVF32, HVF32>; 86004eeddc0SDimitry Andric def: AccRRR_pat<V6_veqw_and, And, setoeq, HQ32, HVF32, HVF32>; 86104eeddc0SDimitry Andric def: AccRRR_pat<V6_veqw_or, Or, setoeq, HQ32, HVF32, HVF32>; 86204eeddc0SDimitry Andric def: AccRRR_pat<V6_veqw_xor, Xor, setoeq, HQ32, HVF32, HVF32>; 86304eeddc0SDimitry Andric def: AccRRR_pat<V6_veqw_and, And, setueq, HQ32, HVF32, HVF32>; 86404eeddc0SDimitry Andric def: AccRRR_pat<V6_veqw_or, Or, setueq, HQ32, HVF32, HVF32>; 86504eeddc0SDimitry Andric def: AccRRR_pat<V6_veqw_xor, Xor, setueq, HQ32, HVF32, HVF32>; 86604eeddc0SDimitry Andric def: AccRRR_pat<V6_vgtsf_and, And, setgt, HQ32, HVF32, HVF32>; 86704eeddc0SDimitry Andric def: AccRRR_pat<V6_vgtsf_or, Or, setgt, HQ32, HVF32, HVF32>; 86804eeddc0SDimitry Andric def: AccRRR_pat<V6_vgtsf_xor, Xor, setgt, HQ32, HVF32, HVF32>; 86904eeddc0SDimitry Andric def: AccRRR_pat<V6_vgtsf_and, And, setogt, HQ32, HVF32, HVF32>; 87004eeddc0SDimitry Andric def: AccRRR_pat<V6_vgtsf_or, Or, setogt, HQ32, HVF32, HVF32>; 87104eeddc0SDimitry Andric def: AccRRR_pat<V6_vgtsf_xor, Xor, setogt, HQ32, HVF32, HVF32>; 87204eeddc0SDimitry Andric def: AccRRR_pat<V6_vgtsf_and, And, setugt, HQ32, HVF32, HVF32>; 87304eeddc0SDimitry Andric def: AccRRR_pat<V6_vgtsf_or, Or, setugt, HQ32, HVF32, HVF32>; 87404eeddc0SDimitry Andric def: AccRRR_pat<V6_vgtsf_xor, Xor, setugt, HQ32, HVF32, HVF32>; 87504eeddc0SDimitry Andric 87604eeddc0SDimitry Andric def: Pat<(VecQ16 (setone HVF16:$Vt, HVF16:$Vu)), 87704eeddc0SDimitry Andric (V6_pred_not (V6_veqh HvxVR:$Vt, HvxVR:$Vu))>; 87804eeddc0SDimitry Andric 87904eeddc0SDimitry Andric def: Pat<(VecQ32 (setone HVF32:$Vt, HVF32:$Vu)), 88004eeddc0SDimitry Andric (V6_pred_not (V6_veqw HvxVR:$Vt, HvxVR:$Vu))>; 88104eeddc0SDimitry Andric} 882