[PATCH] D69387: [ConstantRange] Add toKnownBits() method

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 25 11:11:58 PDT 2019


lebedev.ri added inline comments.


================
Comment at: llvm/lib/IR/ConstantRange.cpp:103
+      return Bit;
+    }
+    llvm_unreachable("Must have found bit mismatch.");
----------------
lebedev.ri wrote:
> nikic wrote:
> > Rather than looping over bits, which seems rather expensive to me, I'd suggest expressing this in terms of `(V0 ^ V1).countLeadingZeros()`.
> This is the brute-force approach, i'm sinking it into APIntOps with proper implementation...
D69439


================
Comment at: llvm/lib/IR/ConstantRange.cpp:117
+  Known.One.clearLowBits(*Bit);
+  Known.Zero.clearLowBits(1 + *Bit);
+
----------------
nikic wrote:
> Why is it necessary to clear one more bit in the Zero case?
Technically, it's the other way around, we can/need to clean exactly `1 + *Bit` low bits from them,
but in the case of `Known.One`, the `1 + *Bit` bit is already always unset (because i used `getUnsignedMin()`),
so it doesn't require unsetting.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69387/new/

https://reviews.llvm.org/D69387





More information about the llvm-commits mailing list