[llvm] r331949 - SCEV] Do not use induction in isKnownPredicate for simplification umax.
Serguei Katkov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 9 18:40:43 PDT 2018
Author: skatkov
Date: Wed May 9 18:40:43 2018
New Revision: 331949
URL: http://llvm.org/viewvc/llvm-project?rev=331949&view=rev
Log:
SCEV] Do not use induction in isKnownPredicate for simplification umax.
During simplification umax we trigger isKnownPredicate twice. As a first attempt it
tries the induction. To do that it tries to get post increment of SCEV.
Re-writing the SCEV may result in simplification of umax. If the SCEV contains a lot
of umax operations this recursion becomes very slow.
The added test demonstrates the slow behavior.
To resolve this we use only simple ways to check whether the predicate is known.
Reviewers: sanjoy, mkazantsev
Reviewed By: sanjoy
Subscribers: lebedev.ri, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46046
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=331949&r1=331948&r2=331949&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed May 9 18:40:43 2018
@@ -3517,12 +3517,13 @@ ScalarEvolution::getUMaxExpr(SmallVector
for (unsigned i = 0, e = Ops.size()-1; i != e; ++i)
// X umax Y umax Y --> X umax Y
// X umax Y --> X, if X is always greater than Y
- if (Ops[i] == Ops[i+1] ||
- isKnownPredicate(ICmpInst::ICMP_UGE, Ops[i], Ops[i+1])) {
- Ops.erase(Ops.begin()+i+1, Ops.begin()+i+2);
+ if (Ops[i] == Ops[i + 1] || isKnownViaNonRecursiveReasoning(
+ ICmpInst::ICMP_UGE, Ops[i], Ops[i + 1])) {
+ Ops.erase(Ops.begin() + i + 1, Ops.begin() + i + 2);
--i; --e;
- } else if (isKnownPredicate(ICmpInst::ICMP_ULE, Ops[i], Ops[i+1])) {
- Ops.erase(Ops.begin()+i, Ops.begin()+i+1);
+ } else if (isKnownViaNonRecursiveReasoning(ICmpInst::ICMP_ULE, Ops[i],
+ Ops[i + 1])) {
+ Ops.erase(Ops.begin() + i, Ops.begin() + i + 1);
--i; --e;
}
More information about the llvm-commits
mailing list