diff options
author | Li Huang <lihuang916@gmail.com> | 2016-10-20 21:38:39 +0000 |
---|---|---|
committer | Li Huang <lihuang916@gmail.com> | 2016-10-20 21:38:39 +0000 |
commit | fcfe8cd3ae78f26643973affd6e8af182528a682 (patch) | |
tree | d0d9bcd7ba4cd8527b18e4c762a324fd6bb05daf /llvm/lib | |
parent | 476cbf901ba21c900e8d19a7547f0fd587a7492a (diff) | |
download | bcm5719-llvm-fcfe8cd3ae78f26643973affd6e8af182528a682.tar.gz bcm5719-llvm-fcfe8cd3ae78f26643973affd6e8af182528a682.zip |
[SCEV] Add a threshold to restrict number of mul operands to be inlined into SCEV
This is to avoid inlining too many multiplication operands into a SCEV, which could
take exponential time in the worst case.
Reviewers: Sanjoy Das, Mehdi Amini, Michael Zolotukhin
Differential Revision: https://reviews.llvm.org/D25794
llvm-svn: 284784
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 9fa0de1aff8..8c6ddffb87b 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -121,6 +121,11 @@ static cl::opt<bool> cl::desc("Verify no dangling value in ScalarEvolution's " "ExprValueMap (slow)")); +static cl::opt<unsigned> MulOpsInlineThreshold( + "scev-mulops-inline-threshold", cl::Hidden, + cl::desc("Threshold for inlining multiplication operands into a SCEV"), + cl::init(1000)); + //===----------------------------------------------------------------------===// // SCEV class definitions //===----------------------------------------------------------------------===// @@ -2516,6 +2521,8 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops, if (Idx < Ops.size()) { bool DeletedMul = false; while (const SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(Ops[Idx])) { + if (Ops.size() > MulOpsInlineThreshold) + break; // If we have an mul, expand the mul operands onto the end of the operands // list. Ops.erase(Ops.begin()+Idx); |