@@ -31475,23 +31475,24 @@ static SDValue reduceVMULWidth(SDNode *N, SelectionDAG &DAG,
31475
31475
SDValue N0 = N->getOperand(0);
31476
31476
SDValue N1 = N->getOperand(1);
31477
31477
EVT VT = N->getOperand(0).getValueType();
31478
+ unsigned NumElts = VT.getVectorNumElements();
31478
31479
unsigned RegSize = 128;
31479
31480
MVT OpsVT = MVT::getVectorVT(MVT::i16, RegSize / 16);
31480
- EVT ReducedVT =
31481
- EVT::getVectorVT(*DAG.getContext(), MVT::i16, VT.getVectorNumElements());
31481
+ EVT ReducedVT = EVT::getVectorVT(*DAG.getContext(), MVT::i16, NumElts);
31482
+
31482
31483
// Shrink the operands of mul.
31483
31484
SDValue NewN0 = DAG.getNode(ISD::TRUNCATE, DL, ReducedVT, N0);
31484
31485
SDValue NewN1 = DAG.getNode(ISD::TRUNCATE, DL, ReducedVT, N1);
31485
31486
31486
- if (VT.getVectorNumElements() >= OpsVT.getVectorNumElements()) {
31487
+ if (NumElts >= OpsVT.getVectorNumElements()) {
31487
31488
// Generate the lower part of mul: pmullw. For MULU8/MULS8, only the
31488
31489
// lower part is needed.
31489
31490
SDValue MulLo = DAG.getNode(ISD::MUL, DL, ReducedVT, NewN0, NewN1);
31490
31491
if (Mode == MULU8 || Mode == MULS8) {
31491
31492
return DAG.getNode((Mode == MULU8) ? ISD::ZERO_EXTEND : ISD::SIGN_EXTEND,
31492
31493
DL, VT, MulLo);
31493
31494
} else {
31494
- MVT ResVT = MVT::getVectorVT(MVT::i32, VT.getVectorNumElements() / 2);
31495
+ MVT ResVT = MVT::getVectorVT(MVT::i32, NumElts / 2);
31495
31496
// Generate the higher part of mul: pmulhw/pmulhuw. For MULU16/MULS16,
31496
31497
// the higher part is also needed.
31497
31498
SDValue MulHi = DAG.getNode(Mode == MULS16 ? ISD::MULHS : ISD::MULHU, DL,
@@ -31500,18 +31501,18 @@ static SDValue reduceVMULWidth(SDNode *N, SelectionDAG &DAG,
31500
31501
// Repack the lower part and higher part result of mul into a wider
31501
31502
// result.
31502
31503
// Generate shuffle functioning as punpcklwd.
31503
- SmallVector<int, 16> ShuffleMask(VT.getVectorNumElements() );
31504
- for (unsigned i = 0; i < VT.getVectorNumElements() / 2; i++) {
31504
+ SmallVector<int, 16> ShuffleMask(NumElts );
31505
+ for (unsigned i = 0, e = NumElts / 2; i < e ; i++) {
31505
31506
ShuffleMask[2 * i] = i;
31506
- ShuffleMask[2 * i + 1] = i + VT.getVectorNumElements() ;
31507
+ ShuffleMask[2 * i + 1] = i + NumElts ;
31507
31508
}
31508
31509
SDValue ResLo =
31509
31510
DAG.getVectorShuffle(ReducedVT, DL, MulLo, MulHi, ShuffleMask);
31510
31511
ResLo = DAG.getBitcast(ResVT, ResLo);
31511
31512
// Generate shuffle functioning as punpckhwd.
31512
- for (unsigned i = 0; i < VT.getVectorNumElements() / 2; i++) {
31513
- ShuffleMask[2 * i] = i + VT.getVectorNumElements() / 2;
31514
- ShuffleMask[2 * i + 1] = i + VT.getVectorNumElements() * 3 / 2;
31513
+ for (unsigned i = 0, e = NumElts / 2; i < e ; i++) {
31514
+ ShuffleMask[2 * i] = i + NumElts / 2;
31515
+ ShuffleMask[2 * i + 1] = i + NumElts * 3 / 2;
31515
31516
}
31516
31517
SDValue ResHi =
31517
31518
DAG.getVectorShuffle(ReducedVT, DL, MulLo, MulHi, ShuffleMask);
0 commit comments