[llvm] 0c7f85d - [InstSimplify] Simplify fetching of index size (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 23 13:08:25 PDT 2021


Author: Nikita Popov
Date: 2021-10-23T22:08:15+02:00
New Revision: 0c7f85d7864b233239d3163f6835f6ea8cd5e337

URL: https://github.com/llvm/llvm-project/commit/0c7f85d7864b233239d3163f6835f6ea8cd5e337
DIFF: https://github.com/llvm/llvm-project/commit/0c7f85d7864b233239d3163f6835f6ea8cd5e337.diff

LOG: [InstSimplify] Simplify fetching of index size (NFC)

Directly fetch the size instead of going through the index type
first.

Added: 
    

Modified: 
    llvm/lib/Analysis/InstructionSimplify.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index cd59a7e7df470..e67ba55d395e9 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -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);


        


More information about the llvm-commits mailing list