[llvm] ae7bffd - [InstCombine] Don't create unnecessary zero-index GEP (NFCI)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 04:09:17 PST 2023
Author: Nikita Popov
Date: 2023-12-11T13:09:09+01:00
New Revision: ae7bffd71c44c8fa21b91e62da22e4d9272b0193
URL: https://github.com/llvm/llvm-project/commit/ae7bffd71c44c8fa21b91e62da22e4d9272b0193
DIFF: https://github.com/llvm/llvm-project/commit/ae7bffd71c44c8fa21b91e62da22e4d9272b0193.diff
LOG: [InstCombine] Don't create unnecessary zero-index GEP (NFCI)
Note needed with opaque pointers.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index b72b68c68d985..f8fae773e476d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -215,27 +215,7 @@ static Instruction *simplifyAllocaArraySize(InstCombinerImpl &IC,
New->setAlignment(AI.getAlign());
replaceAllDbgUsesWith(AI, *New, *New, DT);
-
- // Scan to the end of the allocation instructions, to skip over a block of
- // allocas if possible...also skip interleaved debug info
- //
- BasicBlock::iterator It(New);
- while (isa<AllocaInst>(*It) || isa<DbgInfoIntrinsic>(*It))
- ++It;
-
- // Now that I is pointing to the first non-allocation-inst in the block,
- // insert our getelementptr instruction...
- //
- Type *IdxTy = IC.getDataLayout().getIndexType(AI.getType());
- Value *NullIdx = Constant::getNullValue(IdxTy);
- Value *Idx[2] = {NullIdx, NullIdx};
- Instruction *GEP = GetElementPtrInst::CreateInBounds(
- NewTy, New, Idx, New->getName() + ".sub");
- IC.InsertNewInstBefore(GEP, It);
-
- // Now make everything use the getelementptr instead of the original
- // allocation.
- return IC.replaceInstUsesWith(AI, GEP);
+ return IC.replaceInstUsesWith(AI, New);
}
}
More information about the llvm-commits
mailing list