[PATCH] D38557: Convert an APInt to int64_t properly in TTI::getGEPCost().

Justin Lebar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 4 13:08:56 PDT 2017


jlebar added inline comments.


================
Comment at: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h:726
+            ? std::numeric_limits<int64_t>::max()
+            : BaseOffset.getSExtValue();
     if (static_cast<T *>(this)->isLegalAddressingMode(
----------------
efriedma wrote:
> This doesn't actually clamp the way you want it to; suppose BaseOffset is less than int64_t::min.
> 
> I'd suggest just BaseOffset.sextOrTrunc(64).getSExtValue(); not precisely the same thing, but good enough until someone comes along with an architecture which actually needs 128-bit pointer offsets.
Indeed, that's better, thank you.


https://reviews.llvm.org/D38557





More information about the llvm-commits mailing list