Remove a special case, allowing the general case to handle it. No functionality

change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24076 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-10-29 03:19:53 +00:00
parent 167f1e2651
commit 455fcc8d35

View File

@ -3814,18 +3814,6 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI,
uint64_t CastElTySize = TD->getTypeSize(CastElTy); uint64_t CastElTySize = TD->getTypeSize(CastElTy);
if (CastElTySize == 0 || AllocElTySize == 0) return 0; if (CastElTySize == 0 || AllocElTySize == 0) return 0;
// If the allocation is for an even multiple of the cast type size
Value *Amt = 0;
if (AllocElTySize % CastElTySize == 0) {
Amt = ConstantUInt::get(Type::UIntTy, AllocElTySize/CastElTySize);
if (ConstantUInt *CI = dyn_cast<ConstantUInt>(AI.getOperand(0)))
Amt = ConstantExpr::getMul(CI, cast<ConstantUInt>(Amt));
else {
// Perform an explicit scale.
Instruction *Tmp = BinaryOperator::createMul(Amt, AI.getOperand(0),"tmp");
Amt = InsertNewInstBefore(Tmp, AI);
}
} else {
// See if we can satisfy the modulus by pulling a scale out of the array // See if we can satisfy the modulus by pulling a scale out of the array
// size argument. // size argument.
unsigned ArraySizeScale = 1; unsigned ArraySizeScale = 1;
@ -3856,6 +3844,7 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI,
if ((AllocElTySize*ArraySizeScale) % CastElTySize != 0) return 0; if ((AllocElTySize*ArraySizeScale) % CastElTySize != 0) return 0;
unsigned Scale = (AllocElTySize*ArraySizeScale)/CastElTySize; unsigned Scale = (AllocElTySize*ArraySizeScale)/CastElTySize;
Value *Amt = 0;
if (Scale == 1) { if (Scale == 1) {
Amt = NumElements; Amt = NumElements;
} else { } else {
@ -3867,7 +3856,6 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI,
Amt = InsertNewInstBefore(Tmp, AI); Amt = InsertNewInstBefore(Tmp, AI);
} }
} }
}
std::string Name = AI.getName(); AI.setName(""); std::string Name = AI.getName(); AI.setName("");
AllocationInst *New; AllocationInst *New;