[PATCH] D58650: Add support for computing "zext of value" in KnownBits. NFCI

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 27 06:04:25 PST 2019


bjope marked an inline comment as done.
bjope added inline comments.


================
Comment at: llvm/include/llvm/Support/KnownBits.h:123
+    APInt NewZero = Zero.zext(BitWidth);
+    if (ExtendedBitsAreKnownZero)
+      NewZero.setBitsFrom(OldBitWidth);
----------------
RKSimon wrote:
> if (BitWidth > OldBitWidth && ExtendedBitsAreKnownZero)
The calls to Zero.zext(...) and One.zext(...) will assert if not increasing the width. You need to use zextOrTrunc (maybe there is a zextOrSelf as well) if it should be allowed to have the same size.

I guess that is why these methods hasn't been asserting themselves earlier. Should I add an explicit assert here instead of a condition that always should be fulfilled? Or is it OK as is, given this answer?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58650





More information about the llvm-commits mailing list