Skip to content

Commit b1f78ba

Browse files
committed
[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.
1 parent e8743c0 commit b1f78ba

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -1975,8 +1975,6 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
19751975
if (DI == -1) {
19761976
// All the GEPs feeding the PHI are identical. Clone one down into our
19771977
// BB so that it can be merged with the current GEP.
1978-
GEP.getParent()->getInstList().insert(
1979-
GEP.getParent()->getFirstInsertionPt(), NewGEP);
19801978
} else {
19811979
// All the GEPs feeding the PHI differ at a single offset. Clone a GEP
19821980
// into the current block so it can be merged, and create a new PHI to
@@ -1994,11 +1992,10 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
19941992
PN->getIncomingBlock(I));
19951993

19961994
NewGEP->setOperand(DI, NewPN);
1997-
GEP.getParent()->getInstList().insert(
1998-
GEP.getParent()->getFirstInsertionPt(), NewGEP);
1999-
NewGEP->setOperand(DI, NewPN);
20001995
}
20011996

1997+
GEP.getParent()->getInstList().insert(
1998+
GEP.getParent()->getFirstInsertionPt(), NewGEP);
20021999
GEP.setOperand(0, NewGEP);
20032000
PtrOp = NewGEP;
20042001
}

0 commit comments

Comments
 (0)