[PATCH] D108921: [SCEV] If max BTC is zero, then so is the exact BTC

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 31 08:50:42 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6600e1759be1: [SCEV] If max BTC is zero, then so is the exact BTC [1 of N] (authored by reames).

Changed prior to commit:
  https://reviews.llvm.org/D108921?vs=369462&id=369714#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108921/new/

https://reviews.llvm.org/D108921

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/max-trip-count.ll


Index: llvm/test/Analysis/ScalarEvolution/max-trip-count.ll
===================================================================
--- llvm/test/Analysis/ScalarEvolution/max-trip-count.ll
+++ llvm/test/Analysis/ScalarEvolution/max-trip-count.ll
@@ -458,7 +458,7 @@
 
 define void @max_overflow_se(i8 %n) mustprogress {
 ; CHECK-LABEL: Determining loop execution counts for: @max_overflow_se
-; CHECK: Loop %loop: backedge-taken count is (-126 + (126 smax %n))<nsw>
+; CHECK: Loop %loop: backedge-taken count is 0
 ; CHECK: Loop %loop: max backedge-taken count is 0
 entry:
   br label %loop
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -11939,6 +11939,10 @@
   } else {
     MaxBECount = computeMaxBECountForLT(
         Start, Stride, RHS, getTypeSizeInBits(LHS->getType()), IsSigned);
+    // If we prove the max count is zero, so is the symbolic bound.  This can
+    // happen due to differences in how we reason about bounds impied by UB.
+    if (MaxBECount->isZero())
+      BECount = MaxBECount;
   }
 
   if (isa<SCEVCouldNotCompute>(MaxBECount) &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108921.369714.patch
Type: text/x-patch
Size: 1210 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210831/2567202f/attachment.bin>


More information about the llvm-commits mailing list