@@ -2610,7 +2610,7 @@ static SDValue convertToScalableVector(EVT VT, SDValue V, SelectionDAG &DAG,
2610
2610
assert(V.getValueType().isFixedLengthVector() &&
2611
2611
"Expected a fixed length vector operand!");
2612
2612
SDLoc DL(V);
2613
- SDValue Zero = DAG.getConstant (0, DL, Subtarget.getXLenVT() );
2613
+ SDValue Zero = DAG.getVectorIdxConstant (0, DL);
2614
2614
return DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, DAG.getUNDEF(VT), V, Zero);
2615
2615
}
2616
2616
@@ -3472,7 +3472,7 @@ static SDValue lowerBuildVectorViaDominantValues(SDValue Op, SelectionDAG &DAG,
3472
3472
continue;
3473
3473
if (ValueCounts[V] == 1) {
3474
3474
Vec = DAG.getNode(ISD::INSERT_VECTOR_ELT, DL, VT, Vec, V,
3475
- DAG.getConstant (OpIdx.index(), DL, XLenVT ));
3475
+ DAG.getVectorIdxConstant (OpIdx.index(), DL));
3476
3476
} else {
3477
3477
// Blend in all instances of this value using a VSELECT, using a
3478
3478
// mask where each bit signals whether that element is the one
@@ -3688,7 +3688,7 @@ static SDValue lowerBuildVectorOfConstants(SDValue Op, SelectionDAG &DAG,
3688
3688
SDValue Vec = DAG.getNode(ISD::INSERT_VECTOR_ELT, DL, ViaVecVT,
3689
3689
DAG.getUNDEF(ViaVecVT),
3690
3690
DAG.getConstant(SplatValue, DL, XLenVT),
3691
- DAG.getConstant (0, DL, XLenVT ));
3691
+ DAG.getVectorIdxConstant (0, DL));
3692
3692
if (ViaVecLen != 1)
3693
3693
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL,
3694
3694
MVT::getVectorVT(ViaIntVT, 1), Vec,
@@ -4141,9 +4141,9 @@ static SDValue lowerScalarInsert(SDValue Scalar, SDValue VL, MVT VT,
4141
4141
}
4142
4142
if (ExtractedContainerVT.bitsLE(VT))
4143
4143
return DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, Passthru,
4144
- ExtractedVal, DAG.getConstant (0, DL, XLenVT ));
4144
+ ExtractedVal, DAG.getVectorIdxConstant (0, DL));
4145
4145
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, ExtractedVal,
4146
- DAG.getConstant (0, DL, XLenVT ));
4146
+ DAG.getVectorIdxConstant (0, DL));
4147
4147
}
4148
4148
}
4149
4149
@@ -5020,12 +5020,12 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
5020
5020
assert(EvenSrc >= 0 && "Undef source?");
5021
5021
EvenV = (EvenSrc / Size) == 0 ? V1 : V2;
5022
5022
EvenV = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, HalfVT, EvenV,
5023
- DAG.getConstant (EvenSrc % Size, DL, XLenVT ));
5023
+ DAG.getVectorIdxConstant (EvenSrc % Size, DL));
5024
5024
5025
5025
assert(OddSrc >= 0 && "Undef source?");
5026
5026
OddV = (OddSrc / Size) == 0 ? V1 : V2;
5027
5027
OddV = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, HalfVT, OddV,
5028
- DAG.getConstant (OddSrc % Size, DL, XLenVT ));
5028
+ DAG.getVectorIdxConstant (OddSrc % Size, DL));
5029
5029
5030
5030
return getWideningInterleave(EvenV, OddV, DL, DAG, Subtarget);
5031
5031
}
@@ -6088,7 +6088,7 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
6088
6088
return SDValue();
6089
6089
return DAG.getBitcast(VT, DAG.getNode(ISD::INSERT_VECTOR_ELT, DL, BVT,
6090
6090
DAG.getUNDEF(BVT), Op0,
6091
- DAG.getConstant (0, DL, XLenVT )));
6091
+ DAG.getVectorIdxConstant (0, DL)));
6092
6092
}
6093
6093
return SDValue();
6094
6094
}
@@ -6101,7 +6101,7 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
6101
6101
return SDValue();
6102
6102
SDValue BVec = DAG.getBitcast(BVT, Op0);
6103
6103
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT, BVec,
6104
- DAG.getConstant (0, DL, XLenVT ));
6104
+ DAG.getVectorIdxConstant (0, DL));
6105
6105
}
6106
6106
return SDValue();
6107
6107
}
@@ -6600,8 +6600,9 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
6600
6600
// Don't insert undef subvectors.
6601
6601
if (SubVec.isUndef())
6602
6602
continue;
6603
- Vec = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, Vec, SubVec,
6604
- DAG.getIntPtrConstant(OpIdx.index() * NumOpElts, DL));
6603
+ Vec =
6604
+ DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, Vec, SubVec,
6605
+ DAG.getVectorIdxConstant(OpIdx.index() * NumOpElts, DL));
6605
6606
}
6606
6607
return Vec;
6607
6608
}
@@ -8404,7 +8405,7 @@ SDValue RISCVTargetLowering::lowerEXTRACT_VECTOR_ELT(SDValue Op,
8404
8405
if (!EltVT.isInteger()) {
8405
8406
// Floating-point extracts are handled in TableGen.
8406
8407
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, EltVT, Vec,
8407
- DAG.getConstant (0, DL, XLenVT ));
8408
+ DAG.getVectorIdxConstant (0, DL));
8408
8409
}
8409
8410
8410
8411
SDValue Elt0 = DAG.getNode(RISCVISD::VMV_X_S, DL, XLenVT, Vec);
@@ -8837,7 +8838,7 @@ SDValue RISCVTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
8837
8838
}
8838
8839
case Intrinsic::riscv_vfmv_f_s:
8839
8840
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, Op.getValueType(),
8840
- Op.getOperand(1), DAG.getConstant (0, DL, XLenVT ));
8841
+ Op.getOperand(1), DAG.getVectorIdxConstant (0, DL));
8841
8842
case Intrinsic::riscv_vmv_v_x:
8842
8843
return lowerScalarSplat(Op.getOperand(1), Op.getOperand(2),
8843
8844
Op.getOperand(3), Op.getSimpleValueType(), DL, DAG,
@@ -9437,15 +9438,15 @@ static SDValue lowerReductionSeq(unsigned RVVOpcode, MVT ResVT,
9437
9438
SDValue InitialValue = lowerScalarInsert(StartValue, InnerVL, InnerVT, DL,
9438
9439
DAG, Subtarget);
9439
9440
if (M1VT != InnerVT)
9440
- InitialValue = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, M1VT,
9441
- DAG.getUNDEF(M1VT),
9442
- InitialValue, DAG.getConstant (0, DL, XLenVT ));
9441
+ InitialValue =
9442
+ DAG.getNode(ISD::INSERT_SUBVECTOR, DL, M1VT, DAG.getUNDEF(M1VT),
9443
+ InitialValue, DAG.getVectorIdxConstant (0, DL));
9443
9444
SDValue PassThru = NonZeroAVL ? DAG.getUNDEF(M1VT) : InitialValue;
9444
9445
SDValue Policy = DAG.getTargetConstant(RISCVII::TAIL_AGNOSTIC, DL, XLenVT);
9445
9446
SDValue Ops[] = {PassThru, Vec, InitialValue, Mask, VL, Policy};
9446
9447
SDValue Reduction = DAG.getNode(RVVOpcode, DL, M1VT, Ops);
9447
9448
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, ResVT, Reduction,
9448
- DAG.getConstant (0, DL, XLenVT ));
9449
+ DAG.getVectorIdxConstant (0, DL));
9449
9450
}
9450
9451
9451
9452
SDValue RISCVTargetLowering::lowerVECREDUCE(SDValue Op,
@@ -9490,9 +9491,8 @@ SDValue RISCVTargetLowering::lowerVECREDUCE(SDValue Op,
9490
9491
case ISD::UMIN:
9491
9492
case ISD::SMAX:
9492
9493
case ISD::SMIN:
9493
- MVT XLenVT = Subtarget.getXLenVT();
9494
9494
StartV = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, VecEltVT, Vec,
9495
- DAG.getConstant (0, DL, XLenVT ));
9495
+ DAG.getVectorIdxConstant (0, DL));
9496
9496
}
9497
9497
return lowerReductionSeq(RVVOpcode, Op.getSimpleValueType(), StartV, Vec,
9498
9498
Mask, VL, DL, DAG, Subtarget);
@@ -9521,10 +9521,9 @@ getRVVFPReductionOpAndOperands(SDValue Op, SelectionDAG &DAG, EVT EltVT,
9521
9521
Op.getOperand(0));
9522
9522
case ISD::VECREDUCE_FMIN:
9523
9523
case ISD::VECREDUCE_FMAX: {
9524
- MVT XLenVT = Subtarget.getXLenVT();
9525
9524
SDValue Front =
9526
9525
DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, EltVT, Op.getOperand(0),
9527
- DAG.getConstant (0, DL, XLenVT ));
9526
+ DAG.getVectorIdxConstant (0, DL));
9528
9527
unsigned RVVOpc = (Opcode == ISD::VECREDUCE_FMIN)
9529
9528
? RISCVISD::VECREDUCE_FMIN_VL
9530
9529
: RISCVISD::VECREDUCE_FMAX_VL;
@@ -9646,14 +9645,14 @@ SDValue RISCVTargetLowering::lowerINSERT_SUBVECTOR(SDValue Op,
9646
9645
if (OrigIdx == 0 && Vec.isUndef() && VecVT.isFixedLengthVector()) {
9647
9646
SubVec = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, ContainerVT,
9648
9647
DAG.getUNDEF(ContainerVT), SubVec,
9649
- DAG.getConstant (0, DL, XLenVT ));
9648
+ DAG.getVectorIdxConstant (0, DL));
9650
9649
SubVec = convertFromScalableVector(VecVT, SubVec, DAG, Subtarget);
9651
9650
return DAG.getBitcast(Op.getValueType(), SubVec);
9652
9651
}
9653
9652
9654
9653
SubVec = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, ContainerVT,
9655
9654
DAG.getUNDEF(ContainerVT), SubVec,
9656
- DAG.getConstant (0, DL, XLenVT ));
9655
+ DAG.getVectorIdxConstant (0, DL));
9657
9656
SDValue Mask =
9658
9657
getDefaultVLOps(VecVT, ContainerVT, DL, DAG, Subtarget).first;
9659
9658
// Set the vector length to only the number of elements we care about. Note
@@ -9720,12 +9719,12 @@ SDValue RISCVTargetLowering::lowerINSERT_SUBVECTOR(SDValue Op,
9720
9719
// Extract a subvector equal to the nearest full vector register type. This
9721
9720
// should resolve to a EXTRACT_SUBREG instruction.
9722
9721
AlignedExtract = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InterSubVT, Vec,
9723
- DAG.getConstant (AlignedIdx, DL, XLenVT ));
9722
+ DAG.getVectorIdxConstant (AlignedIdx, DL));
9724
9723
}
9725
9724
9726
9725
SubVec = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, InterSubVT,
9727
9726
DAG.getUNDEF(InterSubVT), SubVec,
9728
- DAG.getConstant (0, DL, XLenVT ));
9727
+ DAG.getVectorIdxConstant (0, DL));
9729
9728
9730
9729
auto [Mask, VL] = getDefaultScalableVLOps(VecVT, DL, DAG, Subtarget);
9731
9730
@@ -9751,7 +9750,7 @@ SDValue RISCVTargetLowering::lowerINSERT_SUBVECTOR(SDValue Op,
9751
9750
// This should resolve to an INSERT_SUBREG instruction.
9752
9751
if (VecVT.bitsGT(InterSubVT))
9753
9752
SubVec = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VecVT, Vec, SubVec,
9754
- DAG.getConstant (AlignedIdx, DL, XLenVT ));
9753
+ DAG.getVectorIdxConstant (AlignedIdx, DL));
9755
9754
9756
9755
// We might have bitcast from a mask type: cast back to the original type if
9757
9756
// required.
@@ -9846,7 +9845,7 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
9846
9845
DAG.getUNDEF(ContainerVT), Vec, SlidedownAmt, Mask, VL);
9847
9846
// Now we can use a cast-like subvector extract to get the result.
9848
9847
Slidedown = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, SubVecVT, Slidedown,
9849
- DAG.getConstant (0, DL, XLenVT ));
9848
+ DAG.getVectorIdxConstant (0, DL));
9850
9849
return DAG.getBitcast(Op.getValueType(), Slidedown);
9851
9850
}
9852
9851
@@ -9923,7 +9922,7 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
9923
9922
// Now the vector is in the right position, extract our final subvector. This
9924
9923
// should resolve to a COPY.
9925
9924
Slidedown = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, SubVecVT, Slidedown,
9926
- DAG.getConstant (0, DL, XLenVT ));
9925
+ DAG.getVectorIdxConstant (0, DL));
9927
9926
9928
9927
// We might have bitcast from a mask type: cast back to the original type if
9929
9928
// required.
@@ -9964,7 +9963,6 @@ SDValue RISCVTargetLowering::lowerVECTOR_DEINTERLEAVE(SDValue Op,
9964
9963
SelectionDAG &DAG) const {
9965
9964
SDLoc DL(Op);
9966
9965
MVT VecVT = Op.getSimpleValueType();
9967
- MVT XLenVT = Subtarget.getXLenVT();
9968
9966
9969
9967
assert(VecVT.isScalableVector() &&
9970
9968
"vector_interleave on non-scalable vector!");
@@ -10030,9 +10028,9 @@ SDValue RISCVTargetLowering::lowerVECTOR_DEINTERLEAVE(SDValue Op,
10030
10028
10031
10029
// Extract the result half of the gather for even and odd
10032
10030
SDValue Even = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VecVT, EvenWide,
10033
- DAG.getConstant (0, DL, XLenVT ));
10031
+ DAG.getVectorIdxConstant (0, DL));
10034
10032
SDValue Odd = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VecVT, OddWide,
10035
- DAG.getConstant (0, DL, XLenVT ));
10033
+ DAG.getVectorIdxConstant (0, DL));
10036
10034
10037
10035
return DAG.getMergeValues({Even, Odd}, DL);
10038
10036
}
@@ -10195,10 +10193,10 @@ SDValue RISCVTargetLowering::lowerVECTOR_REVERSE(SDValue Op,
10195
10193
// FIXME: This is a CONCAT_VECTORS.
10196
10194
SDValue Res =
10197
10195
DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VecVT, DAG.getUNDEF(VecVT), Hi,
10198
- DAG.getIntPtrConstant (0, DL));
10196
+ DAG.getVectorIdxConstant (0, DL));
10199
10197
return DAG.getNode(
10200
10198
ISD::INSERT_SUBVECTOR, DL, VecVT, Res, Lo,
10201
- DAG.getIntPtrConstant (LoVT.getVectorMinNumElements(), DL));
10199
+ DAG.getVectorIdxConstant (LoVT.getVectorMinNumElements(), DL));
10202
10200
}
10203
10201
10204
10202
// Just promote the int type to i16 which will double the LMUL.
@@ -10331,9 +10329,9 @@ RISCVTargetLowering::lowerFixedLengthVectorStoreToRVV(SDValue Op,
10331
10329
// If the size less than a byte, we need to pad with zeros to make a byte.
10332
10330
if (VT.getVectorElementType() == MVT::i1 && VT.getVectorNumElements() < 8) {
10333
10331
VT = MVT::v8i1;
10334
- StoreVal = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT,
10335
- DAG.getConstant(0, DL, VT), StoreVal ,
10336
- DAG.getIntPtrConstant (0, DL));
10332
+ StoreVal =
10333
+ DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, DAG.getConstant(0, DL, VT),
10334
+ StoreVal, DAG.getVectorIdxConstant (0, DL));
10337
10335
}
10338
10336
10339
10337
MVT ContainerVT = getContainerForFixedLengthVector(VT);
@@ -12109,7 +12107,7 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
12109
12107
if (isTypeLegal(BVT)) {
12110
12108
SDValue BVec = DAG.getBitcast(BVT, Op0);
12111
12109
Results.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT, BVec,
12112
- DAG.getConstant (0, DL, XLenVT )));
12110
+ DAG.getVectorIdxConstant (0, DL)));
12113
12111
}
12114
12112
}
12115
12113
break;
@@ -12598,7 +12596,7 @@ static SDValue combineBinOpToReduce(SDNode *N, SelectionDAG &DAG,
12598
12596
if (ScalarVT != ScalarV.getValueType())
12599
12597
NewScalarV =
12600
12598
DAG.getNode(ISD::INSERT_SUBVECTOR, DL, ScalarVT, DAG.getUNDEF(ScalarVT),
12601
- NewScalarV, DAG.getConstant (0, DL, Subtarget.getXLenVT() ));
12599
+ NewScalarV, DAG.getVectorIdxConstant (0, DL));
12602
12600
12603
12601
SDValue Ops[] = {Reduce.getOperand(0), Reduce.getOperand(1),
12604
12602
NewScalarV, Reduce.getOperand(3),
@@ -15248,8 +15246,7 @@ static SDValue performINSERT_VECTOR_ELTCombine(SDNode *N, SelectionDAG &DAG,
15248
15246
if (ConcatVT.getVectorElementType() != InVal.getValueType())
15249
15247
return SDValue();
15250
15248
unsigned ConcatNumElts = ConcatVT.getVectorNumElements();
15251
- SDValue NewIdx = DAG.getConstant(Elt % ConcatNumElts, DL,
15252
- EltNo.getValueType());
15249
+ SDValue NewIdx = DAG.getVectorIdxConstant(Elt % ConcatNumElts, DL);
15253
15250
15254
15251
unsigned ConcatOpIdx = Elt / ConcatNumElts;
15255
15252
SDValue ConcatOp = InVec.getOperand(ConcatOpIdx);
@@ -16449,7 +16446,7 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
16449
16446
SDValue Result =
16450
16447
DAG.getNode(N->getOpcode(), DL, M1VT, M1Passthru, Scalar, VL);
16451
16448
Result = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, Passthru, Result,
16452
- DAG.getConstant (0, DL, XLenVT ));
16449
+ DAG.getVectorIdxConstant (0, DL));
16453
16450
return Result;
16454
16451
}
16455
16452
0 commit comments