[InstSimplify] Simplify fetching of index size (NFC)

Directly fetch the size instead of going through the index type
first.
This commit is contained in:
Nikita Popov 2021-10-23 22:07:31 +02:00
parent f9db6a44eb
commit 0c7f85d786
1 changed files with 2 additions and 3 deletions

View File

@ -698,13 +698,12 @@ static Constant *stripAndComputeConstantOffsets(const DataLayout &DL, Value *&V,
bool AllowNonInbounds = false) {
assert(V->getType()->isPtrOrPtrVectorTy());
Type *IntIdxTy = DL.getIndexType(V->getType())->getScalarType();
APInt Offset = APInt::getZero(IntIdxTy->getIntegerBitWidth());
APInt Offset = APInt::getZero(DL.getIndexTypeSizeInBits(V->getType()));
V = V->stripAndAccumulateConstantOffsets(DL, Offset, AllowNonInbounds);
// As that strip may trace through `addrspacecast`, need to sext or trunc
// the offset calculated.
IntIdxTy = DL.getIndexType(V->getType())->getScalarType();
Type *IntIdxTy = DL.getIndexType(V->getType())->getScalarType();
Offset = Offset.sextOrTrunc(IntIdxTy->getIntegerBitWidth());
Constant *OffsetIntPtr = ConstantInt::get(IntIdxTy, Offset);