aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index b8bfb97..ff61f1a 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -5553,7 +5553,6 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
} else {
Type *I8PtrTy =
Builder.getPtrTy(Addr->getType()->getPointerAddressSpace());
- Type *I8Ty = Builder.getInt8Ty();
// Start with the base register. Do this first so that subsequent address
// matching finds it last, which will prevent it from trying to match it
@@ -5597,8 +5596,8 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
// SDAG consecutive load/store merging.
if (ResultPtr->getType() != I8PtrTy)
ResultPtr = Builder.CreatePointerCast(ResultPtr, I8PtrTy);
- ResultPtr = Builder.CreateGEP(I8Ty, ResultPtr, ResultIndex,
- "sunkaddr", AddrMode.InBounds);
+ ResultPtr = Builder.CreatePtrAdd(ResultPtr, ResultIndex, "sunkaddr",
+ AddrMode.InBounds);
}
ResultIndex = V;
@@ -5609,8 +5608,8 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
} else {
if (ResultPtr->getType() != I8PtrTy)
ResultPtr = Builder.CreatePointerCast(ResultPtr, I8PtrTy);
- SunkAddr = Builder.CreateGEP(I8Ty, ResultPtr, ResultIndex, "sunkaddr",
- AddrMode.InBounds);
+ SunkAddr = Builder.CreatePtrAdd(ResultPtr, ResultIndex, "sunkaddr",
+ AddrMode.InBounds);
}
if (SunkAddr->getType() != Addr->getType()) {
@@ -6169,7 +6168,6 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
Type *PtrIdxTy = DL->getIndexType(GEP->getType());
Type *I8PtrTy =
PointerType::get(Ctx, GEP->getType()->getPointerAddressSpace());
- Type *I8Ty = Type::getInt8Ty(Ctx);
BasicBlock::iterator NewBaseInsertPt;
BasicBlock *NewBaseInsertBB;
@@ -6198,7 +6196,7 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
if (NewBaseGEP->getType() != I8PtrTy)
NewBaseGEP = NewBaseBuilder.CreatePointerCast(NewBaseGEP, I8PtrTy);
NewBaseGEP =
- NewBaseBuilder.CreateGEP(I8Ty, NewBaseGEP, BaseIndex, "splitgep");
+ NewBaseBuilder.CreatePtrAdd(NewBaseGEP, BaseIndex, "splitgep");
NewGEPBases.insert(NewBaseGEP);
return;
};
@@ -6235,9 +6233,7 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
}
// Generate a new GEP to replace the current one.
- LLVMContext &Ctx = GEP->getContext();
Type *PtrIdxTy = DL->getIndexType(GEP->getType());
- Type *I8Ty = Type::getInt8Ty(Ctx);
if (!NewBaseGEP) {
// Create a new base if we don't have one yet. Find the insertion
@@ -6250,7 +6246,7 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
if (Offset != BaseOffset) {
// Calculate the new offset for the new GEP.
Value *Index = ConstantInt::get(PtrIdxTy, Offset - BaseOffset);
- NewGEP = Builder.CreateGEP(I8Ty, NewBaseGEP, Index);
+ NewGEP = Builder.CreatePtrAdd(NewBaseGEP, Index);
}
replaceAllUsesWith(GEP, NewGEP, FreshBBs, IsHugeFunc);
LargeOffsetGEPID.erase(GEP);