Refactor code into a separate method.

llvm-svn: 41826
This commit is contained in:
Devang Patel 2007-09-11 00:42:56 +00:00
parent 0678def8d3
commit 8c95373ced
1 changed files with 45 additions and 26 deletions

View File

@ -89,6 +89,13 @@ namespace {
};
private:
// safeIcmpInst - CI is considered safe instruction if one of the operand
// is SCEVAddRecExpr based on induction variable and other operand is
// loop invariant. If CI is safe then populate SplitInfo object SD appropriately
// and return true;
bool safeICmpInst(ICmpInst *CI, SplitInfo &SD);
/// Find condition inside a loop that is suitable candidate for index split.
void findSplitCondition();
@ -411,6 +418,17 @@ void LoopIndexSplit::findSplitCondition() {
// If one operand is loop invariant and second operand is SCEVAddRecExpr
// based on induction variable then CI is a candidate split condition.
if (safeICmpInst(CI, SD))
SplitData.push_back(SD);
}
}
// safeIcmpInst - CI is considered safe instruction if one of the operand
// is SCEVAddRecExpr based on induction variable and other operand is
// loop invariant. If CI is safe then populate SplitInfo object SD appropriately
// and return true;
bool LoopIndexSplit::safeICmpInst(ICmpInst *CI, SplitInfo &SD) {
Value *V0 = CI->getOperand(0);
Value *V1 = CI->getOperand(1);
@ -422,11 +440,11 @@ void LoopIndexSplit::findSplitCondition() {
SD.SplitCondition = CI;
if (PHINode *PN = dyn_cast<PHINode>(V1)) {
if (PN == IndVar)
SplitData.push_back(SD);
return true;
}
else if (Instruction *Insn = dyn_cast<Instruction>(V1)) {
if (IndVarIncrement && IndVarIncrement == Insn)
SplitData.push_back(SD);
return true;
}
}
else if (SH1->isLoopInvariant(L) && isa<SCEVAddRecExpr>(SH0)) {
@ -434,14 +452,15 @@ void LoopIndexSplit::findSplitCondition() {
SD.SplitCondition = CI;
if (PHINode *PN = dyn_cast<PHINode>(V0)) {
if (PN == IndVar)
SplitData.push_back(SD);
return true;
}
else if (Instruction *Insn = dyn_cast<Instruction>(V0)) {
if (IndVarIncrement && IndVarIncrement == Insn)
SplitData.push_back(SD);
}
return true;
}
}
return false;
}
/// processOneIterationLoop - Current loop L contains compare instruction