[llvm] r359693 - [SCEV] Use isKnownViaNonRecursiveReasoning for smax simplification

Keno Fischer via llvm-commits llvm-commits at lists.llvm.org
Wed May 1 08:58:24 PDT 2019


Author: kfischer
Date: Wed May  1 08:58:24 2019
New Revision: 359693

URL: http://llvm.org/viewvc/llvm-project?rev=359693&view=rev
Log:
[SCEV] Use isKnownViaNonRecursiveReasoning for smax simplification

Summary:
Commit
	rL331949: SCEV] Do not use induction in isKnownPredicate for simplification umax

changed the codepath for umax from isKnownPredicate to
isKnownViaNonRecursiveReasoning to avoid compile time blow up (and as
I found out also stack overflows). However, there is an exact copy of
the code for umax that was lacking this change. In D50167 I want to unify
these codepaths, but to avoid that being a behavior change for the smax
case, pull this independent bit out of it.

Reviewed By: sanjoy
Differential Revision: https://reviews.llvm.org/D61166

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=359693&r1=359692&r2=359693&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed May  1 08:58:24 2019
@@ -3605,11 +3605,12 @@ ScalarEvolution::getSMaxExpr(SmallVector
   for (unsigned i = 0, e = Ops.size()-1; i != e; ++i)
     //  X smax Y smax Y  -->  X smax Y
     //  X smax Y         -->  X, if X is always greater than Y
-    if (Ops[i] == Ops[i+1] ||
-        isKnownPredicate(ICmpInst::ICMP_SGE, Ops[i], Ops[i+1])) {
+    if (Ops[i] == Ops[i + 1] || isKnownViaNonRecursiveReasoning(
+                                    ICmpInst::ICMP_SGE, Ops[i], Ops[i + 1])) {
       Ops.erase(Ops.begin()+i+1, Ops.begin()+i+2);
       --i; --e;
-    } else if (isKnownPredicate(ICmpInst::ICMP_SLE, Ops[i], Ops[i+1])) {
+    } else if (isKnownViaNonRecursiveReasoning(ICmpInst::ICMP_SLE, Ops[i],
+                                               Ops[i + 1])) {
       Ops.erase(Ops.begin()+i, Ops.begin()+i+1);
       --i; --e;
     }




More information about the llvm-commits mailing list