return SDValue();
if (IsSigned) {
- if (DAG.ComputeNumSignBits(Op0) <= (ScalarBits - NarrowSize))
+ if (DAG.ComputeMaxSignificantBits(Op0) > NarrowSize)
return SDValue();
} else {
- APInt Mask = APInt::getBitsSetFrom(ScalarBits, NarrowSize);
- if (!DAG.MaskedValueIsZero(Op0, Mask))
+ if (!DAG.MaskedValueIsZero(Op0,
+ APInt::getBitsSetFrom(ScalarBits, NarrowSize)))
return SDValue();
}
return SDValue();
// If the LHS is a sign extend, try to use vwmul.
- if (IsSignExt && DAG.ComputeNumSignBits(Op1) > (ScalarBits - NarrowSize)) {
+ if (IsSignExt && DAG.ComputeMaxSignificantBits(Op1) <= NarrowSize) {
// Can use vwmul.
- } else {
- // Otherwise try to use vwmulu or vwmulsu.
- APInt Mask = APInt::getBitsSetFrom(ScalarBits, NarrowSize);
- if (DAG.MaskedValueIsZero(Op1, Mask))
- IsVWMULSU = IsSignExt;
- else
- return SDValue();
- }
+ } else if (DAG.MaskedValueIsZero(
+ Op1, APInt::getBitsSetFrom(ScalarBits, NarrowSize))) {
+ // Scalar is zero extended, if the vector is sign extended we can use
+ // vwmulsu. If the vector is zero extended we can use vwmulu.
+ IsVWMULSU = IsSignExt;
+ } else
+ return SDValue();
Op1 = DAG.getNode(RISCVISD::VMV_V_X_VL, DL, NarrowVT,
DAG.getUNDEF(NarrowVT), Op1, VL);