[PATCH] D125557: [APInt] Remove all uses of zextOrSelf, sextOrSelf and truncOrSelf

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 13 17:09:21 PDT 2022


efriedma added inline comments.


================
Comment at: llvm/lib/IR/ConstantRange.cpp:724
     auto BW = getBitWidth();
-    APInt Min = APInt::getMinValue(BW).zextOrSelf(ResultBitWidth);
-    APInt Max = APInt::getMaxValue(BW).zextOrSelf(ResultBitWidth);
+    APInt Min = APInt::getMinValue(BW);
+    APInt Max = APInt::getMaxValue(BW);
----------------
efriedma wrote:
> Making the bitwidth of the result here not equal to ResultBitWidth seems suspect.
> 
> I think there should just be an `if (ResultBitWidth < BW) return getFull(ResultBitWidth);` here.  Then a simple conversion just works.
Actually, looking at D27294 again, maybe it is actually making the result bitwidth intentionally inflate like this.

This could use a comment explaining what it's doing, in any case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125557



More information about the llvm-commits mailing list