Skip to content

Commit cd39242

Browse files
committed
[InstCombine] Remove no longer needed constant offset case (NFCI)
Now that we canonicalize constant geps to i8 type, this special handling should no longer be needed.
1 parent cdd608b commit cd39242

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,21 +2442,11 @@ Instruction *InstCombinerImpl::visitGEPOfGEP(GetElementPtrInst &GEP,
24422442
if (!GEP.accumulateConstantOffset(DL, Offset))
24432443
return nullptr;
24442444

2445-
APInt OffsetOld = Offset;
24462445
// Convert the total offset back into indices.
24472446
SmallVector<APInt> ConstIndices =
24482447
DL.getGEPIndicesForOffset(BaseType, Offset);
2449-
if (!Offset.isZero() || (!IsFirstType && !ConstIndices[0].isZero())) {
2450-
// If both GEP are constant-indexed, and cannot be merged in either way,
2451-
// convert them to a GEP of i8.
2452-
if (Src->hasAllConstantIndices())
2453-
return replaceInstUsesWith(
2454-
GEP, Builder.CreateGEP(
2455-
Builder.getInt8Ty(), Src->getOperand(0),
2456-
Builder.getInt(OffsetOld), "",
2457-
isMergedGEPInBounds(*Src, *cast<GEPOperator>(&GEP))));
2448+
if (!Offset.isZero() || (!IsFirstType && !ConstIndices[0].isZero()))
24582449
return nullptr;
2459-
}
24602450

24612451
bool IsInBounds = isMergedGEPInBounds(*Src, *cast<GEPOperator>(&GEP));
24622452
SmallVector<Value *> Indices;

0 commit comments

Comments
 (0)