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).

llvm-svn: 33012
This commit is contained in:
Reid Spencer 2007-01-08 16:32:00 +00:00
parent 405e204fb3
commit c857bb0b27
3 changed files with 14 additions and 12 deletions

View File

@ -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;
}

View File

@ -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.

View File

@ -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: