2 SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>, SDTCisSameAs<1,2>]>;
4 def SDTHexagonVEXTRACTW: SDTypeProfile<1, 2,
5 [SDTCisVT<0, i32>, SDTCisVec<1>, SDTCisVT<2, i32>]>;
6 def HexagonVEXTRACTW : SDNode<"HexagonISD::VEXTRACTW", SDTHexagonVEXTRACTW>;
8 def SDTHexagonVINSERTW0: SDTypeProfile<1, 2,
9 [SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisVT<2, i32>]>;
10 def HexagonVINSERTW0: SDNode<"HexagonISD::VINSERTW0", SDTHexagonVINSERTW0>;
12 def SDTHexagonVSPLATW: SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVT<1, i32>]>;
13 def HexagonVSPLATW: SDNode<"HexagonISD::VSPLATW", SDTHexagonVSPLATW>;
15 def HwLen2: SDNodeXForm<imm, [{
16 const auto &ST = static_cast<const HexagonSubtarget&>(CurDAG->getSubtarget());
17 return CurDAG->getTargetConstant(ST.getVectorLength()/2, SDLoc(N), MVT::i32);
20 def Q2V: OutPatFrag<(ops node:$Qs), (V6_vandqrt $Qs, (A2_tfrsi -1))>;
22 def Combinev: OutPatFrag<(ops node:$Vs, node:$Vt),
23 (REG_SEQUENCE HvxWR, $Vs, vsub_hi, $Vt, vsub_lo)>;
25 def Combineq: OutPatFrag<(ops node:$Qs, node:$Qt),
28 (V6_vror (V6_vpackeb (V6_vd0), (Q2V $Qs)),
29 (A2_tfrsi (HwLen2 (i32 0)))), // Half the vector length
30 (V6_vpackeb (V6_vd0), (Q2V $Qt))),
33 def LoVec: OutPatFrag<(ops node:$Vs), (EXTRACT_SUBREG $Vs, vsub_lo)>;
34 def HiVec: OutPatFrag<(ops node:$Vs), (EXTRACT_SUBREG $Vs, vsub_hi)>;
36 def HexagonVZERO: SDNode<"HexagonISD::VZERO", SDTVecLeaf>;
37 def HexagonQCAT: SDNode<"HexagonISD::QCAT", SDTVecBinOp>;
38 def HexagonQTRUE: SDNode<"HexagonISD::QTRUE", SDTVecLeaf>;
39 def HexagonQFALSE: SDNode<"HexagonISD::QFALSE", SDTVecLeaf>;
41 def vzero: PatFrag<(ops), (HexagonVZERO)>;
42 def qtrue: PatFrag<(ops), (HexagonQTRUE)>;
43 def qfalse: PatFrag<(ops), (HexagonQFALSE)>;
44 def qcat: PatFrag<(ops node:$Qs, node:$Qt),
45 (HexagonQCAT node:$Qs, node:$Qt)>;
47 def qnot: PatFrag<(ops node:$Qs), (xor node:$Qs, qtrue)>;
49 def VSxtb: OutPatFrag<(ops node:$Vs), (V6_vunpackb $Vs)>;
50 def VSxth: OutPatFrag<(ops node:$Vs), (V6_vunpackh $Vs)>;
51 def VZxtb: OutPatFrag<(ops node:$Vs), (V6_vunpackub $Vs)>;
52 def VZxth: OutPatFrag<(ops node:$Vs), (V6_vunpackuh $Vs)>;
54 def SplatB: SDNodeXForm<imm, [{
55 uint32_t V = N->getZExtValue();
57 uint32_t S = V << 24 | V << 16 | V << 8 | V;
58 return CurDAG->getTargetConstant(S, SDLoc(N), MVT::i32);
61 def SplatH: SDNodeXForm<imm, [{
62 uint32_t V = N->getZExtValue();
63 assert(isUInt<16>(V));
64 return CurDAG->getTargetConstant(V << 16 | V, SDLoc(N), MVT::i32);
67 def IsVecOff : PatLeaf<(i32 imm), [{
68 int32_t V = N->getSExtValue();
69 int32_t VecSize = HRI->getSpillSize(Hexagon::HvxVRRegClass);
70 assert(isPowerOf2_32(VecSize));
71 if ((uint32_t(V) & (uint32_t(VecSize)-1)) != 0)
73 int32_t L = Log2_32(VecSize);
74 return isInt<4>(V >> L);
78 def alignedload: PatFrag<(ops node:$a), (load $a), [{
79 return isAlignedMemNode(dyn_cast<MemSDNode>(N));
82 def unalignedload: PatFrag<(ops node:$a), (load $a), [{
83 return !isAlignedMemNode(dyn_cast<MemSDNode>(N));
86 def alignedstore: PatFrag<(ops node:$v, node:$a), (store $v, $a), [{
87 return isAlignedMemNode(dyn_cast<MemSDNode>(N));
90 def unalignedstore: PatFrag<(ops node:$v, node:$a), (store $v, $a), [{
91 return !isAlignedMemNode(dyn_cast<MemSDNode>(N));
97 multiclass HvxLd_pat<InstHexagon MI, PatFrag Load, ValueType ResType,
99 def: Pat<(ResType (Load I32:$Rt)),
101 def: Pat<(ResType (Load (add I32:$Rt, ImmPred:$s))),
102 (MI I32:$Rt, imm:$s)>;
103 // The HVX selection code for shuffles can generate vector constants.
104 // Calling "Select" on the resulting loads from CP fails without these
106 def: Pat<(ResType (Load (HexagonCP tconstpool:$A))),
107 (MI (A2_tfrsi imm:$A), 0)>;
108 def: Pat<(ResType (Load (HexagonAtPcrel tconstpool:$A))),
109 (MI (C4_addipc imm:$A), 0)>;
112 multiclass HvxLda_pat<InstHexagon MI, PatFrag Load, ValueType ResType,
114 let AddedComplexity = 50 in {
115 def: Pat<(ResType (Load (valignaddr I32:$Rt))),
117 def: Pat<(ResType (Load (add (valignaddr I32:$Rt), ImmPred:$Off))),
118 (MI I32:$Rt, imm:$Off)>;
120 defm: HvxLd_pat<MI, Load, ResType, ImmPred>;
123 let Predicates = [UseHVX] in {
124 defm: HvxLda_pat<V6_vL32b_nt_ai, alignednontemporalload, VecI8, IsVecOff>;
125 defm: HvxLda_pat<V6_vL32b_nt_ai, alignednontemporalload, VecI16, IsVecOff>;
126 defm: HvxLda_pat<V6_vL32b_nt_ai, alignednontemporalload, VecI32, IsVecOff>;
128 defm: HvxLda_pat<V6_vL32b_ai, alignedload, VecI8, IsVecOff>;
129 defm: HvxLda_pat<V6_vL32b_ai, alignedload, VecI16, IsVecOff>;
130 defm: HvxLda_pat<V6_vL32b_ai, alignedload, VecI32, IsVecOff>;
132 defm: HvxLd_pat<V6_vL32Ub_ai, unalignedload, VecI8, IsVecOff>;
133 defm: HvxLd_pat<V6_vL32Ub_ai, unalignedload, VecI16, IsVecOff>;
134 defm: HvxLd_pat<V6_vL32Ub_ai, unalignedload, VecI32, IsVecOff>;
139 multiclass HvxSt_pat<InstHexagon MI, PatFrag Store, PatFrag ImmPred,
141 def: Pat<(Store Value:$Vs, I32:$Rt),
142 (MI I32:$Rt, 0, Value:$Vs)>;
143 def: Pat<(Store Value:$Vs, (add I32:$Rt, ImmPred:$s)),
144 (MI I32:$Rt, imm:$s, Value:$Vs)>;
147 let Predicates = [UseHVX] in {
148 defm: HvxSt_pat<V6_vS32b_nt_ai, alignednontemporalstore, IsVecOff, HVI8>;
149 defm: HvxSt_pat<V6_vS32b_nt_ai, alignednontemporalstore, IsVecOff, HVI16>;
150 defm: HvxSt_pat<V6_vS32b_nt_ai, alignednontemporalstore, IsVecOff, HVI32>;
152 defm: HvxSt_pat<V6_vS32b_ai, alignedstore, IsVecOff, HVI8>;
153 defm: HvxSt_pat<V6_vS32b_ai, alignedstore, IsVecOff, HVI16>;
154 defm: HvxSt_pat<V6_vS32b_ai, alignedstore, IsVecOff, HVI32>;
156 defm: HvxSt_pat<V6_vS32Ub_ai, unalignedstore, IsVecOff, HVI8>;
157 defm: HvxSt_pat<V6_vS32Ub_ai, unalignedstore, IsVecOff, HVI16>;
158 defm: HvxSt_pat<V6_vS32Ub_ai, unalignedstore, IsVecOff, HVI32>;
161 // Bitcasts between same-size vector types are no-ops, except for the
162 // actual type change.
163 class Bitcast<ValueType ResTy, ValueType InpTy, RegisterClass RC>
164 : Pat<(ResTy (bitconvert (InpTy RC:$Val))), (ResTy RC:$Val)>;
166 let Predicates = [UseHVX] in {
167 def: Bitcast<VecI8, VecI16, HvxVR>;
168 def: Bitcast<VecI8, VecI32, HvxVR>;
169 def: Bitcast<VecI16, VecI8, HvxVR>;
170 def: Bitcast<VecI16, VecI32, HvxVR>;
171 def: Bitcast<VecI32, VecI8, HvxVR>;
172 def: Bitcast<VecI32, VecI16, HvxVR>;
174 def: Bitcast<VecPI8, VecPI16, HvxWR>;
175 def: Bitcast<VecPI8, VecPI32, HvxWR>;
176 def: Bitcast<VecPI16, VecPI8, HvxWR>;
177 def: Bitcast<VecPI16, VecPI32, HvxWR>;
178 def: Bitcast<VecPI32, VecPI8, HvxWR>;
179 def: Bitcast<VecPI32, VecPI16, HvxWR>;
182 let Predicates = [UseHVX] in {
183 def: Pat<(VecI8 vzero), (V6_vd0)>;
184 def: Pat<(VecI16 vzero), (V6_vd0)>;
185 def: Pat<(VecI32 vzero), (V6_vd0)>;
186 def: Pat<(VecPI8 vzero), (PS_vdd0)>;
187 def: Pat<(VecPI16 vzero), (PS_vdd0)>;
188 def: Pat<(VecPI32 vzero), (PS_vdd0)>;
190 def: Pat<(concat_vectors (VecI8 vzero), (VecI8 vzero)), (PS_vdd0)>;
191 def: Pat<(concat_vectors (VecI16 vzero), (VecI16 vzero)), (PS_vdd0)>;
192 def: Pat<(concat_vectors (VecI32 vzero), (VecI32 vzero)), (PS_vdd0)>;
194 def: Pat<(VecPI8 (concat_vectors HVI8:$Vs, HVI8:$Vt)),
195 (Combinev HvxVR:$Vt, HvxVR:$Vs)>;
196 def: Pat<(VecPI16 (concat_vectors HVI16:$Vs, HVI16:$Vt)),
197 (Combinev HvxVR:$Vt, HvxVR:$Vs)>;
198 def: Pat<(VecPI32 (concat_vectors HVI32:$Vs, HVI32:$Vt)),
199 (Combinev HvxVR:$Vt, HvxVR:$Vs)>;
201 def: Pat<(VecQ8 (qcat HQ16:$Qs, HQ16:$Qt)), (Combineq $Qt, $Qs)>;
202 def: Pat<(VecQ16 (qcat HQ32:$Qs, HQ32:$Qt)), (Combineq $Qt, $Qs)>;
204 def: Pat<(HexagonVEXTRACTW HVI8:$Vu, I32:$Rs),
205 (V6_extractw HvxVR:$Vu, I32:$Rs)>;
206 def: Pat<(HexagonVEXTRACTW HVI16:$Vu, I32:$Rs),
207 (V6_extractw HvxVR:$Vu, I32:$Rs)>;
208 def: Pat<(HexagonVEXTRACTW HVI32:$Vu, I32:$Rs),
209 (V6_extractw HvxVR:$Vu, I32:$Rs)>;
211 def: Pat<(HexagonVINSERTW0 HVI8:$Vu, I32:$Rt),
212 (V6_vinsertwr HvxVR:$Vu, I32:$Rt)>;
213 def: Pat<(HexagonVINSERTW0 HVI16:$Vu, I32:$Rt),
214 (V6_vinsertwr HvxVR:$Vu, I32:$Rt)>;
215 def: Pat<(HexagonVINSERTW0 HVI32:$Vu, I32:$Rt),
216 (V6_vinsertwr HvxVR:$Vu, I32:$Rt)>;
219 def Vsplatib: OutPatFrag<(ops node:$V), (V6_lvsplatw (ToI32 (SplatB $V)))>;
220 def Vsplatih: OutPatFrag<(ops node:$V), (V6_lvsplatw (ToI32 (SplatH $V)))>;
221 def Vsplatiw: OutPatFrag<(ops node:$V), (V6_lvsplatw (ToI32 $V))>;
223 def Vsplatrb: OutPatFrag<(ops node:$Rs), (V6_lvsplatw (S2_vsplatrb $Rs))>;
224 def Vsplatrh: OutPatFrag<(ops node:$Rs),
225 (V6_lvsplatw (A2_combine_ll $Rs, $Rs))>;
226 def Vsplatrw: OutPatFrag<(ops node:$Rs), (V6_lvsplatw $Rs)>;
228 def Rep: OutPatFrag<(ops node:$N), (Combinev $N, $N)>;
230 let Predicates = [UseHVX] in {
231 let AddedComplexity = 10 in {
232 def: Pat<(VecI8 (HexagonVSPLAT u8_0ImmPred:$V)), (Vsplatib $V)>;
233 def: Pat<(VecI16 (HexagonVSPLAT u16_0ImmPred:$V)), (Vsplatih $V)>;
234 def: Pat<(VecI32 (HexagonVSPLAT anyimm:$V)), (Vsplatiw $V)>;
235 def: Pat<(VecPI8 (HexagonVSPLAT u8_0ImmPred:$V)), (Rep (Vsplatib $V))>;
236 def: Pat<(VecPI16 (HexagonVSPLAT u16_0ImmPred:$V)), (Rep (Vsplatih $V))>;
237 def: Pat<(VecPI32 (HexagonVSPLAT anyimm:$V)), (Rep (Vsplatiw $V))>;
239 def: Pat<(VecI8 (HexagonVSPLAT I32:$Rs)), (Vsplatrb $Rs)>;
240 def: Pat<(VecI16 (HexagonVSPLAT I32:$Rs)), (Vsplatrh $Rs)>;
241 def: Pat<(VecI32 (HexagonVSPLAT I32:$Rs)), (Vsplatrw $Rs)>;
242 def: Pat<(VecPI8 (HexagonVSPLAT I32:$Rs)), (Rep (Vsplatrb $Rs))>;
243 def: Pat<(VecPI16 (HexagonVSPLAT I32:$Rs)), (Rep (Vsplatrh $Rs))>;
244 def: Pat<(VecPI32 (HexagonVSPLAT I32:$Rs)), (Rep (Vsplatrw $Rs))>;
246 def: Pat<(VecI8 (HexagonVSPLATW I32:$Rs)), (Vsplatrw $Rs)>;
247 def: Pat<(VecI16 (HexagonVSPLATW I32:$Rs)), (Vsplatrw $Rs)>;
248 def: Pat<(VecI32 (HexagonVSPLATW I32:$Rs)), (Vsplatrw $Rs)>;
249 def: Pat<(VecPI8 (HexagonVSPLATW I32:$Rs)), (Rep (Vsplatrw $Rs))>;
250 def: Pat<(VecPI16 (HexagonVSPLATW I32:$Rs)), (Rep (Vsplatrw $Rs))>;
251 def: Pat<(VecPI32 (HexagonVSPLATW I32:$Rs)), (Rep (Vsplatrw $Rs))>;
254 class Vneg1<ValueType VecTy>
255 : PatFrag<(ops), (VecTy (HexagonVSPLATW (i32 -1)))>;
257 class Vnot<ValueType VecTy>
258 : PatFrag<(ops node:$Vs), (xor $Vs, Vneg1<VecTy>)>;
260 let Predicates = [UseHVX] in {
261 let AddedComplexity = 220 in {
262 defm: MinMax_pats<V6_vminb, V6_vmaxb, vselect, setgt, VecQ8, HVI8>;
263 defm: MinMax_pats<V6_vminb, V6_vmaxb, vselect, setge, VecQ8, HVI8>;
264 defm: MinMax_pats<V6_vminub, V6_vmaxub, vselect, setugt, VecQ8, HVI8>;
265 defm: MinMax_pats<V6_vminub, V6_vmaxub, vselect, setuge, VecQ8, HVI8>;
266 defm: MinMax_pats<V6_vminh, V6_vmaxh, vselect, setgt, VecQ16, HVI16>;
267 defm: MinMax_pats<V6_vminh, V6_vmaxh, vselect, setge, VecQ16, HVI16>;
268 defm: MinMax_pats<V6_vminuh, V6_vmaxuh, vselect, setugt, VecQ16, HVI16>;
269 defm: MinMax_pats<V6_vminuh, V6_vmaxuh, vselect, setuge, VecQ16, HVI16>;
270 defm: MinMax_pats<V6_vminw, V6_vmaxw, vselect, setgt, VecQ32, HVI32>;
271 defm: MinMax_pats<V6_vminw, V6_vmaxw, vselect, setge, VecQ32, HVI32>;
275 let Predicates = [UseHVX] in {
276 let AddedComplexity = 200 in {
277 def: Pat<(Vnot<VecI8> HVI8:$Vs), (V6_vnot HvxVR:$Vs)>;
278 def: Pat<(Vnot<VecI16> HVI16:$Vs), (V6_vnot HvxVR:$Vs)>;
279 def: Pat<(Vnot<VecI32> HVI32:$Vs), (V6_vnot HvxVR:$Vs)>;
282 def: OpR_RR_pat<V6_vaddb, Add, VecI8, HVI8>;
283 def: OpR_RR_pat<V6_vaddh, Add, VecI16, HVI16>;
284 def: OpR_RR_pat<V6_vaddw, Add, VecI32, HVI32>;
285 def: OpR_RR_pat<V6_vaddb_dv, Add, VecPI8, HWI8>;
286 def: OpR_RR_pat<V6_vaddh_dv, Add, VecPI16, HWI16>;
287 def: OpR_RR_pat<V6_vaddw_dv, Add, VecPI32, HWI32>;
288 def: OpR_RR_pat<V6_vsubb, Sub, VecI8, HVI8>;
289 def: OpR_RR_pat<V6_vsubh, Sub, VecI16, HVI16>;
290 def: OpR_RR_pat<V6_vsubw, Sub, VecI32, HVI32>;
291 def: OpR_RR_pat<V6_vsubb_dv, Sub, VecPI8, HWI8>;
292 def: OpR_RR_pat<V6_vsubh_dv, Sub, VecPI16, HWI16>;
293 def: OpR_RR_pat<V6_vsubw_dv, Sub, VecPI32, HWI32>;
294 def: OpR_RR_pat<V6_vand, And, VecI8, HVI8>;
295 def: OpR_RR_pat<V6_vand, And, VecI16, HVI16>;
296 def: OpR_RR_pat<V6_vand, And, VecI32, HVI32>;
297 def: OpR_RR_pat<V6_vor, Or, VecI8, HVI8>;
298 def: OpR_RR_pat<V6_vor, Or, VecI16, HVI16>;
299 def: OpR_RR_pat<V6_vor, Or, VecI32, HVI32>;
300 def: OpR_RR_pat<V6_vxor, Xor, VecI8, HVI8>;
301 def: OpR_RR_pat<V6_vxor, Xor, VecI16, HVI16>;
302 def: OpR_RR_pat<V6_vxor, Xor, VecI32, HVI32>;
304 def: Pat<(vselect HQ8:$Qu, HVI8:$Vs, HVI8:$Vt),
305 (V6_vmux HvxQR:$Qu, HvxVR:$Vs, HvxVR:$Vt)>;
306 def: Pat<(vselect HQ16:$Qu, HVI16:$Vs, HVI16:$Vt),
307 (V6_vmux HvxQR:$Qu, HvxVR:$Vs, HvxVR:$Vt)>;
308 def: Pat<(vselect HQ32:$Qu, HVI32:$Vs, HVI32:$Vt),
309 (V6_vmux HvxQR:$Qu, HvxVR:$Vs, HvxVR:$Vt)>;
311 def: Pat<(vselect (qnot HQ8:$Qu), HVI8:$Vs, HVI8:$Vt),
312 (V6_vmux HvxQR:$Qu, HvxVR:$Vt, HvxVR:$Vs)>;
313 def: Pat<(vselect (qnot HQ16:$Qu), HVI16:$Vs, HVI16:$Vt),
314 (V6_vmux HvxQR:$Qu, HvxVR:$Vt, HvxVR:$Vs)>;
315 def: Pat<(vselect (qnot HQ32:$Qu), HVI32:$Vs, HVI32:$Vt),
316 (V6_vmux HvxQR:$Qu, HvxVR:$Vt, HvxVR:$Vs)>;
319 let Predicates = [UseHVX] in {
320 def: Pat<(VecPI16 (sext HVI8:$Vs)), (VSxtb $Vs)>;
321 def: Pat<(VecPI32 (sext HVI16:$Vs)), (VSxth $Vs)>;
322 def: Pat<(VecPI16 (zext HVI8:$Vs)), (VZxtb $Vs)>;
323 def: Pat<(VecPI32 (zext HVI16:$Vs)), (VZxth $Vs)>;
325 def: Pat<(VecI16 (sext_invec HVI8:$Vs)), (LoVec (VSxtb $Vs))>;
326 def: Pat<(VecI32 (sext_invec HVI16:$Vs)), (LoVec (VSxth $Vs))>;
327 def: Pat<(VecI32 (sext_invec HVI8:$Vs)),
328 (LoVec (VSxth (LoVec (VSxtb $Vs))))>;
329 def: Pat<(VecPI16 (sext_invec HWI8:$Vss)), (VSxtb (LoVec $Vss))>;
330 def: Pat<(VecPI32 (sext_invec HWI16:$Vss)), (VSxth (LoVec $Vss))>;
331 def: Pat<(VecPI32 (sext_invec HWI8:$Vss)),
332 (VSxth (LoVec (VSxtb (LoVec $Vss))))>;
334 def: Pat<(VecI16 (zext_invec HVI8:$Vs)), (LoVec (VZxtb $Vs))>;
335 def: Pat<(VecI32 (zext_invec HVI16:$Vs)), (LoVec (VZxth $Vs))>;
336 def: Pat<(VecI32 (zext_invec HVI8:$Vs)),
337 (LoVec (VZxth (LoVec (VZxtb $Vs))))>;
338 def: Pat<(VecPI16 (zext_invec HWI8:$Vss)), (VZxtb (LoVec $Vss))>;
339 def: Pat<(VecPI32 (zext_invec HWI16:$Vss)), (VZxth (LoVec $Vss))>;
340 def: Pat<(VecPI32 (zext_invec HWI8:$Vss)),
341 (VZxth (LoVec (VZxtb (LoVec $Vss))))>;
343 def: Pat<(VecI8 (trunc HWI16:$Vss)),
344 (V6_vpackeb (HiVec $Vss), (LoVec $Vss))>;
345 def: Pat<(VecI16 (trunc HWI32:$Vss)),
346 (V6_vpackeh (HiVec $Vss), (LoVec $Vss))>;
348 def: Pat<(VecQ8 (trunc HVI8:$Vs)),
349 (V6_vandvrt HvxVR:$Vs, (A2_tfrsi 0x01010101))>;
350 def: Pat<(VecQ16 (trunc HVI16:$Vs)),
351 (V6_vandvrt HvxVR:$Vs, (A2_tfrsi 0x01010101))>;
352 def: Pat<(VecQ32 (trunc HVI32:$Vs)),
353 (V6_vandvrt HvxVR:$Vs, (A2_tfrsi 0x01010101))>;
356 let Predicates = [UseHVX] in {
357 // The "source" types are not legal, and there are no parameterized
358 // definitions for them, but they are length-specific.
359 let Predicates = [UseHVX,UseHVX64B] in {
360 def: Pat<(VecI16 (sext_inreg HVI16:$Vs, v32i8)),
361 (V6_vasrh (V6_vaslh HVI16:$Vs, (A2_tfrsi 8)), (A2_tfrsi 8))>;
362 def: Pat<(VecI32 (sext_inreg HVI32:$Vs, v16i8)),
363 (V6_vasrw (V6_vaslw HVI32:$Vs, (A2_tfrsi 24)), (A2_tfrsi 24))>;
364 def: Pat<(VecI32 (sext_inreg HVI32:$Vs, v16i16)),
365 (V6_vasrw (V6_vaslw HVI32:$Vs, (A2_tfrsi 16)), (A2_tfrsi 16))>;
367 let Predicates = [UseHVX,UseHVX128B] in {
368 def: Pat<(VecI16 (sext_inreg HVI16:$Vs, v64i8)),
369 (V6_vasrh (V6_vaslh HVI16:$Vs, (A2_tfrsi 8)), (A2_tfrsi 8))>;
370 def: Pat<(VecI32 (sext_inreg HVI32:$Vs, v32i8)),
371 (V6_vasrw (V6_vaslw HVI32:$Vs, (A2_tfrsi 24)), (A2_tfrsi 24))>;
372 def: Pat<(VecI32 (sext_inreg HVI32:$Vs, v32i16)),
373 (V6_vasrw (V6_vaslw HVI32:$Vs, (A2_tfrsi 16)), (A2_tfrsi 16))>;
376 def: Pat<(HexagonVASL HVI8:$Vs, I32:$Rt),
377 (V6_vpackeb (V6_vaslh (HiVec (VZxtb HvxVR:$Vs)), I32:$Rt),
378 (V6_vaslh (LoVec (VZxtb HvxVR:$Vs)), I32:$Rt))>;
379 def: Pat<(HexagonVASR HVI8:$Vs, I32:$Rt),
380 (V6_vpackeb (V6_vasrh (HiVec (VSxtb HvxVR:$Vs)), I32:$Rt),
381 (V6_vasrh (LoVec (VSxtb HvxVR:$Vs)), I32:$Rt))>;
382 def: Pat<(HexagonVLSR HVI8:$Vs, I32:$Rt),
383 (V6_vpackeb (V6_vlsrh (HiVec (VZxtb HvxVR:$Vs)), I32:$Rt),
384 (V6_vlsrh (LoVec (VZxtb HvxVR:$Vs)), I32:$Rt))>;
386 def: Pat<(HexagonVASL HVI16:$Vs, I32:$Rt), (V6_vaslh HvxVR:$Vs, I32:$Rt)>;
387 def: Pat<(HexagonVASL HVI32:$Vs, I32:$Rt), (V6_vaslw HvxVR:$Vs, I32:$Rt)>;
388 def: Pat<(HexagonVASR HVI16:$Vs, I32:$Rt), (V6_vasrh HvxVR:$Vs, I32:$Rt)>;
389 def: Pat<(HexagonVASR HVI32:$Vs, I32:$Rt), (V6_vasrw HvxVR:$Vs, I32:$Rt)>;
390 def: Pat<(HexagonVLSR HVI16:$Vs, I32:$Rt), (V6_vlsrh HvxVR:$Vs, I32:$Rt)>;
391 def: Pat<(HexagonVLSR HVI32:$Vs, I32:$Rt), (V6_vlsrw HvxVR:$Vs, I32:$Rt)>;
393 def: Pat<(add HVI32:$Vx, (HexagonVASL HVI32:$Vu, I32:$Rt)),
394 (V6_vaslw_acc HvxVR:$Vx, HvxVR:$Vu, I32:$Rt)>;
395 def: Pat<(add HVI32:$Vx, (HexagonVASR HVI32:$Vu, I32:$Rt)),
396 (V6_vasrw_acc HvxVR:$Vx, HvxVR:$Vu, I32:$Rt)>;
398 def: Pat<(shl HVI16:$Vs, HVI16:$Vt), (V6_vaslhv HvxVR:$Vs, HvxVR:$Vt)>;
399 def: Pat<(shl HVI32:$Vs, HVI32:$Vt), (V6_vaslwv HvxVR:$Vs, HvxVR:$Vt)>;
400 def: Pat<(sra HVI16:$Vs, HVI16:$Vt), (V6_vasrhv HvxVR:$Vs, HvxVR:$Vt)>;
401 def: Pat<(sra HVI32:$Vs, HVI32:$Vt), (V6_vasrwv HvxVR:$Vs, HvxVR:$Vt)>;
402 def: Pat<(srl HVI16:$Vs, HVI16:$Vt), (V6_vlsrhv HvxVR:$Vs, HvxVR:$Vt)>;
403 def: Pat<(srl HVI32:$Vs, HVI32:$Vt), (V6_vlsrwv HvxVR:$Vs, HvxVR:$Vt)>;
405 def: Pat<(VecI16 (bswap HVI16:$Vs)),
406 (V6_vdelta HvxVR:$Vs, (V6_lvsplatw (A2_tfrsi 0x01010101)))>;
407 def: Pat<(VecI32 (bswap HVI32:$Vs)),
408 (V6_vdelta HvxVR:$Vs, (V6_lvsplatw (A2_tfrsi 0x03030303)))>;
410 def: Pat<(VecI8 (ctpop HVI8:$Vs)),
411 (V6_vpackeb (V6_vpopcounth (HiVec (V6_vunpackub HvxVR:$Vs))),
412 (V6_vpopcounth (LoVec (V6_vunpackub HvxVR:$Vs))))>;
413 def: Pat<(VecI16 (ctpop HVI16:$Vs)), (V6_vpopcounth HvxVR:$Vs)>;
414 def: Pat<(VecI32 (ctpop HVI32:$Vs)),
415 (V6_vaddw (LoVec (V6_vzh (V6_vpopcounth HvxVR:$Vs))),
416 (HiVec (V6_vzh (V6_vpopcounth HvxVR:$Vs))))>;
418 def: Pat<(VecI8 (ctlz HVI8:$Vs)),
419 (V6_vsubb (V6_vpackeb (V6_vcl0h (HiVec (V6_vunpackub HvxVR:$Vs))),
420 (V6_vcl0h (LoVec (V6_vunpackub HvxVR:$Vs)))),
421 (V6_lvsplatw (A2_tfrsi 0x08080808)))>;
422 def: Pat<(VecI16 (ctlz HVI16:$Vs)), (V6_vcl0h HvxVR:$Vs)>;
423 def: Pat<(VecI32 (ctlz HVI32:$Vs)), (V6_vcl0w HvxVR:$Vs)>;
426 class HvxSel_pat<InstHexagon MI, PatFrag RegPred>
427 : Pat<(select I1:$Pu, RegPred:$Vs, RegPred:$Vt),
428 (MI I1:$Pu, RegPred:$Vs, RegPred:$Vt)>;
430 let Predicates = [UseHVX] in {
431 def: HvxSel_pat<PS_vselect, HVI8>;
432 def: HvxSel_pat<PS_vselect, HVI16>;
433 def: HvxSel_pat<PS_vselect, HVI32>;
434 def: HvxSel_pat<PS_wselect, HWI8>;
435 def: HvxSel_pat<PS_wselect, HWI16>;
436 def: HvxSel_pat<PS_wselect, HWI32>;
439 let Predicates = [UseHVX] in {
440 def: Pat<(VecQ8 (qtrue)), (PS_qtrue)>;
441 def: Pat<(VecQ16 (qtrue)), (PS_qtrue)>;
442 def: Pat<(VecQ32 (qtrue)), (PS_qtrue)>;
443 def: Pat<(VecQ8 (qfalse)), (PS_qfalse)>;
444 def: Pat<(VecQ16 (qfalse)), (PS_qfalse)>;
445 def: Pat<(VecQ32 (qfalse)), (PS_qfalse)>;
447 def: Pat<(vnot HQ8:$Qs), (V6_pred_not HvxQR:$Qs)>;
448 def: Pat<(vnot HQ16:$Qs), (V6_pred_not HvxQR:$Qs)>;
449 def: Pat<(vnot HQ32:$Qs), (V6_pred_not HvxQR:$Qs)>;
450 def: Pat<(qnot HQ8:$Qs), (V6_pred_not HvxQR:$Qs)>;
451 def: Pat<(qnot HQ16:$Qs), (V6_pred_not HvxQR:$Qs)>;
452 def: Pat<(qnot HQ32:$Qs), (V6_pred_not HvxQR:$Qs)>;
454 def: OpR_RR_pat<V6_pred_and, And, VecQ8, HQ8>;
455 def: OpR_RR_pat<V6_pred_and, And, VecQ16, HQ16>;
456 def: OpR_RR_pat<V6_pred_and, And, VecQ32, HQ32>;
457 def: OpR_RR_pat<V6_pred_or, Or, VecQ8, HQ8>;
458 def: OpR_RR_pat<V6_pred_or, Or, VecQ16, HQ16>;
459 def: OpR_RR_pat<V6_pred_or, Or, VecQ32, HQ32>;
460 def: OpR_RR_pat<V6_pred_xor, Xor, VecQ8, HQ8>;
461 def: OpR_RR_pat<V6_pred_xor, Xor, VecQ16, HQ16>;
462 def: OpR_RR_pat<V6_pred_xor, Xor, VecQ32, HQ32>;
464 def: OpR_RR_pat<V6_pred_and_n, Not2<And>, VecQ8, HQ8>;
465 def: OpR_RR_pat<V6_pred_and_n, Not2<And>, VecQ16, HQ16>;
466 def: OpR_RR_pat<V6_pred_and_n, Not2<And>, VecQ32, HQ32>;
467 def: OpR_RR_pat<V6_pred_or_n, Not2<Or>, VecQ8, HQ8>;
468 def: OpR_RR_pat<V6_pred_or_n, Not2<Or>, VecQ16, HQ16>;
469 def: OpR_RR_pat<V6_pred_or_n, Not2<Or>, VecQ32, HQ32>;
471 def: OpR_RR_pat<V6_veqb, seteq, VecQ8, HVI8>;
472 def: OpR_RR_pat<V6_veqh, seteq, VecQ16, HVI16>;
473 def: OpR_RR_pat<V6_veqw, seteq, VecQ32, HVI32>;
474 def: OpR_RR_pat<V6_vgtb, setgt, VecQ8, HVI8>;
475 def: OpR_RR_pat<V6_vgth, setgt, VecQ16, HVI16>;
476 def: OpR_RR_pat<V6_vgtw, setgt, VecQ32, HVI32>;
477 def: OpR_RR_pat<V6_vgtub, setugt, VecQ8, HVI8>;
478 def: OpR_RR_pat<V6_vgtuh, setugt, VecQ16, HVI16>;
479 def: OpR_RR_pat<V6_vgtuw, setugt, VecQ32, HVI32>;
481 def: AccRRR_pat<V6_veqb_and, And, seteq, HQ8, HVI8, HVI8>;
482 def: AccRRR_pat<V6_veqb_or, Or, seteq, HQ8, HVI8, HVI8>;
483 def: AccRRR_pat<V6_veqb_xor, Xor, seteq, HQ8, HVI8, HVI8>;
484 def: AccRRR_pat<V6_veqh_and, And, seteq, HQ16, HVI16, HVI16>;
485 def: AccRRR_pat<V6_veqh_or, Or, seteq, HQ16, HVI16, HVI16>;
486 def: AccRRR_pat<V6_veqh_xor, Xor, seteq, HQ16, HVI16, HVI16>;
487 def: AccRRR_pat<V6_veqw_and, And, seteq, HQ32, HVI32, HVI32>;
488 def: AccRRR_pat<V6_veqw_or, Or, seteq, HQ32, HVI32, HVI32>;
489 def: AccRRR_pat<V6_veqw_xor, Xor, seteq, HQ32, HVI32, HVI32>;
491 def: AccRRR_pat<V6_vgtb_and, And, setgt, HQ8, HVI8, HVI8>;
492 def: AccRRR_pat<V6_vgtb_or, Or, setgt, HQ8, HVI8, HVI8>;
493 def: AccRRR_pat<V6_vgtb_xor, Xor, setgt, HQ8, HVI8, HVI8>;
494 def: AccRRR_pat<V6_vgth_and, And, setgt, HQ16, HVI16, HVI16>;
495 def: AccRRR_pat<V6_vgth_or, Or, setgt, HQ16, HVI16, HVI16>;
496 def: AccRRR_pat<V6_vgth_xor, Xor, setgt, HQ16, HVI16, HVI16>;
497 def: AccRRR_pat<V6_vgtw_and, And, setgt, HQ32, HVI32, HVI32>;
498 def: AccRRR_pat<V6_vgtw_or, Or, setgt, HQ32, HVI32, HVI32>;
499 def: AccRRR_pat<V6_vgtw_xor, Xor, setgt, HQ32, HVI32, HVI32>;
501 def: AccRRR_pat<V6_vgtub_and, And, setugt, HQ8, HVI8, HVI8>;
502 def: AccRRR_pat<V6_vgtub_or, Or, setugt, HQ8, HVI8, HVI8>;
503 def: AccRRR_pat<V6_vgtub_xor, Xor, setugt, HQ8, HVI8, HVI8>;
504 def: AccRRR_pat<V6_vgtuh_and, And, setugt, HQ16, HVI16, HVI16>;
505 def: AccRRR_pat<V6_vgtuh_or, Or, setugt, HQ16, HVI16, HVI16>;
506 def: AccRRR_pat<V6_vgtuh_xor, Xor, setugt, HQ16, HVI16, HVI16>;
507 def: AccRRR_pat<V6_vgtuw_and, And, setugt, HQ32, HVI32, HVI32>;
508 def: AccRRR_pat<V6_vgtuw_or, Or, setugt, HQ32, HVI32, HVI32>;
509 def: AccRRR_pat<V6_vgtuw_xor, Xor, setugt, HQ32, HVI32, HVI32>;