[llvm] [Support] Adding fast-path for KnownBits's udiv when RHS is contant (PR #189779)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 1 02:47:13 PDT 2026


================
@@ -1209,6 +1209,26 @@ KnownBits KnownBits::udiv(const KnownBits &LHS, const KnownBits &RHS,
     return Known;
   }
 
+  if (RHS.isConstant()) {
----------------
jayfoad wrote:

This feels like it should be much much simpler, something like:
```
  if (RHS.isConstant() && RHS.getConstant().isPowerOf2())
    return LHS.lshr(RHS.getConstant().logBase2());
```

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


More information about the llvm-commits mailing list