[llvm] 9659069 - [SCEV] Further clarify comments regarding UB and zero stride

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 7 13:54:53 PDT 2021


Author: Philip Reames
Date: 2021-09-07T13:53:56-07:00
New Revision: 965906997865a470e1e5751bad6856a2f6375829

URL: https://github.com/llvm/llvm-project/commit/965906997865a470e1e5751bad6856a2f6375829
DIFF: https://github.com/llvm/llvm-project/commit/965906997865a470e1e5751bad6856a2f6375829.diff

LOG: [SCEV] Further clarify comments regarding UB and zero stride

Follow on to D109029. I realized we had no mention of mustprogrress in the comment (as it prexisted mustprogress in the codebase). In the process of adding it, I tweaked the preconditions into something I think is more clear. Note that mustprogress is checked in the code.

Differential Revision: https://reviews.llvm.org/D109091

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index fbaaa7ed47f7..c4fc2532d59d 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -11631,9 +11631,9 @@ ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
     //
     // a) IV is either nuw or nsw depending upon signedness (indicated by the
     //    NoWrap flag).
-    // b) loop is single exit with no side effects.
-    // c) loop has no abnormal exits
-    //
+    // b) the loop is guaranteed to be finite (e.g. is mustprogress and has
+    //    no side effects within the loop)
+    // c) loop has a single static exit (with no abnormal exits)
     //
     // Precondition a) implies that if the stride is negative, this is a single
     // trip loop. The backedge taken count formula reduces to zero in this case.


        


More information about the llvm-commits mailing list