[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 12:22:35 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));
----------------
Can you use `APSInt::getMinValue(BitWidth, !SI->isSigned())` instead?
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:2079-2080
+ unsigned BitWidth = Ty->getScalarSizeInBits();
+ APInt Max = SI->isSigned() ? APInt::getSignedMaxValue(BitWidth)
+ : APInt::getMaxValue(BitWidth);
+ return replaceInstUsesWith(*SI, ConstantInt::get(Ty, Max));
----------------
Same
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