[llvm] [DAG] isKnownToBeAPowerOfTwo - add DemandedElts, OrZero arguments and support for zero constants (PR #181485)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 15 00:40:12 PST 2026


================
@@ -2243,8 +2243,20 @@ class SelectionDAG {
 
   /// Test if the given value is known to have exactly one bit set. This differs
   /// from computeKnownBits in that it doesn't necessarily determine which bit
-  /// is set.
-  LLVM_ABI bool isKnownToBeAPowerOfTwo(SDValue Val, unsigned Depth = 0) const;
+  /// is set. If 'OrZero' is set, then return true if the given value is either
+  /// a power of two or zero.
+  LLVM_ABI bool isKnownToBeAPowerOfTwo(SDValue Val, bool OrZero = false,
+                                       unsigned Depth = 0) const;
+
+  /// Test if the given value is known to have exactly one bit set. This differs
+  /// from computeKnownBits in that it doesn't necessarily determine which bit
+  /// is set. The DemandedElts argument allows
+  /// us to only collect the minimum sign bits of the requested vector
+  /// elements.If 'OrZero' is set, then return true if the given value is either
----------------
nikic wrote:

```suggestion
  /// elements. If 'OrZero' is set, then return true if the given value is either
```
Also some weird line wrapping above

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


More information about the llvm-commits mailing list