Skip to content

Commit 0c7f85d

Browse files
committed
[InstSimplify] Simplify fetching of index size (NFC)
Directly fetch the size instead of going through the index type first.
1 parent f9db6a4 commit 0c7f85d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,12 @@ static Constant *stripAndComputeConstantOffsets(const DataLayout &DL, Value *&V,
698698
bool AllowNonInbounds = false) {
699699
assert(V->getType()->isPtrOrPtrVectorTy());
700700

701-
Type *IntIdxTy = DL.getIndexType(V->getType())->getScalarType();
702-
APInt Offset = APInt::getZero(IntIdxTy->getIntegerBitWidth());
701+
APInt Offset = APInt::getZero(DL.getIndexTypeSizeInBits(V->getType()));
703702

704703
V = V->stripAndAccumulateConstantOffsets(DL, Offset, AllowNonInbounds);
705704
// As that strip may trace through `addrspacecast`, need to sext or trunc
706705
// the offset calculated.
707-
IntIdxTy = DL.getIndexType(V->getType())->getScalarType();
706+
Type *IntIdxTy = DL.getIndexType(V->getType())->getScalarType();
708707
Offset = Offset.sextOrTrunc(IntIdxTy->getIntegerBitWidth());
709708

710709
Constant *OffsetIntPtr = ConstantInt::get(IntIdxTy, Offset);

0 commit comments

Comments
 (0)