[llvm] cd39242 - [InstCombine] Remove no longer needed constant offset case (NFCI)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 01:16:01 PDT 2024


Author: Nikita Popov
Date: 2024-09-13T10:15:54+02:00
New Revision: cd392420322f9968f76cd7f4afb6726d5912b236

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

LOG: [InstCombine] Remove no longer needed constant offset case (NFCI)

Now that we canonicalize constant geps to i8 type, this special
handling should no longer be needed.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 45ae6d342742af..0f9d296490bc3d 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2442,21 +2442,11 @@ Instruction *InstCombinerImpl::visitGEPOfGEP(GetElementPtrInst &GEP,
     if (!GEP.accumulateConstantOffset(DL, Offset))
       return nullptr;
 
-    APInt OffsetOld = Offset;
     // Convert the total offset back into indices.
     SmallVector<APInt> ConstIndices =
         DL.getGEPIndicesForOffset(BaseType, Offset);
-    if (!Offset.isZero() || (!IsFirstType && !ConstIndices[0].isZero())) {
-      // If both GEP are constant-indexed, and cannot be merged in either way,
-      // convert them to a GEP of i8.
-      if (Src->hasAllConstantIndices())
-        return replaceInstUsesWith(
-            GEP, Builder.CreateGEP(
-                     Builder.getInt8Ty(), Src->getOperand(0),
-                     Builder.getInt(OffsetOld), "",
-                     isMergedGEPInBounds(*Src, *cast<GEPOperator>(&GEP))));
+    if (!Offset.isZero() || (!IsFirstType && !ConstIndices[0].isZero()))
       return nullptr;
-    }
 
     bool IsInBounds = isMergedGEPInBounds(*Src, *cast<GEPOperator>(&GEP));
     SmallVector<Value *> Indices;


        


More information about the llvm-commits mailing list