Skip to content

Commit 930bc6c

Browse files
committed
[InstCombine] Avoid use of ConstantExpr::getSExtOrTrunc()
InstCombine will canonicalize the index type, no need to handle the non-canonical case.
1 parent e3c2eac commit 930bc6c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,11 +668,11 @@ getAsConstantIndexedAddress(Type *ElemTy, Value *V, const DataLayout &DL) {
668668
if (!GEP->isInBounds())
669669
break;
670670
if (GEP->hasAllConstantIndices() && GEP->getNumIndices() == 1 &&
671-
GEP->getSourceElementType() == ElemTy) {
671+
GEP->getSourceElementType() == ElemTy &&
672+
GEP->getOperand(1)->getType() == IndexType) {
672673
V = GEP->getOperand(0);
673674
Constant *GEPIndex = static_cast<Constant *>(GEP->getOperand(1));
674-
Index = ConstantExpr::getAdd(
675-
Index, ConstantExpr::getSExtOrTrunc(GEPIndex, IndexType));
675+
Index = ConstantExpr::getAdd(Index, GEPIndex);
676676
continue;
677677
}
678678
break;

0 commit comments

Comments
 (0)