[llvm] [DAG] isKnownToBeAPowerOfTwo - Power of 2 value is known to be power of 2 after BSWAP/BITREVERSE (PR #182207)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 2 03:28:15 PST 2026


================
@@ -4733,7 +4733,9 @@ bool SelectionDAG::isKnownToBeAPowerOfTwo(SDValue Val,
 
   case ISD::ROTL:
   case ISD::ROTR:
-    return isKnownToBeAPowerOfTwo(Val.getOperand(0), /*OrZero=*/false,
+  case ISD::BSWAP:
+  case ISD::BITREVERSE:
----------------
RKSimon wrote:

Just focus on BSWAP/BITREVERSE;
```
  case ISD::ROTL:
  case ISD::ROTR:
    return isKnownToBeAPowerOfTwo(Val.getOperand(0), /*OrZero=*/false,

  case ISD::BSWAP:
  case ISD::BITREVERSE:
    return isKnownToBeAPowerOfTwo(Val.getOperand(0), DemandedElts, OrZero,
                                  Depth + 1);
```

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


More information about the llvm-commits mailing list