[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
Wed Oct 26 15:16:06 PDT 2016


majnemer added inline comments.


================
Comment at: lib/IR/ConstantFold.cpp:2063-2070
     if (VectorType *VT = dyn_cast<VectorType>(C->getType()))
       GEPTy = VectorType::get(GEPTy, VT->getNumElements());
+    // When the getelementptr has one of more vector indices, it will
+    // return a vector of pointers. We guarantee that all the vectors
+    // in this case will have the same width, so we can just look at
+    // the first one.
+    else if (VectorType *VT = dyn_cast<VectorType>(Idxs[0]->getType()))
----------------
Could this be replaced with `GetElementPtrInst::getGEPReturnType` ?


https://reviews.llvm.org/D26014





More information about the llvm-commits mailing list