summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-08-12 15:00:23 +0000
committerDan Gohman <gohman@apple.com>2010-08-12 15:00:23 +0000
commit2de47777f40a7b525dfee8363930a0fe6cdb2e09 (patch)
tree5ac86c6ce06a737b14eb7cc58bba6e5fc96faaea
parent157847f5d1d6567004dc0ae44547f4f41816b308 (diff)
downloadbcm5719-llvm-2de47777f40a7b525dfee8363930a0fe6cdb2e09.tar.gz
bcm5719-llvm-2de47777f40a7b525dfee8363930a0fe6cdb2e09.zip
Optimize ScalarEvolution::getAddExpr's operand factoring code by
having it finish processing all of the muliply operands before starting the whole getAddExpr process over again, instead of immediately after the first simplification. llvm-svn: 110916
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 1803c3c7b5d..394e0159db8 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -1541,6 +1541,7 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
}
// Check this multiply against other multiplies being added together.
+ bool AnyFold = false;
for (unsigned OtherMulIdx = Idx+1;
OtherMulIdx < Ops.size() && isa<SCEVMulExpr>(Ops[OtherMulIdx]);
++OtherMulIdx) {
@@ -1568,12 +1569,14 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
const SCEV *InnerMulSum = getAddExpr(InnerMul1,InnerMul2);
const SCEV *OuterMul = getMulExpr(MulOpSCEV, InnerMulSum);
if (Ops.size() == 2) return OuterMul;
- Ops.erase(Ops.begin()+Idx);
- Ops.erase(Ops.begin()+OtherMulIdx-1);
- Ops.push_back(OuterMul);
- return getAddExpr(Ops);
+ Ops[Idx] = OuterMul;
+ Ops.erase(Ops.begin()+OtherMulIdx);
+ OtherMulIdx = Idx;
+ AnyFold = true;
}
}
+ if (AnyFold)
+ return getAddExpr(Ops);
}
}
OpenPOWER on IntegriCloud