[llvm] [DAG] Use known-bits when creating umulh/smulh. (PR #160916)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 29 07:52:23 PDT 2025
================
@@ -10821,18 +10825,17 @@ static SDValue combineShiftToMULH(SDNode *N, const SDLoc &DL, SelectionDAG &DAG,
}
SDValue MulhRightOp;
- if (ConstantSDNode *Constant = isConstOrConstSplat(RightOp)) {
- unsigned ActiveBits = IsSignExt
- ? Constant->getAPIntValue().getSignificantBits()
- : Constant->getAPIntValue().getActiveBits();
- if (ActiveBits > NarrowVTSize)
+ if (LeftOp.getOpcode() != RightOp.getOpcode()) {
+ if (IsZeroExt && ShiftOperand.hasOneUse() &&
+ DAG.computeKnownBits(RightOp).countMinLeadingZeros() >= NarrowVTSize) {
+ MulhRightOp = DAG.getNode(ISD::TRUNCATE, DL, NarrowVT, RightOp);
+ } else if (IsSignExt && ShiftOperand.hasOneUse() &&
+ DAG.ComputeNumSignBits(RightOp) > NarrowVTSize) {
----------------
RKSimon wrote:
Is this correct? We've gone from a getSignificantBits/getActiveBits check to a leading zero/sign bits check for the same NarrowVTSize bounds
https://github.com/llvm/llvm-project/pull/160916
More information about the llvm-commits
mailing list