[llvm] [GlobalISel] Add G_SUB for computeNumSignBits (PR #158384)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 17 04:00:21 PDT 2025


================
@@ -5066,8 +5066,13 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
     if (Tmp2 == 1) return 1; // Early out.
     return std::min(Tmp, Tmp2) - 1;
   case ISD::SUB:
+    Tmp = ComputeNumSignBits(Op.getOperand(0), DemandedElts, Depth + 1);
----------------
RKSimon wrote:

Ideally we'd check https://llvm-compile-time-tracker.com for this one - (SUB X, C) is likely to fold to (ADD, -C) so the reasoning behind checking Op1 first for early-out is weaker, but it might still have an effect.

https://github.com/llvm/llvm-project/pull/158384


More information about the llvm-commits mailing list