[PATCH] D134156: [SCEV][NFC] Mark methods related to Loop Disposition computation as const

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 18 22:53:25 PDT 2022


mkazantsev created this revision.
mkazantsev added reviewers: lebedev.ri, nikic, fhahn, reames.
Herald added a subscriber: hiraditya.
Herald added a project: All.
mkazantsev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The only field they modify is the corresponding cache, which in this case
should be marked as mutable. This will allow us to verify loop disposition
which is not currently something that we do.


https://reviews.llvm.org/D134156

Files:
  llvm/include/llvm/Analysis/ScalarEvolution.h
  llvm/lib/Analysis/ScalarEvolution.cpp


Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -13396,7 +13396,7 @@
 }
 
 ScalarEvolution::LoopDisposition
-ScalarEvolution::getLoopDisposition(const SCEV *S, const Loop *L) {
+ScalarEvolution::getLoopDisposition(const SCEV *S, const Loop *L) const {
   auto &Values = LoopDispositions[S];
   for (auto &V : Values) {
     if (V.getPointer() == L)
@@ -13415,7 +13415,7 @@
 }
 
 ScalarEvolution::LoopDisposition
-ScalarEvolution::computeLoopDisposition(const SCEV *S, const Loop *L) {
+ScalarEvolution::computeLoopDisposition(const SCEV *S, const Loop *L) const {
   switch (S->getSCEVType()) {
   case scConstant:
     return LoopInvariant;
@@ -13496,11 +13496,12 @@
   llvm_unreachable("Unknown SCEV kind!");
 }
 
-bool ScalarEvolution::isLoopInvariant(const SCEV *S, const Loop *L) {
+bool ScalarEvolution::isLoopInvariant(const SCEV *S, const Loop *L) const {
   return getLoopDisposition(S, L) == LoopInvariant;
 }
 
-bool ScalarEvolution::hasComputableLoopEvolution(const SCEV *S, const Loop *L) {
+bool ScalarEvolution::hasComputableLoopEvolution(const SCEV *S,
+                                                 const Loop *L) const {
   return getLoopDisposition(S, L) == LoopComputable;
 }
 
Index: llvm/include/llvm/Analysis/ScalarEvolution.h
===================================================================
--- llvm/include/llvm/Analysis/ScalarEvolution.h
+++ llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -1117,11 +1117,11 @@
 
   /// Return the "disposition" of the given SCEV with respect to the given
   /// loop.
-  LoopDisposition getLoopDisposition(const SCEV *S, const Loop *L);
+  LoopDisposition getLoopDisposition(const SCEV *S, const Loop *L) const;
 
   /// Return true if the value of the given SCEV is unchanging in the
   /// specified loop.
-  bool isLoopInvariant(const SCEV *S, const Loop *L);
+  bool isLoopInvariant(const SCEV *S, const Loop *L) const;
 
   /// Determine if the SCEV can be evaluated at loop's entry. It is true if it
   /// doesn't depend on a SCEVUnknown of an instruction which is dominated by
@@ -1132,7 +1132,7 @@
   /// specified loop.  This property being true implies that the value is
   /// variant in the loop AND that we can emit an expression to compute the
   /// value of the expression at any particular loop iteration.
-  bool hasComputableLoopEvolution(const SCEV *S, const Loop *L);
+  bool hasComputableLoopEvolution(const SCEV *S, const Loop *L) const;
 
   /// Return the "disposition" of the given SCEV with respect to the given
   /// block.
@@ -1487,9 +1487,9 @@
       ValuesAtScopesUsers;
 
   /// Memoized computeLoopDisposition results.
-  DenseMap<const SCEV *,
-           SmallVector<PointerIntPair<const Loop *, 2, LoopDisposition>, 2>>
-      LoopDispositions;
+  mutable DenseMap<const SCEV *,
+                   SmallVector<PointerIntPair<const Loop *, 2, LoopDisposition>,
+                               2> > LoopDispositions;
 
   struct LoopProperties {
     /// Set to true if the loop contains no instruction that can abnormally exit
@@ -1515,7 +1515,7 @@
   }
 
   /// Compute a LoopDisposition value.
-  LoopDisposition computeLoopDisposition(const SCEV *S, const Loop *L);
+  LoopDisposition computeLoopDisposition(const SCEV *S, const Loop *L) const;
 
   /// Memoized computeBlockDisposition results.
   DenseMap<


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134156.461135.patch
Type: text/x-patch
Size: 3468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220919/3d8a7409/attachment-0001.bin>


More information about the llvm-commits mailing list