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

Peter Rong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 14 13:47:47 PST 2022


Peter added inline comments.


================
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:
> RKSimon wrote:
> > RKSimon wrote:
> > > getSignificantBits - you might need to alter the unit test as 'all bits' representations will safely truncate to -1
> > getActiveBits ->getSignificantBits 
> Still needs to be converted to getSignificantBits to match getSExtValue
Sry I forgot about it. This patch should be good to go.


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