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

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 00:49:17 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(
----------------
dtcxzyw wrote:

Done. If necessary, I can split the APInt change into an NFC patch.


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


More information about the llvm-commits mailing list