[ConstantFolding] Remove some typed pointer handling (NFC)
authorNikita Popov <npopov@redhat.com>
Tue, 18 Jul 2023 09:35:03 +0000 (11:35 +0200)
committerNikita Popov <npopov@redhat.com>
Tue, 18 Jul 2023 09:35:03 +0000 (11:35 +0200)
No need to insert a bitcast.

llvm/lib/Analysis/ConstantFolding.cpp

index 432be1e..514d449 100644 (file)
@@ -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