[llvm] [Analysis] Add `KnownBits` optimization for `pdep` and `pext` (PR #204223)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 20 08:02:22 PDT 2026


================
@@ -3955,19 +3955,13 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
   case ISD::PDEP: {
     Known = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);
     Known2 = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
-    // Zeros are retained from the mask operand. But not ones.
-    Known.One.clearAllBits();
-    // The result will have at least as many trailing zeros as the non-mask
-    // operand since bits can only map to the same or higher bit position.
-    Known.Zero.setLowBits(Known2.countMinTrailingZeros());
+    Known = KnownBits::pdep(Known, Known2);
----------------
RKSimon wrote:

Operand mismatch:
```suggestion
    Known = KnownBits::pdep(Known2, Known);
```

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


More information about the llvm-commits mailing list