[llvm] 7e3606f - [ScalarEvolution] Control flag for nonstrict inequalities in finite loops

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 23 17:56:59 PST 2022


Author: Mircea Trofin
Date: 2022-02-23T17:56:35-08:00
New Revision: 7e3606f43c63f9622f176a786424c3c92c15f5c0

URL: https://github.com/llvm/llvm-project/commit/7e3606f43c63f9622f176a786424c3c92c15f5c0
DIFF: https://github.com/llvm/llvm-project/commit/7e3606f43c63f9622f176a786424c3c92c15f5c0.diff

LOG: [ScalarEvolution] Control flag for nonstrict inequalities in finite loops

D118090 causes a pretty significant (19%) regression in some Eigen
benchmarks. Investigating is a bit time consuming as the compilation
unit where this occurs is large. Rather than revert, this patch adds a
flag controlling that behavior (enabled by default).

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 08caaaabc4259..24fb780d0f7e6 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -239,6 +239,11 @@ static cl::opt<unsigned> MaxPhiSCCAnalysisSize(
              "Phi strongly connected components"),
     cl::init(8));
 
+static cl::opt<bool>
+    EnableFiniteLoopControl("scalar-evolution-finite-loop", cl::Hidden,
+                            cl::desc("Handle <= and >= in finite loops"),
+                            cl::init(true));
+
 //===----------------------------------------------------------------------===//
 //                           SCEV class definitions
 //===----------------------------------------------------------------------===//
@@ -8660,7 +8665,8 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
       ControlsExit && loopHasNoAbnormalExits(L) && loopIsFiniteByAssumption(L);
   // Simplify the operands before analyzing them.
   (void)SimplifyICmpOperands(Pred, LHS, RHS, /*Depth=*/0,
-                             ControllingFiniteLoop);
+                             (EnableFiniteLoopControl ? ControllingFiniteLoop
+                                                     : false));
 
   // If we have a comparison of a chrec against a constant, try to use value
   // ranges to answer this query.


        


More information about the llvm-commits mailing list