[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 12:55:46 PDT 2016

majnemer added inline comments.

Comment at: lib/IR/ConstantFold.cpp:2063-2069
     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.
+    else
+      GEPTy = GetElementPtrInst::getGEPReturnType(C,
+        makeArrayRef((Value * const *)Idxs.data(), Idxs.size()));
Do we still need this if/else now that we are using `GetElementPtrInst::getGEPReturnType`?


More information about the llvm-commits mailing list