[HEXAGON] Fix hvx-isel for extract_subvector op (#129672) · llvm/llvm-project@50343e5 (original) (raw)

Original file line number Diff line number Diff line change
@@ -1265,11 +1265,15 @@ HexagonTargetLowering::extractHvxSubvectorReg(SDValue OrigOp, SDValue VecV,
1265 1265 // the subvector of interest. The subvector will never overlap two single
1266 1266 // vectors.
1267 1267 if (isHvxPairTy(VecTy)) {
1268 -if (Idx * ElemWidth >= 8*HwLen)
1268 +unsigned SubIdx = Hexagon::vsub_lo;
1269 +if (Idx * ElemWidth >= 8 * HwLen) {
1270 + SubIdx = Hexagon::vsub_hi;
1269 1271 Idx -= VecTy.getVectorNumElements() / 2;
1272 + }
1270 1273
1271 - VecV = OrigOp;
1272 -if (typeSplit(VecTy).first == ResTy)
1274 + VecTy = typeSplit(VecTy).first;
1275 + VecV = DAG.getTargetExtractSubreg(SubIdx, dl, VecTy, VecV);
1276 +if (VecTy == ResTy)
1273 1277 return VecV;
1274 1278 }
1275 1279