[llvm] b1f78ba - [InstCombine] Reduce code duplication in GEP of PHI transform; NFC
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 28 11:07:46 PDT 2020
Author: Nikita Popov
Date: 2020-03-28T19:07:25+01:00
New Revision: b1f78baeaa1aadba8ab8e5b0ba102cec146a16fd
URL: https://github.com/llvm/llvm-project/commit/b1f78baeaa1aadba8ab8e5b0ba102cec146a16fd
DIFF: https://github.com/llvm/llvm-project/commit/b1f78baeaa1aadba8ab8e5b0ba102cec146a16fd.diff
LOG: [InstCombine] Reduce code duplication in GEP of PHI transform; NFC
The `NewGEP->setOperand(DI, NewPN)` call was duplicated, and the
insertion of NewGEP is the same in both if/else, so we can extract it.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index f2bc6968c3e8..49e39c3bc87a 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1975,8 +1975,6 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
if (DI == -1) {
// All the GEPs feeding the PHI are identical. Clone one down into our
// BB so that it can be merged with the current GEP.
- GEP.getParent()->getInstList().insert(
- GEP.getParent()->getFirstInsertionPt(), NewGEP);
} else {
// All the GEPs feeding the PHI
diff er at a single offset. Clone a GEP
// into the current block so it can be merged, and create a new PHI to
@@ -1994,11 +1992,10 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
PN->getIncomingBlock(I));
NewGEP->setOperand(DI, NewPN);
- GEP.getParent()->getInstList().insert(
- GEP.getParent()->getFirstInsertionPt(), NewGEP);
- NewGEP->setOperand(DI, NewPN);
}
+ GEP.getParent()->getInstList().insert(
+ GEP.getParent()->getFirstInsertionPt(), NewGEP);
GEP.setOperand(0, NewGEP);
PtrOp = NewGEP;
}
More information about the llvm-commits
mailing list