@@ -9576,11 +9576,11 @@ getSmallestVTForIndex(MVT VecVT, unsigned MaxIdx, SDLoc DL, SelectionDAG &DAG,
95769576 return SmallerVT;
95779577}
95789578
9579- static bool isValidInsertExtractIndex (SDValue Idx) {
9579+ static bool isValidVisniInsertExtractIndex (SDValue Idx) {
95809580 auto *IdxC = dyn_cast<ConstantSDNode>(Idx);
95819581 if (!IdxC || isNullConstant(Idx))
95829582 return false;
9583- return IdxC->getZExtValue() < 32 ;
9583+ return isUInt<5>( IdxC->getZExtValue()) ;
95849584}
95859585
95869586// Custom-legalize INSERT_VECTOR_ELT so that the value is inserted into the
@@ -9696,7 +9696,7 @@ SDValue RISCVTargetLowering::lowerINSERT_VECTOR_ELT(SDValue Op,
96969696
96979697 // Use ri.vinsert.v.x if available.
96989698 if (Subtarget.hasVendorXRivosVisni() && VecVT.isInteger() &&
9699- isValidInsertExtractIndex (Idx)) {
9699+ isValidVisniInsertExtractIndex (Idx)) {
97009700 unsigned Policy = RISCVVType::TAIL_UNDISTURBED_MASK_UNDISTURBED;
97019701 if (VecVT.isFixedLengthVector() && isa<ConstantSDNode>(Idx) &&
97029702 Idx->getAsZExtVal() + 1 == VecVT.getVectorNumElements())
@@ -9915,7 +9915,7 @@ SDValue RISCVTargetLowering::lowerEXTRACT_VECTOR_ELT(SDValue Op,
99159915 // Use ri.vextract.x.v if available.
99169916 // TODO: Avoid index 0 and just use the vmv.x.s
99179917 if (Subtarget.hasVendorXRivosVisni() && EltVT.isInteger() &&
9918- isValidInsertExtractIndex (Idx)) {
9918+ isValidVisniInsertExtractIndex (Idx)) {
99199919 SDValue Elt = DAG.getNode(RISCVISD::RI_VEXTRACT, DL, XLenVT, Vec, Idx);
99209920 return DAG.getNode(ISD::TRUNCATE, DL, EltVT, Elt);
99219921 }
0 commit comments