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

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 27 14:24:53 PDT 2016


davide 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
----------------
majnemer wrote:
> Isn't this a dead store to `GEPTy`?
Yes, actually there's more dead code (unless I'm mistaken).


================
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,
----------------
majnemer wrote:
> This comment is a little confusing because nothing vector related is happening here, we are just calling some function.
Agree, removed.


https://reviews.llvm.org/D26014





More information about the llvm-commits mailing list