[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

Stephen Senran Zhang via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 18 20:54:46 PST 2024


================
@@ -1538,10 +1625,17 @@ ConstantRange ConstantRange::binaryOr(const ConstantRange &Other) const {
 
   ConstantRange KnownBitsRange =
       fromKnownBits(toKnownBits() | Other.toKnownBits(), false);
+
+  //      ~a & ~b    >= x
+  // <=>  ~(~a & ~b) <= ~x
+  // <=>  a | b      <= ~x
+  // <=>  a | b      <  ~x + 1
+  // thus, UpperBound(a | b) == ~LowerBound(~a & ~b) + 1
+  auto UpperBound =
----------------
zsrkmyn wrote:

Fixed! Thx!

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


More information about the llvm-commits mailing list