[PATCH] D139683: [APInt] provide a safe API for zext value and sext value.

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 01:26:34 PST 2022


RKSimon added inline comments.


================
Comment at: llvm/include/llvm/ADT/APInt.h:1518
+  ///
+  /// This method attempts to return the value of this APInt as a zero extended
+  /// int64_t. The bitwidth must be <= 64 or the value must fit within an
----------------
zero -> sign


================
Comment at: llvm/include/llvm/ADT/APInt.h:1522
+  std::optional<int64_t> trySExtValue() const {
+    return (getActiveBits() <= 64) ? std::optional<int64_t>(getSExtValue())
+                                   : std::optional<int64_t>();
----------------
RKSimon wrote:
> getSignificantBits - you might need to alter the unit test as 'all bits' representations will safely truncate to -1
getActiveBits ->getSignificantBits 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139683



More information about the llvm-commits mailing list