[llvm] 2310066 - [InstSimplify] Simplify calculation of GEP result pointer type (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 17 08:14:18 PST 2023


Author: Nikita Popov
Date: 2023-11-17T17:14:07+01:00
New Revision: 2310066faab21996a52513c5475552f0e28f0624

URL: https://github.com/llvm/llvm-project/commit/2310066faab21996a52513c5475552f0e28f0624
DIFF: https://github.com/llvm/llvm-project/commit/2310066faab21996a52513c5475552f0e28f0624.diff

LOG: [InstSimplify] Simplify calculation of GEP result pointer type (NFC)

The result type is the same as the input pointer type, except for
splat geps.

Added: 
    

Modified: 
    llvm/lib/Analysis/InstructionSimplify.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index bb58a446b447b3e..700a94e83b50bc8 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4911,10 +4911,8 @@ static Value *simplifyGEPInst(Type *SrcTy, Value *Ptr,
 
   // Compute the (pointer) type returned by the GEP instruction.
   Type *LastType = GetElementPtrInst::getIndexedType(SrcTy, Indices);
-  Type *GEPTy = PointerType::get(LastType, AS);
-  if (VectorType *VT = dyn_cast<VectorType>(Ptr->getType()))
-    GEPTy = VectorType::get(GEPTy, VT->getElementCount());
-  else {
+  Type *GEPTy = Ptr->getType();
+  if (!GEPTy->isVectorTy()) {
     for (Value *Op : Indices) {
       // If one of the operands is a vector, the result type is a vector of
       // pointers. All vector operands must have the same number of elements.


        


More information about the llvm-commits mailing list