[PATCH] D143437: [llvm] Use pointer index type for more GEP offsets (pre-codegen)
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 13 11:08:42 PST 2023
arsenm added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:282-286
if (!GEP->isInBounds()) {
- Type *IntPtrTy = DL.getIntPtrType(GEP->getType());
- unsigned PtrSize = IntPtrTy->getIntegerBitWidth();
+ Type *PtrIdxTy = DL.getIndexType(GEP->getType());
+ unsigned PtrSize = PtrIdxTy->getIntegerBitWidth();
if (Idx->getType()->getPrimitiveSizeInBits().getFixedValue() > PtrSize)
+ Idx = Builder.CreateTrunc(Idx, PtrIdxTy);
----------------
Don't think this one is tested
================
Comment at: llvm/lib/Transforms/Scalar/ConstantHoisting.cpp:414
+ IntegerType *OffsetTy = DL->getIndexType(*Ctx, GVPtrTy->getAddressSpace());
+ APInt Offset(DL->getTypeSizeInBits(OffsetTy), /*val*/ 0, /*isSigned*/ true);
auto *GEPO = cast<GEPOperator>(ConstExpr);
----------------
Don't think this one is tested
================
Comment at: llvm/lib/Transforms/Scalar/MergeICmps.cpp:160
- APInt Offset = APInt(DL.getPointerTypeSizeInBits(Addr->getType()), 0);
+ APInt Offset = APInt(DL.getIndexTypeSizeInBits(Addr->getType()), 0);
Value *Base = Addr;
----------------
Don't think this one is tested
================
Comment at: llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp:927
- Value *ResultPtr = Builder.CreatePtrToInt(Variadic->getOperand(0), IntPtrTy);
+ Value *ResultPtr = Builder.CreatePtrToInt(Variadic->getOperand(0), PtrIdxTy);
gep_type_iterator GTI = gep_type_begin(*Variadic);
----------------
Doesn't creating a ptrtoint from a non-integral pointer break horribly?
================
Comment at: llvm/lib/Transforms/Utils/FunctionComparator.cpp:719
+ unsigned OffsetBitWidth = DL.getIndexSizeInBits(ASL);
+ APInt OffsetL(OffsetBitWidth, 0), OffsetR(OffsetBitWidth, 0);
if (GEPL->accumulateConstantOffset(DL, OffsetL) &&
----------------
Don't think this one is tested
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143437/new/
https://reviews.llvm.org/D143437
More information about the llvm-commits
mailing list