[PATCH] D26014: [ConstantFold] Get the correct vector type when folding a getelementptr instruction with vector indices

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 27 14:12:18 PDT 2016


majnemer added inline comments.


================
Comment at: lib/IR/ConstantFold.cpp:2062
     assert(Ty && "Invalid indices for GEP!");
     Type *GEPTy = PointerType::get(Ty, PtrTy->getAddressSpace());
+    // When the getelementptr has one or more vector indices, it will
----------------
Isn't this a dead store to `GEPTy`?


================
Comment at: lib/IR/ConstantFold.cpp:2063-2064
     Type *GEPTy = PointerType::get(Ty, PtrTy->getAddressSpace());
-    if (VectorType *VT = dyn_cast<VectorType>(C->getType()))
-      GEPTy = VectorType::get(GEPTy, VT->getNumElements());
+    // When the getelementptr has one or more vector indices, it will
+    // return a vector of pointers.
+    GEPTy = GetElementPtrInst::getGEPReturnType(C,
----------------
This comment is a little confusing because nothing vector related is happening here, we are just calling some function.


https://reviews.llvm.org/D26014





More information about the llvm-commits mailing list