@@ -5553,7 +5553,6 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
55535553 } else {
55545554 Type *I8PtrTy =
55555555 Builder.getPtrTy (Addr->getType ()->getPointerAddressSpace ());
5556- Type *I8Ty = Builder.getInt8Ty ();
55575556
55585557 // Start with the base register. Do this first so that subsequent address
55595558 // matching finds it last, which will prevent it from trying to match it
@@ -5597,8 +5596,8 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
55975596 // SDAG consecutive load/store merging.
55985597 if (ResultPtr->getType () != I8PtrTy)
55995598 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 );
56025601 }
56035602
56045603 ResultIndex = V;
@@ -5609,8 +5608,8 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
56095608 } else {
56105609 if (ResultPtr->getType () != I8PtrTy)
56115610 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 );
56145613 }
56155614
56165615 if (SunkAddr->getType () != Addr->getType ()) {
@@ -6169,7 +6168,6 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
61696168 Type *PtrIdxTy = DL->getIndexType (GEP->getType ());
61706169 Type *I8PtrTy =
61716170 PointerType::get (Ctx, GEP->getType ()->getPointerAddressSpace ());
6172- Type *I8Ty = Type::getInt8Ty (Ctx);
61736171
61746172 BasicBlock::iterator NewBaseInsertPt;
61756173 BasicBlock *NewBaseInsertBB;
@@ -6198,7 +6196,7 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
61986196 if (NewBaseGEP->getType () != I8PtrTy)
61996197 NewBaseGEP = NewBaseBuilder.CreatePointerCast (NewBaseGEP, I8PtrTy);
62006198 NewBaseGEP =
6201- NewBaseBuilder.CreateGEP (I8Ty, NewBaseGEP, BaseIndex, " splitgep" );
6199+ NewBaseBuilder.CreatePtrAdd ( NewBaseGEP, BaseIndex, " splitgep" );
62026200 NewGEPBases.insert (NewBaseGEP);
62036201 return ;
62046202 };
@@ -6235,9 +6233,7 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
62356233 }
62366234
62376235 // Generate a new GEP to replace the current one.
6238- LLVMContext &Ctx = GEP->getContext ();
62396236 Type *PtrIdxTy = DL->getIndexType (GEP->getType ());
6240- Type *I8Ty = Type::getInt8Ty (Ctx);
62416237
62426238 if (!NewBaseGEP) {
62436239 // Create a new base if we don't have one yet. Find the insertion
@@ -6250,7 +6246,7 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
62506246 if (Offset != BaseOffset) {
62516247 // Calculate the new offset for the new GEP.
62526248 Value *Index = ConstantInt::get (PtrIdxTy, Offset - BaseOffset);
6253- NewGEP = Builder.CreateGEP (I8Ty, NewBaseGEP, Index);
6249+ NewGEP = Builder.CreatePtrAdd ( NewBaseGEP, Index);
62546250 }
62556251 replaceAllUsesWith (GEP, NewGEP, FreshBBs, IsHugeFunc);
62566252 LargeOffsetGEPID.erase (GEP);
0 commit comments