[PATCH] D42123: Derive GEP index type from Data Layout

Elena Demikhovsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 31 01:46:53 PST 2018


delena added inline comments.


================
Comment at: ../lib/Analysis/ScalarEvolution.cpp:3667
 bool ScalarEvolution::isSCEVable(Type *Ty) const {
   // Integers and pointers are always SCEVable.
   return Ty->isIntegerTy() || Ty->isPointerTy();
----------------
sanjoy wrote:
> Generally speaking; the SCEV changes need to be tested.
I added several tests that go through the SCEV. Looks ok right now. I can't say that I cover all corner cases, but we can do further changes gradually, there is no impact on in-tree targets. If you see something specific that requires more testing now, please let me know.


================
Comment at: ../lib/Analysis/ScalarEvolution.cpp:3675
   assert(isSCEVable(Ty) && "Type is not SCEVable!");
+  if (Ty->isPointerTy())
+    return getDataLayout().getIndexTypeSizeInBits(Ty);
----------------
sanjoy wrote:
> I don't think this is a correct place to make this change -- the size of a pointer is the size of a pointer.  I think you need to change the SCEV corresponding to GEP(Ptr, Idx) to be "sext(Ptr) + Idx" or "Ptr + sext(Idx)" depending on their relative sizes.
I can't create SCEV expressions with ptr+ind, it will fail with assertion on different types.


Repository:
  rL LLVM

https://reviews.llvm.org/D42123





More information about the llvm-commits mailing list