[llvm] e65cabb - [ConstantFolding] Remove some typed pointer handling (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 02:35:26 PDT 2023


Author: Nikita Popov
Date: 2023-07-18T11:35:03+02:00
New Revision: e65cabbbb577c8e5a93227d071e325c0d248df4c

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

LOG: [ConstantFolding] Remove some typed pointer handling (NFC)

No need to insert a bitcast.

Added: 
    

Modified: 
    llvm/lib/Analysis/ConstantFolding.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 432be1e51de240..514d44973c7987 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1001,18 +1001,8 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
     }
 
   // Create a GEP.
-  Constant *C = ConstantExpr::getGetElementPtr(SrcElemTy, Ptr, NewIdxs,
-                                               InBounds, InRangeIndex);
-  assert(
-      cast<PointerType>(C->getType())->isOpaqueOrPointeeTypeMatches(ElemTy) &&
-      "Computed GetElementPtr has unexpected type!");
-
-  // If we ended up indexing a member with a type that doesn't match
-  // the type of what the original indices indexed, add a cast.
-  if (C->getType() != ResTy)
-    C = FoldBitCast(C, ResTy, DL);
-
-  return C;
+  return ConstantExpr::getGetElementPtr(SrcElemTy, Ptr, NewIdxs, InBounds,
+                                        InRangeIndex);
 }
 
 /// Attempt to constant fold an instruction with the


        


More information about the llvm-commits mailing list