op_iterator-ify some loops, fix 80col violations

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52226 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Gabor Greif 2008-06-11 21:38:51 +00:00
parent 096b461b2e
commit 6725cb5f1c

View File

@ -246,8 +246,8 @@ DeleteTriviallyDeadInstructions(SmallPtrSet<Instruction*,16> &Insts) {
} }
if (isInstructionTriviallyDead(I)) { if (isInstructionTriviallyDead(I)) {
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i)
if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i))) if (Instruction *U = dyn_cast<Instruction>(*i))
Insts.insert(U); Insts.insert(U);
SE->deleteValueFromRecords(I); SE->deleteValueFromRecords(I);
I->eraseFromParent(); I->eraseFromParent();
@ -289,24 +289,25 @@ SCEVHandle LoopStrengthReduce::GetExpressionSCEV(Instruction *Exp) {
gep_type_iterator GTI = gep_type_begin(GEP); gep_type_iterator GTI = gep_type_begin(GEP);
for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i, ++GTI) { for (User::op_iterator i = GEP->op_begin() + 1, e = GEP->op_end();
i != e; ++i, ++GTI) {
// If this is a use of a recurrence that we can analyze, and it comes before // If this is a use of a recurrence that we can analyze, and it comes before
// Op does in the GEP operand list, we will handle this when we process this // Op does in the GEP operand list, we will handle this when we process this
// operand. // operand.
if (const StructType *STy = dyn_cast<StructType>(*GTI)) { if (const StructType *STy = dyn_cast<StructType>(*GTI)) {
const StructLayout *SL = TD->getStructLayout(STy); const StructLayout *SL = TD->getStructLayout(STy);
unsigned Idx = cast<ConstantInt>(GEP->getOperand(i))->getZExtValue(); unsigned Idx = cast<ConstantInt>(*i)->getZExtValue();
uint64_t Offset = SL->getElementOffset(Idx); uint64_t Offset = SL->getElementOffset(Idx);
GEPVal = SE->getAddExpr(GEPVal, GEPVal = SE->getAddExpr(GEPVal,
SE->getIntegerSCEV(Offset, UIntPtrTy)); SE->getIntegerSCEV(Offset, UIntPtrTy));
} else { } else {
unsigned GEPOpiBits = unsigned GEPOpiBits =
GEP->getOperand(i)->getType()->getPrimitiveSizeInBits(); (*i)->getType()->getPrimitiveSizeInBits();
unsigned IntPtrBits = UIntPtrTy->getPrimitiveSizeInBits(); unsigned IntPtrBits = UIntPtrTy->getPrimitiveSizeInBits();
Instruction::CastOps opcode = (GEPOpiBits < IntPtrBits ? Instruction::CastOps opcode = (GEPOpiBits < IntPtrBits ?
Instruction::SExt : (GEPOpiBits > IntPtrBits ? Instruction::Trunc : Instruction::SExt : (GEPOpiBits > IntPtrBits ? Instruction::Trunc :
Instruction::BitCast)); Instruction::BitCast));
Value *OpVal = getCastedVersionOf(opcode, GEP->getOperand(i)); Value *OpVal = getCastedVersionOf(opcode, *i);
SCEVHandle Idx = SE->getSCEV(OpVal); SCEVHandle Idx = SE->getSCEV(OpVal);
uint64_t TypeSize = TD->getABITypeSize(GTI.getIndexedType()); uint64_t TypeSize = TD->getABITypeSize(GTI.getIndexedType());
@ -628,7 +629,8 @@ void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase,
if (NewBasePt && isa<PHINode>(OperandValToReplace)) { if (NewBasePt && isa<PHINode>(OperandValToReplace)) {
InsertPt = NewBasePt; InsertPt = NewBasePt;
++InsertPt; ++InsertPt;
} else if (Instruction *OpInst = dyn_cast<Instruction>(OperandValToReplace)) { } else if (Instruction *OpInst
= dyn_cast<Instruction>(OperandValToReplace)) {
InsertPt = OpInst; InsertPt = OpInst;
while (isa<PHINode>(InsertPt)) ++InsertPt; while (isa<PHINode>(InsertPt)) ++InsertPt;
} }
@ -1593,8 +1595,8 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond,
? UIntPtrTy->getPrimitiveSizeInBits() ? UIntPtrTy->getPrimitiveSizeInBits()
: NewCmpTy->getPrimitiveSizeInBits(); : NewCmpTy->getPrimitiveSizeInBits();
if (RequiresTypeConversion(NewCmpTy, CmpTy)) { if (RequiresTypeConversion(NewCmpTy, CmpTy)) {
// Check if it is possible to rewrite it using a iv / stride of a smaller // Check if it is possible to rewrite it using
// integer type. // an iv / stride of a smaller integer type.
bool TruncOk = false; bool TruncOk = false;
if (NewCmpTy->isInteger()) { if (NewCmpTy->isInteger()) {
unsigned Bits = NewTyBits; unsigned Bits = NewTyBits;