@@ -5553,7 +5553,6 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
5553
5553
} else {
5554
5554
Type *I8PtrTy =
5555
5555
Builder.getPtrTy (Addr->getType ()->getPointerAddressSpace ());
5556
- Type *I8Ty = Builder.getInt8Ty ();
5557
5556
5558
5557
// Start with the base register. Do this first so that subsequent address
5559
5558
// matching finds it last, which will prevent it from trying to match it
@@ -5597,8 +5596,8 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
5597
5596
// SDAG consecutive load/store merging.
5598
5597
if (ResultPtr->getType () != I8PtrTy)
5599
5598
ResultPtr = Builder.CreatePointerCast (ResultPtr, I8PtrTy);
5600
- ResultPtr = Builder.CreateGEP (I8Ty, ResultPtr, ResultIndex,
5601
- " sunkaddr " , AddrMode.InBounds );
5599
+ ResultPtr = Builder.CreatePtrAdd ( ResultPtr, ResultIndex, " sunkaddr " ,
5600
+ AddrMode.InBounds );
5602
5601
}
5603
5602
5604
5603
ResultIndex = V;
@@ -5609,8 +5608,8 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
5609
5608
} else {
5610
5609
if (ResultPtr->getType () != I8PtrTy)
5611
5610
ResultPtr = Builder.CreatePointerCast (ResultPtr, I8PtrTy);
5612
- SunkAddr = Builder.CreateGEP (I8Ty, ResultPtr, ResultIndex, " sunkaddr" ,
5613
- AddrMode.InBounds );
5611
+ SunkAddr = Builder.CreatePtrAdd ( ResultPtr, ResultIndex, " sunkaddr" ,
5612
+ AddrMode.InBounds );
5614
5613
}
5615
5614
5616
5615
if (SunkAddr->getType () != Addr->getType ()) {
@@ -6169,7 +6168,6 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
6169
6168
Type *PtrIdxTy = DL->getIndexType (GEP->getType ());
6170
6169
Type *I8PtrTy =
6171
6170
PointerType::get (Ctx, GEP->getType ()->getPointerAddressSpace ());
6172
- Type *I8Ty = Type::getInt8Ty (Ctx);
6173
6171
6174
6172
BasicBlock::iterator NewBaseInsertPt;
6175
6173
BasicBlock *NewBaseInsertBB;
@@ -6198,7 +6196,7 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
6198
6196
if (NewBaseGEP->getType () != I8PtrTy)
6199
6197
NewBaseGEP = NewBaseBuilder.CreatePointerCast (NewBaseGEP, I8PtrTy);
6200
6198
NewBaseGEP =
6201
- NewBaseBuilder.CreateGEP (I8Ty, NewBaseGEP, BaseIndex, " splitgep" );
6199
+ NewBaseBuilder.CreatePtrAdd ( NewBaseGEP, BaseIndex, " splitgep" );
6202
6200
NewGEPBases.insert (NewBaseGEP);
6203
6201
return ;
6204
6202
};
@@ -6235,9 +6233,7 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
6235
6233
}
6236
6234
6237
6235
// Generate a new GEP to replace the current one.
6238
- LLVMContext &Ctx = GEP->getContext ();
6239
6236
Type *PtrIdxTy = DL->getIndexType (GEP->getType ());
6240
- Type *I8Ty = Type::getInt8Ty (Ctx);
6241
6237
6242
6238
if (!NewBaseGEP) {
6243
6239
// Create a new base if we don't have one yet. Find the insertion
@@ -6250,7 +6246,7 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
6250
6246
if (Offset != BaseOffset) {
6251
6247
// Calculate the new offset for the new GEP.
6252
6248
Value *Index = ConstantInt::get (PtrIdxTy, Offset - BaseOffset);
6253
- NewGEP = Builder.CreateGEP (I8Ty, NewBaseGEP, Index);
6249
+ NewGEP = Builder.CreatePtrAdd ( NewBaseGEP, Index);
6254
6250
}
6255
6251
replaceAllUsesWith (GEP, NewGEP, FreshBBs, IsHugeFunc);
6256
6252
LargeOffsetGEPID.erase (GEP);
0 commit comments