Skip to content

Commit ae7bffd

Browse files
committed
[InstCombine] Don't create unnecessary zero-index GEP (NFCI)
Note needed with opaque pointers.
1 parent 2460bf2 commit ae7bffd

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -215,27 +215,7 @@ static Instruction *simplifyAllocaArraySize(InstCombinerImpl &IC,
215215
New->setAlignment(AI.getAlign());
216216

217217
replaceAllDbgUsesWith(AI, *New, *New, DT);
218-
219-
// Scan to the end of the allocation instructions, to skip over a block of
220-
// allocas if possible...also skip interleaved debug info
221-
//
222-
BasicBlock::iterator It(New);
223-
while (isa<AllocaInst>(*It) || isa<DbgInfoIntrinsic>(*It))
224-
++It;
225-
226-
// Now that I is pointing to the first non-allocation-inst in the block,
227-
// insert our getelementptr instruction...
228-
//
229-
Type *IdxTy = IC.getDataLayout().getIndexType(AI.getType());
230-
Value *NullIdx = Constant::getNullValue(IdxTy);
231-
Value *Idx[2] = {NullIdx, NullIdx};
232-
Instruction *GEP = GetElementPtrInst::CreateInBounds(
233-
NewTy, New, Idx, New->getName() + ".sub");
234-
IC.InsertNewInstBefore(GEP, It);
235-
236-
// Now make everything use the getelementptr instead of the original
237-
// allocation.
238-
return IC.replaceInstUsesWith(AI, GEP);
218+
return IC.replaceInstUsesWith(AI, New);
239219
}
240220
}
241221

0 commit comments

Comments
 (0)