[llvm] 574f2ba - SeparateConstOffsetForGEP: Remove some typed pointer code
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 26 10:58:16 PDT 2023
Author: Matt Arsenault
Date: 2023-06-26T13:58:06-04:00
New Revision: 574f2bac18803a85020efe2663c53988892ba1ec
URL: https://github.com/llvm/llvm-project/commit/574f2bac18803a85020efe2663c53988892ba1ec
DIFF: https://github.com/llvm/llvm-project/commit/574f2bac18803a85020efe2663c53988892ba1ec.diff
LOG: SeparateConstOffsetForGEP: Remove some typed pointer code
Added:
Modified:
llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
index b303edbb7a163..0e35e202d8089 100644
--- a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
+++ b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
@@ -857,8 +857,6 @@ void SeparateConstOffsetFromGEP::lowerToSingleIndexGEPs(
IRBuilder<> Builder(Variadic);
Type *PtrIndexTy = DL->getIndexType(Variadic->getType());
- Type *I8PtrTy =
- Builder.getInt8PtrTy(Variadic->getType()->getPointerAddressSpace());
Value *ResultPtr = Variadic->getOperand(0);
Loop *L = LI->getLoopFor(Variadic->getParent());
// Check if the base is not loop invariant or used more than once.
@@ -867,9 +865,6 @@ void SeparateConstOffsetFromGEP::lowerToSingleIndexGEPs(
!hasMoreThanOneUseInLoop(ResultPtr, L);
Value *FirstResult = nullptr;
- if (ResultPtr->getType() != I8PtrTy)
- ResultPtr = Builder.CreateBitCast(ResultPtr, I8PtrTy);
-
gep_type_iterator GTI = gep_type_begin(*Variadic);
// Create an ugly GEP for each sequential index. We don't create GEPs for
// structure indices, as they are accumulated in the constant offset index.
@@ -917,9 +912,6 @@ void SeparateConstOffsetFromGEP::lowerToSingleIndexGEPs(
if (isSwapCandidate && isLegalToSwapOperand(FirstGEP, SecondGEP, L))
swapGEPOperand(FirstGEP, SecondGEP);
- if (ResultPtr->getType() != Variadic->getType())
- ResultPtr = Builder.CreateBitCast(ResultPtr, Variadic->getType());
-
Variadic->replaceAllUsesWith(ResultPtr);
Variadic->eraseFromParent();
}
@@ -1149,16 +1141,11 @@ bool SeparateConstOffsetFromGEP::splitGEP(GetElementPtrInst *GEP) {
//
// Emit an uglygep in this case.
IRBuilder<> Builder(GEP);
- Type *I8PtrTy =
- Builder.getInt8Ty()->getPointerTo(GEP->getPointerAddressSpace());
-
NewGEP = cast<Instruction>(Builder.CreateGEP(
- Builder.getInt8Ty(), Builder.CreateBitCast(NewGEP, I8PtrTy),
+ Builder.getInt8Ty(), NewGEP,
{ConstantInt::get(PtrIdxTy, AccumulativeByteOffset, true)}, "uglygep",
GEPWasInBounds));
-
NewGEP->copyMetadata(*GEP);
- NewGEP = cast<Instruction>(Builder.CreateBitCast(NewGEP, GEP->getType()));
}
GEP->replaceAllUsesWith(NewGEP);
More information about the llvm-commits
mailing list