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 9e8d8bef9SDimitry Andric 10e8d8bef9SDimitry Andricdef SDTVecUnaryOp: 11e8d8bef9SDimitry Andric SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVec<1>]>; 12e8d8bef9SDimitry Andric 130b57cec5SDimitry Andricdef SDTVecBinOp: 140b57cec5SDimitry Andric SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>, SDTCisSameAs<1,2>]>; 150b57cec5SDimitry Andric 160b57cec5SDimitry Andricdef SDTHexagonVEXTRACTW: SDTypeProfile<1, 2, 170b57cec5SDimitry Andric [SDTCisVT<0, i32>, SDTCisVec<1>, SDTCisVT<2, i32>]>; 180b57cec5SDimitry Andricdef HexagonVEXTRACTW : SDNode<"HexagonISD::VEXTRACTW", SDTHexagonVEXTRACTW>; 190b57cec5SDimitry Andric 200b57cec5SDimitry Andricdef SDTHexagonVINSERTW0: SDTypeProfile<1, 2, 210b57cec5SDimitry Andric [SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisVT<2, i32>]>; 220b57cec5SDimitry Andricdef HexagonVINSERTW0: SDNode<"HexagonISD::VINSERTW0", SDTHexagonVINSERTW0>; 230b57cec5SDimitry Andric 240b57cec5SDimitry Andricdef HwLen2: SDNodeXForm<imm, [{ 250b57cec5SDimitry Andric const auto &ST = static_cast<const HexagonSubtarget&>(CurDAG->getSubtarget()); 260b57cec5SDimitry Andric return CurDAG->getTargetConstant(ST.getVectorLength()/2, SDLoc(N), MVT::i32); 270b57cec5SDimitry Andric}]>; 280b57cec5SDimitry Andric 290b57cec5SDimitry Andricdef Q2V: OutPatFrag<(ops node:$Qs), (V6_vandqrt $Qs, (A2_tfrsi -1))>; 300b57cec5SDimitry Andric 310b57cec5SDimitry Andricdef Combinev: OutPatFrag<(ops node:$Vs, node:$Vt), 320b57cec5SDimitry Andric (REG_SEQUENCE HvxWR, $Vs, vsub_hi, $Vt, vsub_lo)>; 330b57cec5SDimitry Andric 340b57cec5SDimitry Andricdef Combineq: OutPatFrag<(ops node:$Qs, node:$Qt), 350b57cec5SDimitry Andric (V6_vandvrt 360b57cec5SDimitry Andric (V6_vor 370b57cec5SDimitry Andric (V6_vror (V6_vpackeb (V6_vd0), (Q2V $Qs)), 380b57cec5SDimitry Andric (A2_tfrsi (HwLen2 (i32 0)))), // Half the vector length 390b57cec5SDimitry Andric (V6_vpackeb (V6_vd0), (Q2V $Qt))), 400b57cec5SDimitry Andric (A2_tfrsi -1))>; 410b57cec5SDimitry Andric 420b57cec5SDimitry Andricdef LoVec: OutPatFrag<(ops node:$Vs), (EXTRACT_SUBREG $Vs, vsub_lo)>; 430b57cec5SDimitry Andricdef HiVec: OutPatFrag<(ops node:$Vs), (EXTRACT_SUBREG $Vs, vsub_hi)>; 440b57cec5SDimitry Andric 450b57cec5SDimitry Andricdef HexagonQCAT: SDNode<"HexagonISD::QCAT", SDTVecBinOp>; 460b57cec5SDimitry Andricdef HexagonQTRUE: SDNode<"HexagonISD::QTRUE", SDTVecLeaf>; 470b57cec5SDimitry Andricdef HexagonQFALSE: SDNode<"HexagonISD::QFALSE", SDTVecLeaf>; 48e8d8bef9SDimitry Andricdef HexagonVPACKL: SDNode<"HexagonISD::VPACKL", SDTVecUnaryOp>; 49e8d8bef9SDimitry Andricdef HexagonVUNPACK: SDNode<"HexagonISD::VUNPACK", SDTVecUnaryOp>; 50e8d8bef9SDimitry Andricdef HexagonVUNPACKU: SDNode<"HexagonISD::VUNPACKU", SDTVecUnaryOp>; 510b57cec5SDimitry Andric 52e8d8bef9SDimitry Andricdef vzero: PatFrag<(ops), (splat_vector (i32 0))>; 530b57cec5SDimitry Andricdef qtrue: PatFrag<(ops), (HexagonQTRUE)>; 540b57cec5SDimitry Andricdef qfalse: PatFrag<(ops), (HexagonQFALSE)>; 550b57cec5SDimitry Andricdef qcat: PatFrag<(ops node:$Qs, node:$Qt), 560b57cec5SDimitry Andric (HexagonQCAT node:$Qs, node:$Qt)>; 570b57cec5SDimitry Andric 580b57cec5SDimitry Andricdef qnot: PatFrag<(ops node:$Qs), (xor node:$Qs, qtrue)>; 59e8d8bef9SDimitry Andricdef vpackl: PatFrag<(ops node:$Vs), (HexagonVPACKL node:$Vs)>; 60e8d8bef9SDimitry Andricdef vunpack: PatFrag<(ops node:$Vs), (HexagonVUNPACK node:$Vs)>; 61e8d8bef9SDimitry Andricdef vunpacku: PatFrag<(ops node:$Vs), (HexagonVUNPACKU node:$Vs)>; 620b57cec5SDimitry Andric 630b57cec5SDimitry Andricdef VSxtb: OutPatFrag<(ops node:$Vs), (V6_vunpackb $Vs)>; 640b57cec5SDimitry Andricdef VSxth: OutPatFrag<(ops node:$Vs), (V6_vunpackh $Vs)>; 650b57cec5SDimitry Andricdef VZxtb: OutPatFrag<(ops node:$Vs), (V6_vunpackub $Vs)>; 660b57cec5SDimitry Andricdef VZxth: OutPatFrag<(ops node:$Vs), (V6_vunpackuh $Vs)>; 670b57cec5SDimitry Andric 680b57cec5SDimitry Andricdef IsVecOff : PatLeaf<(i32 imm), [{ 690b57cec5SDimitry Andric int32_t V = N->getSExtValue(); 700b57cec5SDimitry Andric int32_t VecSize = HRI->getSpillSize(Hexagon::HvxVRRegClass); 710b57cec5SDimitry Andric assert(isPowerOf2_32(VecSize)); 720b57cec5SDimitry Andric if ((uint32_t(V) & (uint32_t(VecSize)-1)) != 0) 730b57cec5SDimitry Andric return false; 740b57cec5SDimitry Andric int32_t L = Log2_32(VecSize); 750b57cec5SDimitry Andric return isInt<4>(V >> L); 760b57cec5SDimitry Andric}]>; 770b57cec5SDimitry Andric 780b57cec5SDimitry Andric 790b57cec5SDimitry Andricdef alignedload: PatFrag<(ops node:$a), (load $a), [{ 800b57cec5SDimitry Andric return isAlignedMemNode(dyn_cast<MemSDNode>(N)); 810b57cec5SDimitry Andric}]>; 820b57cec5SDimitry Andric 830b57cec5SDimitry Andricdef unalignedload: PatFrag<(ops node:$a), (load $a), [{ 840b57cec5SDimitry Andric return !isAlignedMemNode(dyn_cast<MemSDNode>(N)); 850b57cec5SDimitry Andric}]>; 860b57cec5SDimitry Andric 870b57cec5SDimitry Andricdef alignedstore: PatFrag<(ops node:$v, node:$a), (store $v, $a), [{ 880b57cec5SDimitry Andric return isAlignedMemNode(dyn_cast<MemSDNode>(N)); 890b57cec5SDimitry Andric}]>; 900b57cec5SDimitry Andric 910b57cec5SDimitry Andricdef unalignedstore: PatFrag<(ops node:$v, node:$a), (store $v, $a), [{ 920b57cec5SDimitry Andric return !isAlignedMemNode(dyn_cast<MemSDNode>(N)); 930b57cec5SDimitry Andric}]>; 940b57cec5SDimitry Andric 950b57cec5SDimitry Andric 960b57cec5SDimitry Andric// HVX loads 970b57cec5SDimitry Andric 98*fe6060f1SDimitry Andricmulticlass HvxLdfi_pat<InstHexagon MI, PatFrag Load, ValueType ResType, 990b57cec5SDimitry Andric PatFrag ImmPred> { 100*fe6060f1SDimitry Andric def: Pat<(ResType (Load (add (i32 AddrFI:$fi), ImmPred:$Off))), 101*fe6060f1SDimitry Andric (MI AddrFI:$fi, imm:$Off)>; 102*fe6060f1SDimitry Andric def: Pat<(ResType (Load (IsOrAdd (i32 AddrFI:$fi), ImmPred:$Off))), 103*fe6060f1SDimitry Andric (MI AddrFI:$fi, imm:$Off)>; 104*fe6060f1SDimitry Andric def: Pat<(ResType (Load AddrFI:$fi)), (ResType (MI AddrFI:$fi, 0))>; 105*fe6060f1SDimitry Andric} 106*fe6060f1SDimitry Andric 107*fe6060f1SDimitry Andricmulticlass HvxLdgi_pat<InstHexagon MI, PatFrag Load, ValueType ResType, 108*fe6060f1SDimitry Andric PatFrag ImmPred> { 109*fe6060f1SDimitry Andric def: Pat<(ResType (Load (add I32:$Rt, ImmPred:$Off))), 110*fe6060f1SDimitry Andric (MI I32:$Rt, imm:$Off)>; 1110b57cec5SDimitry Andric def: Pat<(ResType (Load I32:$Rt)), 1120b57cec5SDimitry Andric (MI I32:$Rt, 0)>; 113*fe6060f1SDimitry Andric} 114*fe6060f1SDimitry Andric 115*fe6060f1SDimitry Andricmulticlass HvxLdc_pat<InstHexagon MI, PatFrag Load, ValueType ResType> { 1160b57cec5SDimitry Andric // The HVX selection code for shuffles can generate vector constants. 1170b57cec5SDimitry Andric // Calling "Select" on the resulting loads from CP fails without these 1180b57cec5SDimitry Andric // patterns. 119*fe6060f1SDimitry Andric def: Pat<(ResType (Load (HexagonCP tconstpool:$Addr))), 120*fe6060f1SDimitry Andric (MI (A2_tfrsi imm:$Addr), 0)>; 121*fe6060f1SDimitry Andric def: Pat<(ResType (Load (HexagonAtPcrel tconstpool:$Addr))), 122*fe6060f1SDimitry Andric (MI (C4_addipc imm:$Addr), 0)>; 1230b57cec5SDimitry Andric} 1240b57cec5SDimitry Andric 125*fe6060f1SDimitry Andricmulticlass HvxLd_pat<InstHexagon MI, PatFrag Load, ValueType ResType, 126*fe6060f1SDimitry Andric PatFrag ImmPred> { 127*fe6060f1SDimitry Andric defm: HvxLdfi_pat<MI, Load, ResType, ImmPred>; 128*fe6060f1SDimitry Andric defm: HvxLdgi_pat<MI, Load, ResType, ImmPred>; 129*fe6060f1SDimitry Andric defm: HvxLdc_pat <MI, Load, ResType>; 130*fe6060f1SDimitry Andric} 131*fe6060f1SDimitry Andric 132*fe6060f1SDimitry Andric// Aligned loads: everything, plus loads with valignaddr node. 1330b57cec5SDimitry Andricmulticlass HvxLda_pat<InstHexagon MI, PatFrag Load, ValueType ResType, 1340b57cec5SDimitry Andric PatFrag ImmPred> { 1350b57cec5SDimitry Andric let AddedComplexity = 50 in { 1360b57cec5SDimitry Andric def: Pat<(ResType (Load (valignaddr I32:$Rt))), 1370b57cec5SDimitry Andric (MI I32:$Rt, 0)>; 1380b57cec5SDimitry Andric def: Pat<(ResType (Load (add (valignaddr I32:$Rt), ImmPred:$Off))), 1390b57cec5SDimitry Andric (MI I32:$Rt, imm:$Off)>; 1400b57cec5SDimitry Andric } 1410b57cec5SDimitry Andric defm: HvxLd_pat<MI, Load, ResType, ImmPred>; 1420b57cec5SDimitry Andric} 1430b57cec5SDimitry Andric 1440b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 145*fe6060f1SDimitry Andric // alignedload will match a non-temporal load as well, so try non-temporal 146*fe6060f1SDimitry Andric // first. 1470b57cec5SDimitry Andric defm: HvxLda_pat<V6_vL32b_nt_ai, alignednontemporalload, VecI8, IsVecOff>; 1480b57cec5SDimitry Andric defm: HvxLda_pat<V6_vL32b_nt_ai, alignednontemporalload, VecI16, IsVecOff>; 1490b57cec5SDimitry Andric defm: HvxLda_pat<V6_vL32b_nt_ai, alignednontemporalload, VecI32, IsVecOff>; 1500b57cec5SDimitry Andric defm: HvxLda_pat<V6_vL32b_ai, alignedload, VecI8, IsVecOff>; 1510b57cec5SDimitry Andric defm: HvxLda_pat<V6_vL32b_ai, alignedload, VecI16, IsVecOff>; 1520b57cec5SDimitry Andric defm: HvxLda_pat<V6_vL32b_ai, alignedload, VecI32, IsVecOff>; 1530b57cec5SDimitry Andric 1540b57cec5SDimitry Andric defm: HvxLd_pat<V6_vL32Ub_ai, unalignedload, VecI8, IsVecOff>; 1550b57cec5SDimitry Andric defm: HvxLd_pat<V6_vL32Ub_ai, unalignedload, VecI16, IsVecOff>; 1560b57cec5SDimitry Andric defm: HvxLd_pat<V6_vL32Ub_ai, unalignedload, VecI32, IsVecOff>; 1570b57cec5SDimitry Andric} 1580b57cec5SDimitry Andric 159*fe6060f1SDimitry Andric 1600b57cec5SDimitry Andric// HVX stores 1610b57cec5SDimitry Andric 162*fe6060f1SDimitry Andricmulticlass HvxStfi_pat<InstHexagon MI, PatFrag Store, PatFrag Value, 163*fe6060f1SDimitry Andric PatFrag ImmPred> { 164*fe6060f1SDimitry Andric def: Pat<(Store Value:$Vs, (add (i32 AddrFI:$fi), ImmPred:$Off)), 165*fe6060f1SDimitry Andric (MI AddrFI:$fi, imm:$Off, Value:$Vs)>; 166*fe6060f1SDimitry Andric def: Pat<(Store Value:$Vs, (IsOrAdd (i32 AddrFI:$fi), ImmPred:$Off)), 167*fe6060f1SDimitry Andric (MI AddrFI:$fi, imm:$Off, Value:$Vs)>; 168*fe6060f1SDimitry Andric def: Pat<(Store Value:$Vs, AddrFI:$fi), 169*fe6060f1SDimitry Andric (MI AddrFI:$fi, 0, Value:$Vs)>; 170*fe6060f1SDimitry Andric} 171*fe6060f1SDimitry Andric 172*fe6060f1SDimitry Andricmulticlass HvxStgi_pat<InstHexagon MI, PatFrag Store, PatFrag Value, 173*fe6060f1SDimitry Andric PatFrag ImmPred> { 174*fe6060f1SDimitry Andric def: Pat<(Store Value:$Vs, (add I32:$Rt, ImmPred:$Off)), 175*fe6060f1SDimitry Andric (MI I32:$Rt, imm:$Off, Value:$Vs)>; 176*fe6060f1SDimitry Andric def: Pat<(Store Value:$Vs, (IsOrAdd I32:$Rt, ImmPred:$Off)), 177*fe6060f1SDimitry Andric (MI I32:$Rt, imm:$Off, Value:$Vs)>; 1780b57cec5SDimitry Andric def: Pat<(Store Value:$Vs, I32:$Rt), 1790b57cec5SDimitry Andric (MI I32:$Rt, 0, Value:$Vs)>; 180*fe6060f1SDimitry Andric} 181*fe6060f1SDimitry Andric 182*fe6060f1SDimitry Andricmulticlass HvxSt_pat<InstHexagon MI, PatFrag Store, PatFrag Value, 183*fe6060f1SDimitry Andric PatFrag ImmPred> { 184*fe6060f1SDimitry Andric defm: HvxStfi_pat<MI, Store, Value, ImmPred>; 185*fe6060f1SDimitry Andric defm: HvxStgi_pat<MI, Store, Value, ImmPred>; 1860b57cec5SDimitry Andric} 1870b57cec5SDimitry Andric 1880b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 189*fe6060f1SDimitry Andric // alignedstore will match a non-temporal store as well, so try non-temporal 190*fe6060f1SDimitry Andric // first. 191*fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32b_nt_ai, alignednontemporalstore, HVI8, IsVecOff>; 192*fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32b_nt_ai, alignednontemporalstore, HVI16, IsVecOff>; 193*fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32b_nt_ai, alignednontemporalstore, HVI32, IsVecOff>; 194*fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32b_ai, alignedstore, HVI8, IsVecOff>; 195*fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32b_ai, alignedstore, HVI16, IsVecOff>; 196*fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32b_ai, alignedstore, HVI32, IsVecOff>; 197*fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32Ub_ai, unalignedstore, HVI8, IsVecOff>; 198*fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32Ub_ai, unalignedstore, HVI16, IsVecOff>; 199*fe6060f1SDimitry Andric defm: HvxSt_pat<V6_vS32Ub_ai, unalignedstore, HVI32, IsVecOff>; 2000b57cec5SDimitry Andric} 2010b57cec5SDimitry Andric 2020b57cec5SDimitry Andric// Bitcasts between same-size vector types are no-ops, except for the 2030b57cec5SDimitry Andric// actual type change. 2040b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 2058bcb0991SDimitry Andric defm: NopCast_pat<VecI8, VecI16, HvxVR>; 2068bcb0991SDimitry Andric defm: NopCast_pat<VecI8, VecI32, HvxVR>; 2078bcb0991SDimitry Andric defm: NopCast_pat<VecI16, VecI32, HvxVR>; 2080b57cec5SDimitry Andric 2098bcb0991SDimitry Andric defm: NopCast_pat<VecPI8, VecPI16, HvxWR>; 2108bcb0991SDimitry Andric defm: NopCast_pat<VecPI8, VecPI32, HvxWR>; 2118bcb0991SDimitry Andric defm: NopCast_pat<VecPI16, VecPI32, HvxWR>; 2120b57cec5SDimitry Andric} 2130b57cec5SDimitry Andric 2140b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 215e8d8bef9SDimitry Andric let AddedComplexity = 100 in { 216e8d8bef9SDimitry Andric // These should be preferred over a vsplat of 0. 2170b57cec5SDimitry Andric def: Pat<(VecI8 vzero), (V6_vd0)>; 2180b57cec5SDimitry Andric def: Pat<(VecI16 vzero), (V6_vd0)>; 2190b57cec5SDimitry Andric def: Pat<(VecI32 vzero), (V6_vd0)>; 2200b57cec5SDimitry Andric def: Pat<(VecPI8 vzero), (PS_vdd0)>; 2210b57cec5SDimitry Andric def: Pat<(VecPI16 vzero), (PS_vdd0)>; 2220b57cec5SDimitry Andric def: Pat<(VecPI32 vzero), (PS_vdd0)>; 2230b57cec5SDimitry Andric 2240b57cec5SDimitry Andric def: Pat<(concat_vectors (VecI8 vzero), (VecI8 vzero)), (PS_vdd0)>; 2250b57cec5SDimitry Andric def: Pat<(concat_vectors (VecI16 vzero), (VecI16 vzero)), (PS_vdd0)>; 2260b57cec5SDimitry Andric def: Pat<(concat_vectors (VecI32 vzero), (VecI32 vzero)), (PS_vdd0)>; 227e8d8bef9SDimitry Andric } 2280b57cec5SDimitry Andric 2290b57cec5SDimitry Andric def: Pat<(VecPI8 (concat_vectors HVI8:$Vs, HVI8:$Vt)), 2300b57cec5SDimitry Andric (Combinev HvxVR:$Vt, HvxVR:$Vs)>; 2310b57cec5SDimitry Andric def: Pat<(VecPI16 (concat_vectors HVI16:$Vs, HVI16:$Vt)), 2320b57cec5SDimitry Andric (Combinev HvxVR:$Vt, HvxVR:$Vs)>; 2330b57cec5SDimitry Andric def: Pat<(VecPI32 (concat_vectors HVI32:$Vs, HVI32:$Vt)), 2340b57cec5SDimitry Andric (Combinev HvxVR:$Vt, HvxVR:$Vs)>; 2350b57cec5SDimitry Andric 2360b57cec5SDimitry Andric def: Pat<(VecQ8 (qcat HQ16:$Qs, HQ16:$Qt)), (Combineq $Qt, $Qs)>; 2370b57cec5SDimitry Andric def: Pat<(VecQ16 (qcat HQ32:$Qs, HQ32:$Qt)), (Combineq $Qt, $Qs)>; 2380b57cec5SDimitry Andric 2390b57cec5SDimitry Andric def: Pat<(HexagonVEXTRACTW HVI8:$Vu, I32:$Rs), 2400b57cec5SDimitry Andric (V6_extractw HvxVR:$Vu, I32:$Rs)>; 2410b57cec5SDimitry Andric def: Pat<(HexagonVEXTRACTW HVI16:$Vu, I32:$Rs), 2420b57cec5SDimitry Andric (V6_extractw HvxVR:$Vu, I32:$Rs)>; 2430b57cec5SDimitry Andric def: Pat<(HexagonVEXTRACTW HVI32:$Vu, I32:$Rs), 2440b57cec5SDimitry Andric (V6_extractw HvxVR:$Vu, I32:$Rs)>; 2450b57cec5SDimitry Andric 2460b57cec5SDimitry Andric def: Pat<(HexagonVINSERTW0 HVI8:$Vu, I32:$Rt), 2470b57cec5SDimitry Andric (V6_vinsertwr HvxVR:$Vu, I32:$Rt)>; 2480b57cec5SDimitry Andric def: Pat<(HexagonVINSERTW0 HVI16:$Vu, I32:$Rt), 2490b57cec5SDimitry Andric (V6_vinsertwr HvxVR:$Vu, I32:$Rt)>; 2500b57cec5SDimitry Andric def: Pat<(HexagonVINSERTW0 HVI32:$Vu, I32:$Rt), 2510b57cec5SDimitry Andric (V6_vinsertwr HvxVR:$Vu, I32:$Rt)>; 2520b57cec5SDimitry Andric} 2530b57cec5SDimitry Andric 254e8d8bef9SDimitry Andric// Splats for HvxV60 255e8d8bef9SDimitry Andricdef V60splatib: OutPatFrag<(ops node:$V), (V6_lvsplatw (ToI32 (SplatB $V)))>; 256e8d8bef9SDimitry Andricdef V60splatih: OutPatFrag<(ops node:$V), (V6_lvsplatw (ToI32 (SplatH $V)))>; 257e8d8bef9SDimitry Andricdef V60splatiw: OutPatFrag<(ops node:$V), (V6_lvsplatw (ToI32 $V))>; 258e8d8bef9SDimitry Andricdef V60splatrb: OutPatFrag<(ops node:$Rs), (V6_lvsplatw (S2_vsplatrb $Rs))>; 259e8d8bef9SDimitry Andricdef V60splatrh: OutPatFrag<(ops node:$Rs), 2600b57cec5SDimitry Andric (V6_lvsplatw (A2_combine_ll $Rs, $Rs))>; 261e8d8bef9SDimitry Andricdef V60splatrw: OutPatFrag<(ops node:$Rs), (V6_lvsplatw $Rs)>; 262e8d8bef9SDimitry Andric 263e8d8bef9SDimitry Andric// Splats for HvxV62+ 264e8d8bef9SDimitry Andricdef V62splatib: OutPatFrag<(ops node:$V), (V6_lvsplatb (ToI32 $V))>; 265e8d8bef9SDimitry Andricdef V62splatih: OutPatFrag<(ops node:$V), (V6_lvsplath (ToI32 $V))>; 266e8d8bef9SDimitry Andricdef V62splatiw: OutPatFrag<(ops node:$V), (V6_lvsplatw (ToI32 $V))>; 267e8d8bef9SDimitry Andricdef V62splatrb: OutPatFrag<(ops node:$Rs), (V6_lvsplatb $Rs)>; 268e8d8bef9SDimitry Andricdef V62splatrh: OutPatFrag<(ops node:$Rs), (V6_lvsplath $Rs)>; 269e8d8bef9SDimitry Andricdef V62splatrw: OutPatFrag<(ops node:$Rs), (V6_lvsplatw $Rs)>; 2700b57cec5SDimitry Andric 2710b57cec5SDimitry Andricdef Rep: OutPatFrag<(ops node:$N), (Combinev $N, $N)>; 2720b57cec5SDimitry Andric 273e8d8bef9SDimitry Andriclet Predicates = [UseHVX,UseHVXV60] in { 2740b57cec5SDimitry Andric let AddedComplexity = 10 in { 275e8d8bef9SDimitry Andric def: Pat<(VecI8 (splat_vector u8_0ImmPred:$V)), (V60splatib $V)>; 276e8d8bef9SDimitry Andric def: Pat<(VecI16 (splat_vector u16_0ImmPred:$V)), (V60splatih $V)>; 277e8d8bef9SDimitry Andric def: Pat<(VecI32 (splat_vector anyimm:$V)), (V60splatiw $V)>; 278e8d8bef9SDimitry Andric def: Pat<(VecPI8 (splat_vector u8_0ImmPred:$V)), (Rep (V60splatib $V))>; 279e8d8bef9SDimitry Andric def: Pat<(VecPI16 (splat_vector u16_0ImmPred:$V)), (Rep (V60splatih $V))>; 280e8d8bef9SDimitry Andric def: Pat<(VecPI32 (splat_vector anyimm:$V)), (Rep (V60splatiw $V))>; 2810b57cec5SDimitry Andric } 282e8d8bef9SDimitry Andric def: Pat<(VecI8 (splat_vector I32:$Rs)), (V60splatrb $Rs)>; 283e8d8bef9SDimitry Andric def: Pat<(VecI16 (splat_vector I32:$Rs)), (V60splatrh $Rs)>; 284e8d8bef9SDimitry Andric def: Pat<(VecI32 (splat_vector I32:$Rs)), (V60splatrw $Rs)>; 285e8d8bef9SDimitry Andric def: Pat<(VecPI8 (splat_vector I32:$Rs)), (Rep (V60splatrb $Rs))>; 286e8d8bef9SDimitry Andric def: Pat<(VecPI16 (splat_vector I32:$Rs)), (Rep (V60splatrh $Rs))>; 287e8d8bef9SDimitry Andric def: Pat<(VecPI32 (splat_vector I32:$Rs)), (Rep (V60splatrw $Rs))>; 288e8d8bef9SDimitry Andric} 289e8d8bef9SDimitry Andriclet Predicates = [UseHVX,UseHVXV62] in { 290e8d8bef9SDimitry Andric let AddedComplexity = 30 in { 291e8d8bef9SDimitry Andric def: Pat<(VecI8 (splat_vector u8_0ImmPred:$V)), (V62splatib imm:$V)>; 292e8d8bef9SDimitry Andric def: Pat<(VecI16 (splat_vector u16_0ImmPred:$V)), (V62splatih imm:$V)>; 293e8d8bef9SDimitry Andric def: Pat<(VecI32 (splat_vector anyimm:$V)), (V62splatiw imm:$V)>; 294e8d8bef9SDimitry Andric def: Pat<(VecPI8 (splat_vector u8_0ImmPred:$V)), 295e8d8bef9SDimitry Andric (Rep (V62splatib imm:$V))>; 296e8d8bef9SDimitry Andric def: Pat<(VecPI16 (splat_vector u16_0ImmPred:$V)), 297e8d8bef9SDimitry Andric (Rep (V62splatih imm:$V))>; 298e8d8bef9SDimitry Andric def: Pat<(VecPI32 (splat_vector anyimm:$V)), 299e8d8bef9SDimitry Andric (Rep (V62splatiw imm:$V))>; 300e8d8bef9SDimitry Andric } 301e8d8bef9SDimitry Andric let AddedComplexity = 20 in { 302e8d8bef9SDimitry Andric def: Pat<(VecI8 (splat_vector I32:$Rs)), (V62splatrb $Rs)>; 303e8d8bef9SDimitry Andric def: Pat<(VecI16 (splat_vector I32:$Rs)), (V62splatrh $Rs)>; 304e8d8bef9SDimitry Andric def: Pat<(VecI32 (splat_vector I32:$Rs)), (V62splatrw $Rs)>; 305e8d8bef9SDimitry Andric def: Pat<(VecPI8 (splat_vector I32:$Rs)), (Rep (V62splatrb $Rs))>; 306e8d8bef9SDimitry Andric def: Pat<(VecPI16 (splat_vector I32:$Rs)), (Rep (V62splatrh $Rs))>; 307e8d8bef9SDimitry Andric def: Pat<(VecPI32 (splat_vector I32:$Rs)), (Rep (V62splatrw $Rs))>; 308e8d8bef9SDimitry Andric } 3090b57cec5SDimitry Andric} 3100b57cec5SDimitry Andric 3110b57cec5SDimitry Andricclass Vneg1<ValueType VecTy> 312e8d8bef9SDimitry Andric : PatFrag<(ops), (VecTy (splat_vector (i32 -1)))>; 3130b57cec5SDimitry Andric 3140b57cec5SDimitry Andricclass Vnot<ValueType VecTy> 3150b57cec5SDimitry Andric : PatFrag<(ops node:$Vs), (xor $Vs, Vneg1<VecTy>)>; 3160b57cec5SDimitry Andric 3170b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 3180b57cec5SDimitry Andric let AddedComplexity = 200 in { 3190b57cec5SDimitry Andric def: Pat<(Vnot<VecI8> HVI8:$Vs), (V6_vnot HvxVR:$Vs)>; 3200b57cec5SDimitry Andric def: Pat<(Vnot<VecI16> HVI16:$Vs), (V6_vnot HvxVR:$Vs)>; 3210b57cec5SDimitry Andric def: Pat<(Vnot<VecI32> HVI32:$Vs), (V6_vnot HvxVR:$Vs)>; 3220b57cec5SDimitry Andric } 3230b57cec5SDimitry Andric 3240b57cec5SDimitry Andric def: OpR_RR_pat<V6_vaddb, Add, VecI8, HVI8>; 3250b57cec5SDimitry Andric def: OpR_RR_pat<V6_vaddh, Add, VecI16, HVI16>; 3260b57cec5SDimitry Andric def: OpR_RR_pat<V6_vaddw, Add, VecI32, HVI32>; 3270b57cec5SDimitry Andric def: OpR_RR_pat<V6_vaddb_dv, Add, VecPI8, HWI8>; 3280b57cec5SDimitry Andric def: OpR_RR_pat<V6_vaddh_dv, Add, VecPI16, HWI16>; 3290b57cec5SDimitry Andric def: OpR_RR_pat<V6_vaddw_dv, Add, VecPI32, HWI32>; 3300b57cec5SDimitry Andric def: OpR_RR_pat<V6_vsubb, Sub, VecI8, HVI8>; 3310b57cec5SDimitry Andric def: OpR_RR_pat<V6_vsubh, Sub, VecI16, HVI16>; 3320b57cec5SDimitry Andric def: OpR_RR_pat<V6_vsubw, Sub, VecI32, HVI32>; 3330b57cec5SDimitry Andric def: OpR_RR_pat<V6_vsubb_dv, Sub, VecPI8, HWI8>; 3340b57cec5SDimitry Andric def: OpR_RR_pat<V6_vsubh_dv, Sub, VecPI16, HWI16>; 3350b57cec5SDimitry Andric def: OpR_RR_pat<V6_vsubw_dv, Sub, VecPI32, HWI32>; 3360b57cec5SDimitry Andric def: OpR_RR_pat<V6_vand, And, VecI8, HVI8>; 3370b57cec5SDimitry Andric def: OpR_RR_pat<V6_vand, And, VecI16, HVI16>; 3380b57cec5SDimitry Andric def: OpR_RR_pat<V6_vand, And, VecI32, HVI32>; 3390b57cec5SDimitry Andric def: OpR_RR_pat<V6_vor, Or, VecI8, HVI8>; 3400b57cec5SDimitry Andric def: OpR_RR_pat<V6_vor, Or, VecI16, HVI16>; 3410b57cec5SDimitry Andric def: OpR_RR_pat<V6_vor, Or, VecI32, HVI32>; 3420b57cec5SDimitry Andric def: OpR_RR_pat<V6_vxor, Xor, VecI8, HVI8>; 3430b57cec5SDimitry Andric def: OpR_RR_pat<V6_vxor, Xor, VecI16, HVI16>; 3440b57cec5SDimitry Andric def: OpR_RR_pat<V6_vxor, Xor, VecI32, HVI32>; 3450b57cec5SDimitry Andric 346e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vminb, Smin, VecI8, HVI8>; 347e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vmaxb, Smax, VecI8, HVI8>; 348e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vminub, Umin, VecI8, HVI8>; 349e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vmaxub, Umax, VecI8, HVI8>; 350e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vminh, Smin, VecI16, HVI16>; 351e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vmaxh, Smax, VecI16, HVI16>; 352e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vminuh, Umin, VecI16, HVI16>; 353e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vmaxuh, Umax, VecI16, HVI16>; 354e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vminw, Smin, VecI32, HVI32>; 355e8d8bef9SDimitry Andric def: OpR_RR_pat<V6_vmaxw, Smax, VecI32, HVI32>; 356e8d8bef9SDimitry Andric 3570b57cec5SDimitry Andric def: Pat<(vselect HQ8:$Qu, HVI8:$Vs, HVI8:$Vt), 3580b57cec5SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vs, HvxVR:$Vt)>; 3590b57cec5SDimitry Andric def: Pat<(vselect HQ16:$Qu, HVI16:$Vs, HVI16:$Vt), 3600b57cec5SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vs, HvxVR:$Vt)>; 3610b57cec5SDimitry Andric def: Pat<(vselect HQ32:$Qu, HVI32:$Vs, HVI32:$Vt), 3620b57cec5SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vs, HvxVR:$Vt)>; 3630b57cec5SDimitry Andric 3640b57cec5SDimitry Andric def: Pat<(vselect (qnot HQ8:$Qu), HVI8:$Vs, HVI8:$Vt), 3650b57cec5SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vt, HvxVR:$Vs)>; 3660b57cec5SDimitry Andric def: Pat<(vselect (qnot HQ16:$Qu), HVI16:$Vs, HVI16:$Vt), 3670b57cec5SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vt, HvxVR:$Vs)>; 3680b57cec5SDimitry Andric def: Pat<(vselect (qnot HQ32:$Qu), HVI32:$Vs, HVI32:$Vt), 3690b57cec5SDimitry Andric (V6_vmux HvxQR:$Qu, HvxVR:$Vt, HvxVR:$Vs)>; 3700b57cec5SDimitry Andric} 3710b57cec5SDimitry Andric 3720b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 373e8d8bef9SDimitry Andric // For i8 vectors Vs = (a0, a1, ...), Vt = (b0, b1, ...), 374e8d8bef9SDimitry Andric // V6_vmpybv Vs, Vt produces a pair of i16 vectors Hi:Lo, 375e8d8bef9SDimitry Andric // where Lo = (a0*b0, a2*b2, ...), Hi = (a1*b1, a3*b3, ...). 376e8d8bef9SDimitry Andric def: Pat<(mul HVI8:$Vs, HVI8:$Vt), 377e8d8bef9SDimitry Andric (V6_vshuffeb (HiVec (V6_vmpybv HvxVR:$Vs, HvxVR:$Vt)), 378e8d8bef9SDimitry Andric (LoVec (V6_vmpybv HvxVR:$Vs, HvxVR:$Vt)))>; 379e8d8bef9SDimitry Andric def: Pat<(mul HVI16:$Vs, HVI16:$Vt), 380e8d8bef9SDimitry Andric (V6_vmpyih HvxVR:$Vs, HvxVR:$Vt)>; 381e8d8bef9SDimitry Andric def: Pat<(mul HVI32:$Vs, HVI32:$Vt), 382e8d8bef9SDimitry Andric (V6_vmpyiewuh_acc (V6_vmpyieoh HvxVR:$Vs, HvxVR:$Vt), 383e8d8bef9SDimitry Andric HvxVR:$Vs, HvxVR:$Vt)>; 384e8d8bef9SDimitry Andric} 385e8d8bef9SDimitry Andric 386e8d8bef9SDimitry Andriclet Predicates = [UseHVX] in { 3870b57cec5SDimitry Andric def: Pat<(VecPI16 (sext HVI8:$Vs)), (VSxtb $Vs)>; 3880b57cec5SDimitry Andric def: Pat<(VecPI32 (sext HVI16:$Vs)), (VSxth $Vs)>; 3890b57cec5SDimitry Andric def: Pat<(VecPI16 (zext HVI8:$Vs)), (VZxtb $Vs)>; 3900b57cec5SDimitry Andric def: Pat<(VecPI32 (zext HVI16:$Vs)), (VZxth $Vs)>; 3910b57cec5SDimitry Andric 3920b57cec5SDimitry Andric def: Pat<(VecI16 (sext_invec HVI8:$Vs)), (LoVec (VSxtb $Vs))>; 3930b57cec5SDimitry Andric def: Pat<(VecI32 (sext_invec HVI16:$Vs)), (LoVec (VSxth $Vs))>; 3940b57cec5SDimitry Andric def: Pat<(VecI32 (sext_invec HVI8:$Vs)), 3950b57cec5SDimitry Andric (LoVec (VSxth (LoVec (VSxtb $Vs))))>; 3960b57cec5SDimitry Andric def: Pat<(VecPI16 (sext_invec HWI8:$Vss)), (VSxtb (LoVec $Vss))>; 3970b57cec5SDimitry Andric def: Pat<(VecPI32 (sext_invec HWI16:$Vss)), (VSxth (LoVec $Vss))>; 3980b57cec5SDimitry Andric def: Pat<(VecPI32 (sext_invec HWI8:$Vss)), 3990b57cec5SDimitry Andric (VSxth (LoVec (VSxtb (LoVec $Vss))))>; 4000b57cec5SDimitry Andric 4010b57cec5SDimitry Andric def: Pat<(VecI16 (zext_invec HVI8:$Vs)), (LoVec (VZxtb $Vs))>; 4020b57cec5SDimitry Andric def: Pat<(VecI32 (zext_invec HVI16:$Vs)), (LoVec (VZxth $Vs))>; 4030b57cec5SDimitry Andric def: Pat<(VecI32 (zext_invec HVI8:$Vs)), 4040b57cec5SDimitry Andric (LoVec (VZxth (LoVec (VZxtb $Vs))))>; 4050b57cec5SDimitry Andric def: Pat<(VecPI16 (zext_invec HWI8:$Vss)), (VZxtb (LoVec $Vss))>; 4060b57cec5SDimitry Andric def: Pat<(VecPI32 (zext_invec HWI16:$Vss)), (VZxth (LoVec $Vss))>; 4070b57cec5SDimitry Andric def: Pat<(VecPI32 (zext_invec HWI8:$Vss)), 4080b57cec5SDimitry Andric (VZxth (LoVec (VZxtb (LoVec $Vss))))>; 4090b57cec5SDimitry Andric 4100b57cec5SDimitry Andric def: Pat<(VecI8 (trunc HWI16:$Vss)), 4110b57cec5SDimitry Andric (V6_vpackeb (HiVec $Vss), (LoVec $Vss))>; 4120b57cec5SDimitry Andric def: Pat<(VecI16 (trunc HWI32:$Vss)), 4130b57cec5SDimitry Andric (V6_vpackeh (HiVec $Vss), (LoVec $Vss))>; 4140b57cec5SDimitry Andric 4150b57cec5SDimitry Andric def: Pat<(VecQ8 (trunc HVI8:$Vs)), 4160b57cec5SDimitry Andric (V6_vandvrt HvxVR:$Vs, (A2_tfrsi 0x01010101))>; 4170b57cec5SDimitry Andric def: Pat<(VecQ16 (trunc HVI16:$Vs)), 4180b57cec5SDimitry Andric (V6_vandvrt HvxVR:$Vs, (A2_tfrsi 0x01010101))>; 4190b57cec5SDimitry Andric def: Pat<(VecQ32 (trunc HVI32:$Vs)), 4200b57cec5SDimitry Andric (V6_vandvrt HvxVR:$Vs, (A2_tfrsi 0x01010101))>; 4210b57cec5SDimitry Andric} 4220b57cec5SDimitry Andric 4230b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 4240b57cec5SDimitry Andric // The "source" types are not legal, and there are no parameterized 4250b57cec5SDimitry Andric // definitions for them, but they are length-specific. 4260b57cec5SDimitry Andric let Predicates = [UseHVX,UseHVX64B] in { 4270b57cec5SDimitry Andric def: Pat<(VecI16 (sext_inreg HVI16:$Vs, v32i8)), 4280b57cec5SDimitry Andric (V6_vasrh (V6_vaslh HVI16:$Vs, (A2_tfrsi 8)), (A2_tfrsi 8))>; 4290b57cec5SDimitry Andric def: Pat<(VecI32 (sext_inreg HVI32:$Vs, v16i8)), 4300b57cec5SDimitry Andric (V6_vasrw (V6_vaslw HVI32:$Vs, (A2_tfrsi 24)), (A2_tfrsi 24))>; 4310b57cec5SDimitry Andric def: Pat<(VecI32 (sext_inreg HVI32:$Vs, v16i16)), 4320b57cec5SDimitry Andric (V6_vasrw (V6_vaslw HVI32:$Vs, (A2_tfrsi 16)), (A2_tfrsi 16))>; 4330b57cec5SDimitry Andric } 4340b57cec5SDimitry Andric let Predicates = [UseHVX,UseHVX128B] in { 4350b57cec5SDimitry Andric def: Pat<(VecI16 (sext_inreg HVI16:$Vs, v64i8)), 4360b57cec5SDimitry Andric (V6_vasrh (V6_vaslh HVI16:$Vs, (A2_tfrsi 8)), (A2_tfrsi 8))>; 4370b57cec5SDimitry Andric def: Pat<(VecI32 (sext_inreg HVI32:$Vs, v32i8)), 4380b57cec5SDimitry Andric (V6_vasrw (V6_vaslw HVI32:$Vs, (A2_tfrsi 24)), (A2_tfrsi 24))>; 4390b57cec5SDimitry Andric def: Pat<(VecI32 (sext_inreg HVI32:$Vs, v32i16)), 4400b57cec5SDimitry Andric (V6_vasrw (V6_vaslw HVI32:$Vs, (A2_tfrsi 16)), (A2_tfrsi 16))>; 4410b57cec5SDimitry Andric } 4420b57cec5SDimitry Andric 443e8d8bef9SDimitry Andric // Take a pair of vectors Vt:Vs and shift them towards LSB by (Rt & HwLen). 444e8d8bef9SDimitry Andric def: Pat<(VecI8 (valign HVI8:$Vt, HVI8:$Vs, I32:$Rt)), 445e8d8bef9SDimitry Andric (LoVec (V6_valignb HvxVR:$Vt, HvxVR:$Vs, I32:$Rt))>; 446e8d8bef9SDimitry Andric def: Pat<(VecI16 (valign HVI16:$Vt, HVI16:$Vs, I32:$Rt)), 447e8d8bef9SDimitry Andric (LoVec (V6_valignb HvxVR:$Vt, HvxVR:$Vs, I32:$Rt))>; 448e8d8bef9SDimitry Andric def: Pat<(VecI32 (valign HVI32:$Vt, HVI32:$Vs, I32:$Rt)), 449e8d8bef9SDimitry Andric (LoVec (V6_valignb HvxVR:$Vt, HvxVR:$Vs, I32:$Rt))>; 450e8d8bef9SDimitry Andric 4510b57cec5SDimitry Andric def: Pat<(HexagonVASL HVI8:$Vs, I32:$Rt), 4520b57cec5SDimitry Andric (V6_vpackeb (V6_vaslh (HiVec (VZxtb HvxVR:$Vs)), I32:$Rt), 4530b57cec5SDimitry Andric (V6_vaslh (LoVec (VZxtb HvxVR:$Vs)), I32:$Rt))>; 4540b57cec5SDimitry Andric def: Pat<(HexagonVASR HVI8:$Vs, I32:$Rt), 4550b57cec5SDimitry Andric (V6_vpackeb (V6_vasrh (HiVec (VSxtb HvxVR:$Vs)), I32:$Rt), 4560b57cec5SDimitry Andric (V6_vasrh (LoVec (VSxtb HvxVR:$Vs)), I32:$Rt))>; 4570b57cec5SDimitry Andric def: Pat<(HexagonVLSR HVI8:$Vs, I32:$Rt), 4580b57cec5SDimitry Andric (V6_vpackeb (V6_vlsrh (HiVec (VZxtb HvxVR:$Vs)), I32:$Rt), 4590b57cec5SDimitry Andric (V6_vlsrh (LoVec (VZxtb HvxVR:$Vs)), I32:$Rt))>; 4600b57cec5SDimitry Andric 4610b57cec5SDimitry Andric def: Pat<(HexagonVASL HVI16:$Vs, I32:$Rt), (V6_vaslh HvxVR:$Vs, I32:$Rt)>; 4620b57cec5SDimitry Andric def: Pat<(HexagonVASL HVI32:$Vs, I32:$Rt), (V6_vaslw HvxVR:$Vs, I32:$Rt)>; 4630b57cec5SDimitry Andric def: Pat<(HexagonVASR HVI16:$Vs, I32:$Rt), (V6_vasrh HvxVR:$Vs, I32:$Rt)>; 4640b57cec5SDimitry Andric def: Pat<(HexagonVASR HVI32:$Vs, I32:$Rt), (V6_vasrw HvxVR:$Vs, I32:$Rt)>; 4650b57cec5SDimitry Andric def: Pat<(HexagonVLSR HVI16:$Vs, I32:$Rt), (V6_vlsrh HvxVR:$Vs, I32:$Rt)>; 4660b57cec5SDimitry Andric def: Pat<(HexagonVLSR HVI32:$Vs, I32:$Rt), (V6_vlsrw HvxVR:$Vs, I32:$Rt)>; 4670b57cec5SDimitry Andric 4680b57cec5SDimitry Andric def: Pat<(add HVI32:$Vx, (HexagonVASL HVI32:$Vu, I32:$Rt)), 4690b57cec5SDimitry Andric (V6_vaslw_acc HvxVR:$Vx, HvxVR:$Vu, I32:$Rt)>; 4700b57cec5SDimitry Andric def: Pat<(add HVI32:$Vx, (HexagonVASR HVI32:$Vu, I32:$Rt)), 4710b57cec5SDimitry Andric (V6_vasrw_acc HvxVR:$Vx, HvxVR:$Vu, I32:$Rt)>; 4720b57cec5SDimitry Andric 4730b57cec5SDimitry Andric def: Pat<(shl HVI16:$Vs, HVI16:$Vt), (V6_vaslhv HvxVR:$Vs, HvxVR:$Vt)>; 4740b57cec5SDimitry Andric def: Pat<(shl HVI32:$Vs, HVI32:$Vt), (V6_vaslwv HvxVR:$Vs, HvxVR:$Vt)>; 4750b57cec5SDimitry Andric def: Pat<(sra HVI16:$Vs, HVI16:$Vt), (V6_vasrhv HvxVR:$Vs, HvxVR:$Vt)>; 4760b57cec5SDimitry Andric def: Pat<(sra HVI32:$Vs, HVI32:$Vt), (V6_vasrwv HvxVR:$Vs, HvxVR:$Vt)>; 4770b57cec5SDimitry Andric def: Pat<(srl HVI16:$Vs, HVI16:$Vt), (V6_vlsrhv HvxVR:$Vs, HvxVR:$Vt)>; 4780b57cec5SDimitry Andric def: Pat<(srl HVI32:$Vs, HVI32:$Vt), (V6_vlsrwv HvxVR:$Vs, HvxVR:$Vt)>; 4790b57cec5SDimitry Andric 480e8d8bef9SDimitry Andric // Vpackl is a pseudo-op that is used when legalizing widened truncates. 481e8d8bef9SDimitry Andric // It should never be produced with a register pair in the output, but 482e8d8bef9SDimitry Andric // it can happen to have a pair as an input. 483e8d8bef9SDimitry Andric def: Pat<(VecI8 (vpackl HVI16:$Vs)), (V6_vdealb HvxVR:$Vs)>; 484e8d8bef9SDimitry Andric def: Pat<(VecI8 (vpackl HVI32:$Vs)), (V6_vdealb4w (IMPLICIT_DEF), HvxVR:$Vs)>; 485e8d8bef9SDimitry Andric def: Pat<(VecI16 (vpackl HVI32:$Vs)), (V6_vdealh HvxVR:$Vs)>; 486e8d8bef9SDimitry Andric def: Pat<(VecI8 (vpackl HWI16:$Vs)), (V6_vpackeb (HiVec $Vs), (LoVec $Vs))>; 487e8d8bef9SDimitry Andric def: Pat<(VecI8 (vpackl HWI32:$Vs)), 488e8d8bef9SDimitry Andric (V6_vpackeb (IMPLICIT_DEF), (V6_vpackeh (HiVec $Vs), (LoVec $Vs)))>; 489e8d8bef9SDimitry Andric def: Pat<(VecI16 (vpackl HWI32:$Vs)), (V6_vpackeh (HiVec $Vs), (LoVec $Vs))>; 490e8d8bef9SDimitry Andric 491e8d8bef9SDimitry Andric def: Pat<(VecI16 (vunpack HVI8:$Vs)), (LoVec (VSxtb $Vs))>; 492e8d8bef9SDimitry Andric def: Pat<(VecI32 (vunpack HVI8:$Vs)), (LoVec (VSxth (LoVec (VSxtb $Vs))))>; 493e8d8bef9SDimitry Andric def: Pat<(VecI32 (vunpack HVI16:$Vs)), (LoVec (VSxth $Vs))>; 494e8d8bef9SDimitry Andric def: Pat<(VecPI16 (vunpack HVI8:$Vs)), (VSxtb $Vs)>; 495e8d8bef9SDimitry Andric def: Pat<(VecPI32 (vunpack HVI8:$Vs)), (VSxth (LoVec (VSxtb $Vs)))>; 496e8d8bef9SDimitry Andric def: Pat<(VecPI32 (vunpack HVI32:$Vs)), (VSxth $Vs)>; 497e8d8bef9SDimitry Andric 498e8d8bef9SDimitry Andric def: Pat<(VecI16 (vunpacku HVI8:$Vs)), (LoVec (VZxtb $Vs))>; 499e8d8bef9SDimitry Andric def: Pat<(VecI32 (vunpacku HVI8:$Vs)), (LoVec (VZxth (LoVec (VZxtb $Vs))))>; 500e8d8bef9SDimitry Andric def: Pat<(VecI32 (vunpacku HVI16:$Vs)), (LoVec (VZxth $Vs))>; 501e8d8bef9SDimitry Andric def: Pat<(VecPI16 (vunpacku HVI8:$Vs)), (VZxtb $Vs)>; 502e8d8bef9SDimitry Andric def: Pat<(VecPI32 (vunpacku HVI8:$Vs)), (VZxth (LoVec (VZxtb $Vs)))>; 503e8d8bef9SDimitry Andric def: Pat<(VecPI32 (vunpacku HVI32:$Vs)), (VZxth $Vs)>; 504e8d8bef9SDimitry Andric 505e8d8bef9SDimitry Andric let Predicates = [UseHVX,UseHVXV60] in { 5060b57cec5SDimitry Andric def: Pat<(VecI16 (bswap HVI16:$Vs)), 507e8d8bef9SDimitry Andric (V6_vdelta HvxVR:$Vs, (V60splatib (i32 0x01)))>; 5080b57cec5SDimitry Andric def: Pat<(VecI32 (bswap HVI32:$Vs)), 509e8d8bef9SDimitry Andric (V6_vdelta HvxVR:$Vs, (V60splatib (i32 0x03)))>; 510e8d8bef9SDimitry Andric } 511e8d8bef9SDimitry Andric let Predicates = [UseHVX,UseHVXV62], AddedComplexity = 10 in { 512e8d8bef9SDimitry Andric def: Pat<(VecI16 (bswap HVI16:$Vs)), 513e8d8bef9SDimitry Andric (V6_vdelta HvxVR:$Vs, (V62splatib (i32 0x01)))>; 514e8d8bef9SDimitry Andric def: Pat<(VecI32 (bswap HVI32:$Vs)), 515e8d8bef9SDimitry Andric (V6_vdelta HvxVR:$Vs, (V62splatib (i32 0x03)))>; 516e8d8bef9SDimitry Andric } 5170b57cec5SDimitry Andric 5180b57cec5SDimitry Andric def: Pat<(VecI8 (ctpop HVI8:$Vs)), 5190b57cec5SDimitry Andric (V6_vpackeb (V6_vpopcounth (HiVec (V6_vunpackub HvxVR:$Vs))), 5200b57cec5SDimitry Andric (V6_vpopcounth (LoVec (V6_vunpackub HvxVR:$Vs))))>; 5210b57cec5SDimitry Andric def: Pat<(VecI16 (ctpop HVI16:$Vs)), (V6_vpopcounth HvxVR:$Vs)>; 5220b57cec5SDimitry Andric def: Pat<(VecI32 (ctpop HVI32:$Vs)), 5230b57cec5SDimitry Andric (V6_vaddw (LoVec (V6_vzh (V6_vpopcounth HvxVR:$Vs))), 5240b57cec5SDimitry Andric (HiVec (V6_vzh (V6_vpopcounth HvxVR:$Vs))))>; 5250b57cec5SDimitry Andric 526e8d8bef9SDimitry Andric let Predicates = [UseHVX,UseHVXV60] in 5270b57cec5SDimitry Andric def: Pat<(VecI8 (ctlz HVI8:$Vs)), 5280b57cec5SDimitry Andric (V6_vsubb (V6_vpackeb (V6_vcl0h (HiVec (V6_vunpackub HvxVR:$Vs))), 5290b57cec5SDimitry Andric (V6_vcl0h (LoVec (V6_vunpackub HvxVR:$Vs)))), 530e8d8bef9SDimitry Andric (V60splatib (i32 0x08)))>; 531e8d8bef9SDimitry Andric let Predicates = [UseHVX,UseHVXV62], AddedComplexity = 10 in 532e8d8bef9SDimitry Andric def: Pat<(VecI8 (ctlz HVI8:$Vs)), 533e8d8bef9SDimitry Andric (V6_vsubb (V6_vpackeb (V6_vcl0h (HiVec (V6_vunpackub HvxVR:$Vs))), 534e8d8bef9SDimitry Andric (V6_vcl0h (LoVec (V6_vunpackub HvxVR:$Vs)))), 535e8d8bef9SDimitry Andric (V62splatib (i32 0x08)))>; 536e8d8bef9SDimitry Andric 5370b57cec5SDimitry Andric def: Pat<(VecI16 (ctlz HVI16:$Vs)), (V6_vcl0h HvxVR:$Vs)>; 5380b57cec5SDimitry Andric def: Pat<(VecI32 (ctlz HVI32:$Vs)), (V6_vcl0w HvxVR:$Vs)>; 5390b57cec5SDimitry Andric} 5400b57cec5SDimitry Andric 5410b57cec5SDimitry Andricclass HvxSel_pat<InstHexagon MI, PatFrag RegPred> 5420b57cec5SDimitry Andric : Pat<(select I1:$Pu, RegPred:$Vs, RegPred:$Vt), 5430b57cec5SDimitry Andric (MI I1:$Pu, RegPred:$Vs, RegPred:$Vt)>; 5440b57cec5SDimitry Andric 5450b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 5460b57cec5SDimitry Andric def: HvxSel_pat<PS_vselect, HVI8>; 5470b57cec5SDimitry Andric def: HvxSel_pat<PS_vselect, HVI16>; 5480b57cec5SDimitry Andric def: HvxSel_pat<PS_vselect, HVI32>; 5490b57cec5SDimitry Andric def: HvxSel_pat<PS_wselect, HWI8>; 5500b57cec5SDimitry Andric def: HvxSel_pat<PS_wselect, HWI16>; 5510b57cec5SDimitry Andric def: HvxSel_pat<PS_wselect, HWI32>; 5520b57cec5SDimitry Andric} 5530b57cec5SDimitry Andric 5540b57cec5SDimitry Andriclet Predicates = [UseHVX] in { 5550b57cec5SDimitry Andric def: Pat<(VecQ8 (qtrue)), (PS_qtrue)>; 5560b57cec5SDimitry Andric def: Pat<(VecQ16 (qtrue)), (PS_qtrue)>; 5570b57cec5SDimitry Andric def: Pat<(VecQ32 (qtrue)), (PS_qtrue)>; 5580b57cec5SDimitry Andric def: Pat<(VecQ8 (qfalse)), (PS_qfalse)>; 5590b57cec5SDimitry Andric def: Pat<(VecQ16 (qfalse)), (PS_qfalse)>; 5600b57cec5SDimitry Andric def: Pat<(VecQ32 (qfalse)), (PS_qfalse)>; 5610b57cec5SDimitry Andric 5620b57cec5SDimitry Andric def: Pat<(vnot HQ8:$Qs), (V6_pred_not HvxQR:$Qs)>; 5630b57cec5SDimitry Andric def: Pat<(vnot HQ16:$Qs), (V6_pred_not HvxQR:$Qs)>; 5640b57cec5SDimitry Andric def: Pat<(vnot HQ32:$Qs), (V6_pred_not HvxQR:$Qs)>; 5650b57cec5SDimitry Andric def: Pat<(qnot HQ8:$Qs), (V6_pred_not HvxQR:$Qs)>; 5660b57cec5SDimitry Andric def: Pat<(qnot HQ16:$Qs), (V6_pred_not HvxQR:$Qs)>; 5670b57cec5SDimitry Andric def: Pat<(qnot HQ32:$Qs), (V6_pred_not HvxQR:$Qs)>; 5680b57cec5SDimitry Andric 5690b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_and, And, VecQ8, HQ8>; 5700b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_and, And, VecQ16, HQ16>; 5710b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_and, And, VecQ32, HQ32>; 5720b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_or, Or, VecQ8, HQ8>; 5730b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_or, Or, VecQ16, HQ16>; 5740b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_or, Or, VecQ32, HQ32>; 5750b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_xor, Xor, VecQ8, HQ8>; 5760b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_xor, Xor, VecQ16, HQ16>; 5770b57cec5SDimitry Andric def: OpR_RR_pat<V6_pred_xor, Xor, VecQ32, HQ32>; 5780b57cec5SDimitry Andric 579*fe6060f1SDimitry Andric def: OpR_RR_pat<V6_pred_and_n, VNot2<And, qnot>, VecQ8, HQ8>; 580*fe6060f1SDimitry Andric def: OpR_RR_pat<V6_pred_and_n, VNot2<And, qnot>, VecQ16, HQ16>; 581*fe6060f1SDimitry Andric def: OpR_RR_pat<V6_pred_and_n, VNot2<And, qnot>, VecQ32, HQ32>; 582*fe6060f1SDimitry Andric def: OpR_RR_pat<V6_pred_or_n, VNot2<Or, qnot>, VecQ8, HQ8>; 583*fe6060f1SDimitry Andric def: OpR_RR_pat<V6_pred_or_n, VNot2<Or, qnot>, VecQ16, HQ16>; 584*fe6060f1SDimitry Andric def: OpR_RR_pat<V6_pred_or_n, VNot2<Or, qnot>, VecQ32, HQ32>; 5850b57cec5SDimitry Andric 5860b57cec5SDimitry Andric def: OpR_RR_pat<V6_veqb, seteq, VecQ8, HVI8>; 5870b57cec5SDimitry Andric def: OpR_RR_pat<V6_veqh, seteq, VecQ16, HVI16>; 5880b57cec5SDimitry Andric def: OpR_RR_pat<V6_veqw, seteq, VecQ32, HVI32>; 5890b57cec5SDimitry Andric def: OpR_RR_pat<V6_vgtb, setgt, VecQ8, HVI8>; 5900b57cec5SDimitry Andric def: OpR_RR_pat<V6_vgth, setgt, VecQ16, HVI16>; 5910b57cec5SDimitry Andric def: OpR_RR_pat<V6_vgtw, setgt, VecQ32, HVI32>; 5920b57cec5SDimitry Andric def: OpR_RR_pat<V6_vgtub, setugt, VecQ8, HVI8>; 5930b57cec5SDimitry Andric def: OpR_RR_pat<V6_vgtuh, setugt, VecQ16, HVI16>; 5940b57cec5SDimitry Andric def: OpR_RR_pat<V6_vgtuw, setugt, VecQ32, HVI32>; 5950b57cec5SDimitry Andric 5960b57cec5SDimitry Andric def: AccRRR_pat<V6_veqb_and, And, seteq, HQ8, HVI8, HVI8>; 5970b57cec5SDimitry Andric def: AccRRR_pat<V6_veqb_or, Or, seteq, HQ8, HVI8, HVI8>; 5980b57cec5SDimitry Andric def: AccRRR_pat<V6_veqb_xor, Xor, seteq, HQ8, HVI8, HVI8>; 5990b57cec5SDimitry Andric def: AccRRR_pat<V6_veqh_and, And, seteq, HQ16, HVI16, HVI16>; 6000b57cec5SDimitry Andric def: AccRRR_pat<V6_veqh_or, Or, seteq, HQ16, HVI16, HVI16>; 6010b57cec5SDimitry Andric def: AccRRR_pat<V6_veqh_xor, Xor, seteq, HQ16, HVI16, HVI16>; 6020b57cec5SDimitry Andric def: AccRRR_pat<V6_veqw_and, And, seteq, HQ32, HVI32, HVI32>; 6030b57cec5SDimitry Andric def: AccRRR_pat<V6_veqw_or, Or, seteq, HQ32, HVI32, HVI32>; 6040b57cec5SDimitry Andric def: AccRRR_pat<V6_veqw_xor, Xor, seteq, HQ32, HVI32, HVI32>; 6050b57cec5SDimitry Andric 6060b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtb_and, And, setgt, HQ8, HVI8, HVI8>; 6070b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtb_or, Or, setgt, HQ8, HVI8, HVI8>; 6080b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtb_xor, Xor, setgt, HQ8, HVI8, HVI8>; 6090b57cec5SDimitry Andric def: AccRRR_pat<V6_vgth_and, And, setgt, HQ16, HVI16, HVI16>; 6100b57cec5SDimitry Andric def: AccRRR_pat<V6_vgth_or, Or, setgt, HQ16, HVI16, HVI16>; 6110b57cec5SDimitry Andric def: AccRRR_pat<V6_vgth_xor, Xor, setgt, HQ16, HVI16, HVI16>; 6120b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtw_and, And, setgt, HQ32, HVI32, HVI32>; 6130b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtw_or, Or, setgt, HQ32, HVI32, HVI32>; 6140b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtw_xor, Xor, setgt, HQ32, HVI32, HVI32>; 6150b57cec5SDimitry Andric 6160b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtub_and, And, setugt, HQ8, HVI8, HVI8>; 6170b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtub_or, Or, setugt, HQ8, HVI8, HVI8>; 6180b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtub_xor, Xor, setugt, HQ8, HVI8, HVI8>; 6190b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtuh_and, And, setugt, HQ16, HVI16, HVI16>; 6200b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtuh_or, Or, setugt, HQ16, HVI16, HVI16>; 6210b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtuh_xor, Xor, setugt, HQ16, HVI16, HVI16>; 6220b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtuw_and, And, setugt, HQ32, HVI32, HVI32>; 6230b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtuw_or, Or, setugt, HQ32, HVI32, HVI32>; 6240b57cec5SDimitry Andric def: AccRRR_pat<V6_vgtuw_xor, Xor, setugt, HQ32, HVI32, HVI32>; 6250b57cec5SDimitry Andric} 626