From abaa8ca433a52dc522f6137c01a9552ebec44bb5 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Mon, 8 Jan 2007 16:32:00 +0000 Subject: [PATCH] Comparison of primitive type sizes should now be done in bits, not bytes. This patch converts getPrimitiveSize to getPrimitiveSizeInBits where it is appropriate to do so (comparison of integer primitive types). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33012 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/IndVarSimplify.cpp | 5 +++-- lib/Transforms/Scalar/InstructionCombining.cpp | 17 +++++++++-------- lib/Transforms/Scalar/ScalarReplAggregates.cpp | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index c37132c8cd7..a5a9f69c2a6 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -498,8 +498,9 @@ void IndVarSimplify::runOnLoop(Loop *L) { bool DifferingSizes = false; for (unsigned i = 1, e = IndVars.size(); i != e; ++i) { const Type *Ty = IndVars[i].first->getType(); - DifferingSizes |= Ty->getPrimitiveSize() != LargestType->getPrimitiveSize(); - if (Ty->getPrimitiveSize() > LargestType->getPrimitiveSize()) + DifferingSizes |= + Ty->getPrimitiveSizeInBits() != LargestType->getPrimitiveSizeInBits(); + if (Ty->getPrimitiveSizeInBits() > LargestType->getPrimitiveSizeInBits()) LargestType = Ty; } diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index ccc4a9cc864..326de6642df 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1926,8 +1926,8 @@ FoundSExt: Other = LHS; } if (CI && CI->getType()->isSized() && - (CI->getType()->getPrimitiveSize() == - TD->getIntPtrType()->getPrimitiveSize()) + (CI->getType()->getPrimitiveSizeInBits() == + TD->getIntPtrType()->getPrimitiveSizeInBits()) && isa(CI->getOperand(0)->getType())) { Value *I2 = InsertCastBefore(Instruction::BitCast, CI->getOperand(0), PointerType::get(Type::Int8Ty), I); @@ -7239,9 +7239,9 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { bool isConvertible = ActTy == ParamTy || (isa(ParamTy) && isa(ActTy)) || (ParamTy->isIntegral() && ActTy->isIntegral() && - ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize()) || - (c && ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize() && - c->getSExtValue() > 0); + ParamTy->getPrimitiveSizeInBits() >= ActTy->getPrimitiveSizeInBits()) || + (c && ParamTy->getPrimitiveSizeInBits() >= ActTy->getPrimitiveSizeInBits() + && c->getSExtValue() > 0); if (Callee->isExternal() && !isConvertible) return false; } @@ -7594,8 +7594,8 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) { static Value *InsertCastToIntPtrTy(Value *V, const Type *DTy, Instruction *InsertPoint, InstCombiner *IC) { - unsigned PtrSize = DTy->getPrimitiveSize(); - unsigned VTySize = V->getType()->getPrimitiveSize(); + unsigned PtrSize = DTy->getPrimitiveSizeInBits(); + unsigned VTySize = V->getType()->getPrimitiveSizeInBits(); // We must cast correctly to the pointer type. Ensure that we // sign extend the integer value if it is smaller as this is // used for address computation. @@ -7642,7 +7642,8 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { MadeChange = true; GEP.setOperand(i, Src); } - } else if (SrcTy->getPrimitiveSize() < DestTy->getPrimitiveSize() && + } else if (SrcTy->getPrimitiveSizeInBits() < + DestTy->getPrimitiveSizeInBits() && SrcTy->getPrimitiveSize() == 4) { // We can eliminate a cast from [u]int to [u]long iff the target // is a 32-bit pointer target. diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index b8d191a0097..00e58180bd0 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -665,8 +665,8 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { LI->getName(), LI); } else if (LI->getType()->isFloatingPoint()) { // If needed, truncate the integer to the appropriate size. - if (NV->getType()->getPrimitiveSize() > - LI->getType()->getPrimitiveSize()) { + if (NV->getType()->getPrimitiveSizeInBits() > + LI->getType()->getPrimitiveSizeInBits()) { switch (LI->getType()->getTypeID()) { default: assert(0 && "Unknown FP type!"); case Type::FloatTyID: -- 2.34.1