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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 28 12:40:57 PDT 2019


nikic marked an inline comment as done.
nikic 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));
----------------
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.


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