@@ -6403,7 +6403,6 @@ static SDValue BuildExactUDIV(const TargetLowering &TLI, SDNode *N,
64036403 const SDLoc &dl, SelectionDAG &DAG,
64046404 SmallVectorImpl<SDNode *> &Created) {
64056405 EVT VT = N->getValueType (0 );
6406- EVT SVT = VT.getScalarType ();
64076406 EVT ShVT = TLI.getShiftAmountTy (VT, DAG.getDataLayout ());
64086407 EVT ShSVT = ShVT.getScalarType ();
64096408
@@ -6413,6 +6412,8 @@ static SDValue BuildExactUDIV(const TargetLowering &TLI, SDNode *N,
64136412 auto BuildUDIVPattern = [&](ConstantSDNode *C) {
64146413 if (C->isZero ())
64156414 return false ;
6415+
6416+ EVT CT = C->getValueType (0 );
64166417 APInt Divisor = C->getAPIntValue ();
64176418 unsigned Shift = Divisor.countr_zero ();
64186419 if (Shift) {
@@ -6422,14 +6423,15 @@ static SDValue BuildExactUDIV(const TargetLowering &TLI, SDNode *N,
64226423 // Calculate the multiplicative inverse modulo BW.
64236424 APInt Factor = Divisor.multiplicativeInverse ();
64246425 Shifts.push_back (DAG.getConstant (Shift, dl, ShSVT));
6425- Factors.push_back (DAG.getConstant (Factor, dl, SVT ));
6426+ Factors.push_back (DAG.getConstant (Factor, dl, CT ));
64266427 return true ;
64276428 };
64286429
64296430 SDValue Op1 = N->getOperand (1 );
64306431
64316432 // Collect all magic values from the build vector.
6432- if (!ISD::matchUnaryPredicate (Op1, BuildUDIVPattern))
6433+ if (!ISD::matchUnaryPredicate (Op1, BuildUDIVPattern, /* AllowUndefs=*/ false ,
6434+ /* AllowTruncation=*/ true ))
64336435 return SDValue ();
64346436
64356437 SDValue Shift, Factor;
0 commit comments