[llvm] [SDAG] Improve `SimplifyDemandedBits` for mul (PR #90034)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 25 03:20:50 PDT 2024


================
@@ -2782,10 +2782,17 @@ bool TargetLowering::SimplifyDemandedBits(
     unsigned DemandedBitsLZ = DemandedBits.countl_zero();
     APInt LoMask = APInt::getLowBitsSet(BitWidth, BitWidth - DemandedBitsLZ);
     KnownBits KnownOp0, KnownOp1;
-    if (SimplifyDemandedBits(Op0, LoMask, DemandedElts, KnownOp0, TLO,
-                             Depth + 1) ||
-        SimplifyDemandedBits(Op1, LoMask, DemandedElts, KnownOp1, TLO,
+    auto GetDemandedBitsLHSMask = [&](APInt Demanded,
+                                      const KnownBits &KnownRHS) {
+      if (Op.getOpcode() == ISD::MUL)
+        Demanded &= APInt::getLowBitsSet(
----------------
jayfoad wrote:

Could add `APInt::clearHighBits` to help with this? We already have `setHighBits` and `clearLowBits`.

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


More information about the llvm-commits mailing list