aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-09-11 00:42:56 +0000
committerDevang Patel <dpatel@apple.com>2007-09-11 00:42:56 +0000
commit125642991f6ae8f771010d2bca058bf7893f2c13 (patch)
tree6108197a1b220916b453305a7609510c867b7f62 /lib/Transforms
parentfc4ba4dcd06d1f1f59809e799a3da9ba428a88fc (diff)
downloadexternal_llvm-125642991f6ae8f771010d2bca058bf7893f2c13.zip
external_llvm-125642991f6ae8f771010d2bca058bf7893f2c13.tar.gz
external_llvm-125642991f6ae8f771010d2bca058bf7893f2c13.tar.bz2
Refactor code into a separate method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41826 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/LoopIndexSplit.cpp75
1 files changed, 47 insertions, 28 deletions
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp
index abda03c..f182c91 100644
--- a/lib/Transforms/Scalar/LoopIndexSplit.cpp
+++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp
@@ -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,37 +418,49 @@ 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.
- Value *V0 = CI->getOperand(0);
- Value *V1 = CI->getOperand(1);
-
- SCEVHandle SH0 = SE->getSCEV(V0);
- SCEVHandle SH1 = SE->getSCEV(V1);
-
- if (SH0->isLoopInvariant(L) && isa<SCEVAddRecExpr>(SH1)) {
- SD.SplitValue = V0;
- SD.SplitCondition = CI;
- if (PHINode *PN = dyn_cast<PHINode>(V1)) {
- if (PN == IndVar)
- SplitData.push_back(SD);
- }
- else if (Instruction *Insn = dyn_cast<Instruction>(V1)) {
- if (IndVarIncrement && IndVarIncrement == Insn)
- SplitData.push_back(SD);
- }
+ 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);
+
+ SCEVHandle SH0 = SE->getSCEV(V0);
+ SCEVHandle SH1 = SE->getSCEV(V1);
+
+ if (SH0->isLoopInvariant(L) && isa<SCEVAddRecExpr>(SH1)) {
+ SD.SplitValue = V0;
+ SD.SplitCondition = CI;
+ if (PHINode *PN = dyn_cast<PHINode>(V1)) {
+ if (PN == IndVar)
+ return true;
}
- else if (SH1->isLoopInvariant(L) && isa<SCEVAddRecExpr>(SH0)) {
- SD.SplitValue = V1;
- SD.SplitCondition = CI;
- if (PHINode *PN = dyn_cast<PHINode>(V0)) {
- if (PN == IndVar)
- SplitData.push_back(SD);
- }
- else if (Instruction *Insn = dyn_cast<Instruction>(V0)) {
- if (IndVarIncrement && IndVarIncrement == Insn)
- SplitData.push_back(SD);
- }
+ else if (Instruction *Insn = dyn_cast<Instruction>(V1)) {
+ if (IndVarIncrement && IndVarIncrement == Insn)
+ return true;
}
}
+ else if (SH1->isLoopInvariant(L) && isa<SCEVAddRecExpr>(SH0)) {
+ SD.SplitValue = V1;
+ SD.SplitCondition = CI;
+ if (PHINode *PN = dyn_cast<PHINode>(V0)) {
+ if (PN == IndVar)
+ return true;
+ }
+ else if (Instruction *Insn = dyn_cast<Instruction>(V0)) {
+ if (IndVarIncrement && IndVarIncrement == Insn)
+ return true;
+ }
+ }
+
+ return false;
}
/// processOneIterationLoop - Current loop L contains compare instruction