[llvm] Simplify demanded (PR #185113)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 6 13:26:35 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: None (SiliconA-Z)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/185113.diff
1 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp (+12-2)
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 088e6726fea58..40cf9891a83e1 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -1506,11 +1506,21 @@ bool TargetLowering::SimplifyDemandedBits(
}
}
+ // Compute the known bits of Op1 without forcing a deep recursive simplify
+ // so that we can appropriately narrow the DemandedBits for Op0.
+ KnownBits Op1Known = TLO.DAG.computeKnownBits(Op1, DemandedElts, Depth + 1);
+
if (SimplifyDemandedBits(Op1, DemandedBits, DemandedElts, Known, TLO,
Depth + 1))
return true;
- if (SimplifyDemandedBits(Op0, ~Known.Zero & DemandedBits, DemandedElts,
- Known2, TLO, Depth + 1))
+ if (SimplifyDemandedBits(Op0, ~Op1Known.Zero & ~Known.Zero & DemandedBits,
+ DemandedElts, Known2, TLO, Depth + 1))
+ return true;
+ // If we still haven't simplified the node, it may be because Op1 could be
+ // simplified using Op0's known zeros.
+ if ((~Known2.Zero & DemandedBits) != DemandedBits &&
+ SimplifyDemandedBits(Op1, ~Known2.Zero & DemandedBits, DemandedElts,
+ Known, TLO, Depth + 1))
return true;
// If all of the demanded bits are known one on one side, return the other.
``````````
</details>
https://github.com/llvm/llvm-project/pull/185113
More information about the llvm-commits
mailing list