diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-01-08 16:32:00 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-01-08 16:32:00 +0000 |
commit | abaa8ca433a52dc522f6137c01a9552ebec44bb5 (patch) | |
tree | 55f9d7c704cf818011c2d127abf962301e112834 /lib/Transforms | |
parent | ac8cdf79e7b08c5a5be8efab7750835d5a57b2bc (diff) |
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
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/IndVarSimplify.cpp | 5 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 17 | ||||
-rw-r--r-- | 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 c37132c8cd..a5a9f69c2a 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 ccc4a9cc86..326de6642d 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<PointerType>(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<PointerType>(ParamTy) && isa<PointerType>(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 b8d191a009..00e58180bd 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: |