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

Chris Lattner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 17 16:48:18 PDT 2022


lattner added inline comments.


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:2884
     if (IntrinsicID == Intrinsic::smul_fix_sat) {
-      APInt Max = APInt::getSignedMaxValue(Width).sextOrSelf(ExtendedWidth);
-      APInt Min = APInt::getSignedMinValue(Width).sextOrSelf(ExtendedWidth);
+      APInt Max = APInt::getSignedMaxValue(Width).sext(ExtendedWidth);
+      APInt Min = APInt::getSignedMinValue(Width).sext(ExtendedWidth);
----------------
foad wrote:
> lattner wrote:
> > I think this can be a zext given the top bit will be zero
> Sure the first one could be zext, but the second one can't be, so it feels conceptually simpler (to me) to keep them both as sext.
likewise, I'm fine with this either way.  zext is slightly more "Strength reduced" than sext, but it doesn't matter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125557



More information about the cfe-commits mailing list