Index: lib/Analysis/ValueTracking.cpp =================================================================== --- lib/Analysis/ValueTracking.cpp +++ lib/Analysis/ValueTracking.cpp @@ -90,7 +90,7 @@ if (unsigned BitWidth = Ty->getScalarSizeInBits()) return BitWidth; - return DL.getIndexTypeSizeInBits(Ty); + return DL.getPointerTypeSizeInBits(Ty); } namespace { @@ -1120,13 +1120,9 @@ case Instruction::Trunc: { Type *SrcTy = I->getOperand(0)->getType(); - unsigned SrcBitWidth; // Note that we handle pointer operands here because of inttoptr/ptrtoint // which fall through here. - Type *ScalarTy = SrcTy->getScalarType(); - SrcBitWidth = ScalarTy->isPointerTy() ? - Q.DL.getIndexTypeSizeInBits(ScalarTy) : - Q.DL.getTypeSizeInBits(ScalarTy); + unsigned SrcBitWidth = getBitWidth(SrcTy, Q.DL); assert(SrcBitWidth && "SrcBitWidth can't be zero"); Known = Known.zextOrTrunc(SrcBitWidth); @@ -1582,9 +1578,7 @@ V->getType()->isPtrOrPtrVectorTy()) && "Not integer or pointer type!"); - Type *ScalarTy = V->getType()->getScalarType(); - unsigned ExpectedWidth = ScalarTy->isPointerTy() ? - Q.DL.getIndexTypeSizeInBits(ScalarTy) : Q.DL.getTypeSizeInBits(ScalarTy); + unsigned ExpectedWidth = getBitWidth(V->getType(), Q.DL); assert(ExpectedWidth == BitWidth && "V and Known should have same BitWidth"); (void)BitWidth; (void)ExpectedWidth; @@ -2021,7 +2015,7 @@ return true; } - unsigned BitWidth = getBitWidth(V->getType()->getScalarType(), Q.DL); + unsigned BitWidth = getBitWidth(V->getType(), Q.DL); // X | Y != 0 if X != 0 or Y != 0. Value *X = nullptr, *Y = nullptr; @@ -2287,10 +2281,7 @@ // in V, so for undef we have to conservatively return 1. We don't have the // same behavior for poison though -- that's a FIXME today. - Type *ScalarTy = V->getType()->getScalarType(); - unsigned TyBits = ScalarTy->isPointerTy() ? - Q.DL.getIndexTypeSizeInBits(ScalarTy) : - Q.DL.getTypeSizeInBits(ScalarTy); + unsigned TyBits = getBitWidth(V->getType(), Q.DL); unsigned Tmp, Tmp2; unsigned FirstAnswer = 1; Index: lib/Transforms/InstCombine/InstCombineCompares.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineCompares.cpp +++ lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -4284,7 +4284,7 @@ // Get scalar or pointer size. unsigned BitWidth = Ty->isIntOrIntVectorTy() ? Ty->getScalarSizeInBits() - : DL.getIndexTypeSizeInBits(Ty->getScalarType()); + : DL.getPointerTypeSizeInBits(Ty->getScalarType()); if (!BitWidth) return nullptr;