[PATCH] D62544: [InstCombine] Optimize always overflowing signed saturating add/sub

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 28 13:17:16 PDT 2019


lebedev.ri added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:2073-2074
+        unsigned BitWidth = Ty->getScalarSizeInBits();
+        APInt Min = SI->isSigned() ? APInt::getSignedMinValue(BitWidth)
+                                   : APInt::getMinValue(BitWidth);
+        return replaceInstUsesWith(*SI, ConstantInt::get(Ty, Min));
----------------
nikic wrote:
> lebedev.ri wrote:
> > Can you use `APSInt::getMinValue(BitWidth, !SI->isSigned())` instead?
> It works, but I'm wondering whether it's okay to use APSInt for this purpose. It looks like APSInt is used heavily by clang, but the only uses in the LLVM middle end are for interfacing with the convertToInteger() APFloat API.
If it's not ok to use it for this purpose then i, too, would like to know about that :)



Repository:
  rL LLVM

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

https://reviews.llvm.org/D62544





More information about the llvm-commits mailing list