[PATCH] D38337: Check for overflows when calculating the offset in GetGEPCost.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 27 15:28:23 PDT 2017


efriedma added inline comments.


================
Comment at: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h:681
+    // this function.
+    APInt BaseOffset(/*numbits=*/64, 0);
     int64_t Scale = 0;
----------------
Should we use the pointer width here, rather than the constant "64"?


================
Comment at: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h:707
+        bool overflow = false;
+        BaseOffset = BaseOffset.sadd_ov(
+            APInt(
----------------
Might as well use wrapping math, rather than bailing out on overflow; that's how the actual lowering works.


https://reviews.llvm.org/D38337





More information about the llvm-commits mailing list